浏览 2200 次
锁定老帖子 主题:mysql 6 网络层 IO 的设计
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-17
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 还需要有一个工作者线程池。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |