提高:: ASIO线程池与io_service_per_cpu设计 [英] boost::asio threadpool vs. io_service_per_cpu design
问题描述
目前我不确定,我尽量让高性能的服务器,我得到了6Core CPU,所以如果我想用io_service_per_cpu的设计,我有6 io_service's。
Currently I´m not sure, I try to make a high-performance server, I got a 6Core CPU, so if I would use the "io_service_per_cpu" design, I have 6 io_service´s.
我已经听说线程池的设计isn't最好的一个,但我不确定这一点。
I already heard that the threadpool design isn´t the best one, but I´m not sure about that.
你有什么样的知识?有人已经取得与每一个压力测试,还是其他什么东西?
What knowledge do you have? Someone already made a Stress test with each, or something else?
推荐答案
在我的经验,这是大大更容易接近异步应用设计,顺序如下:
In my experience it is vastly easier to approach asynchronous application design with the following order:
- 单线程和单一的
io_service对象
- 多个线程,每个线程调用
:: io_service对象的run()
从单一的io_service对象
。使用<一个href=\"http://www.boost.org/doc/libs/1_46_0/doc/html/boost_asio/overview/core/strands.html\">strands对于需要访问共享数据结构的处理程序。 -
io_service对象
每个CPU
- single thread and a single
io_service
- multiple threads, each invoking
io_service::run()
from a singleio_service
. Use strands for handlers that require access to shared data structures. io_service
per cpu
为每个设计之间改变的动机应该分析您的应用程序后进行。注意,<一href=\"http://stackoverflow.com/questions/6143739/boostasync-write-fails-after-writing-for-some-time/6158561#6158561\">HTTP服务器2 例子只说明了如何使用 io_service对象
每个CPU,它不会告诉你何时或为什么要使用这样的设计。
The motivation for changing between each of these designs should be done after profiling your application. Note that the HTTP Server 2 example only shows how to use an io_service
per CPU, it does not show you when or why to use such a design.
这篇关于提高:: ASIO线程池与io_service_per_cpu设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!