`
iunknown
  • 浏览: 404126 次
社区版块
存档分类
最新评论

mysql 6 网络层 IO 的设计

阅读更多
mysql 6 中关于网络层 IO 的设计,在下面这个链接中讲了大体的思路
http://forge.mysql.com/worklog/task.php?id=441

首先提到了目前的设计,one_thread_per_connect 模型。
引用

......
- A new thread is created to serve this socket. (Actually, with a
thread cache, it might reuse an existing thtread.)
......

In short: The above design does not scale.


新的设计看起来是一个 半同步半异步 模型,使用 libevent 来管理网络层的 IO 。

引用

- One (main) thread loops over a select/poll where one (or more) of
the sockets is the one for new connections.
- If a new connection was made, accept it and add the new socket to
the set of sockets.
- Input on the other sockets is read and the incomming messages
each assembled.
- Each complete request is passed on to a pthread condition
variable protected queue.

- A (fixed) pool of service threads waits for new requests on the
queue.
- When a new requests is received in the queue, one of the threads
will grab it and handle it, and then return to grab new requests
from the queue.


有一个 main 线程负责处理 IO ,有一个线程池负责处理具体的 SQL 事务。
引用

- It's possible to have more than one "main" thread doing the I/O,
if the I/O is believed to be a bottleneck in large, high-load
installations. However, this also causes some problems, with load
balancing among other things. A first step should be limited to
just having one main thread.


对比 memcached ,同样在 多线程 环境下使用 libevent ,但是两者还是有不同。
memcached 的具体事务可以直接在 event_loop 线程中进行处理,但是 mysql 的就不行。
所以 mysql 还需要有一个工作者线程池。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics