2008-05-17
mysql 6 网络层 IO 的设计
关键字: mysql 半同步半异步
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 还需要有一个工作者线程池。
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 还需要有一个工作者线程池。
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 79325 次

- 详细资料
搜索本博客
我的相册
vim
共 2 张
共 2 张
最近加入圈子
最新评论
-
集成 IOCP 到 Libevent
去找了 memcached for win32 的源代码,结果可以顺利编译,并且 ...
-- by iunknown -
集成 IOCP 到 Libevent
qiezi 写道GetQueuedCompletionStatusEx也支持超时 ...
-- by iunknown -
集成 IOCP 到 Libevent
GetQueuedCompletionStatusEx也支持超时,用它代替sel ...
-- by qiezi -
集成 IOCP 到 Libevent
linux/solaris上的aio有多种回调/通知方式,可能和libevent ...
-- by qiezi -
集成 IOCP 到 Libevent
SPServer是一个很不错的框架,受到启发,我用boost::asio实现了一 ...
-- by wow






评论排行榜