Pool of Threads dispatching queries to DB servers
Instead of the one thread per connection model we currently have, make it possible to choose to use a pool of threads instead.
When used with a non blocking client library such as libdrizzle or the MariaDB one, this should be much more efficient than the thread per connection model.
Blueprint information
- Status:
- Complete
- Approver:
- Stewart Smith
- Priority:
- Undefined
- Drafter:
- Stewart Smith
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- Approved
- Series goal:
- Accepted for 1.0
- Implementation:
- Implemented
- Milestone target:
- 0.6
- Started by
- Stewart Smith
- Completed by
- Stewart Smith
Whiteboard
It can be done with the following steps:
1) Create interface for Dispatcher class, make one more type of plugin and move current implementation to plugin;
2) Use shared_ptr to queries queue instead of queries queue itself in DBThread class. The current implementation will create new instance of queue for each DBThread instance but thread pool will have one queue for all threads;
3) Remove pointer to DBThreadState from DBThread class. As we have pool of connection threads we should not store DB thread state in connection class;
4) Create new dispatcher plugin. Let's name it as ConnectionsPool
a) create N DBThread instances with the pointers to the one queue of QueryEntries objects;
b) keep pointer to DBConnectionState in the descendants of QueryEntry class;
c) tcpdump plugin becomes responsible for managing it connection states;
d) Dispatcher:
e) Dispatcher:
f) Dispatcher: