常见并发模型对比

并发模型 【UNP】对应 多进程 多线程 阻塞IO IO复用 长连接 并发性 多核 开销 互通 顺序性 线程数 特点
accept+read/write 0 一次服务一个客户
accept+fork 1 process-per-connection
accept+thread 6 thread-per-connection
prefork 2/3/4/5 见【UNP】
pre threaded 7/8 见【UNP】
poll(reactor) 6.8节 单线程reactor
reactor+thread-per-task thread-per-request
reactor+worker thread worker-thread-per-connection
reactor+thread pool 主线程io,工作线程计算
reactors in threads one loop per thread(muduo)
reactors in process one loop per process(nginx)
reactors+thread pool 最灵活的io与cpu配置
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容