mysql 6 网络层 IO 的设计

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

首先提到了目前的设计,one_thread_per_connect 模型。
[quote]
......
- 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.
[/quote]

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

[quote]
- 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.
[/quote]

有一个 main 线程负责处理 IO ,有一个线程池负责处理具体的 SQL 事务。
[quote]
- 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.
[/quote]

对比 memcached ,同样在 多线程 环境下使用 libevent ,但是两者还是有不同。
memcached 的具体事务可以直接在 event_loop 线程中进行处理,但是 mysql 的就不行。
所以 mysql 还需要有一个工作者线程池。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值