webman在使用默认事件驱动和swoole驱动的对比

nsnake

环境说明:
vm下
OS:centos 7 4核心8G

使用ab测试,并发1000,循环10次;

一下数据取最好结果:
当event_loop为默认的libevent时:

Requests per second:    1644.04 [#/sec] (mean)
Time per request:       608.258 [ms] (mean)
Time per request:       0.608 [ms] (mean, across all concurrent requests)
Transfer rate:          194.27 [Kbytes/sec] received

当event_loop为\Workerman\Events\Swoole::class时

Requests per second:    2063.67 [#/sec] (mean)
Time per request:       484.574 [ms] (mean)
Time per request:       0.485 [ms] (mean, across all concurrent requests)
Transfer rate:          243.85 [Kbytes/sec] received

其中为libevent时。cpu占用率为50%,而使用Swoole时为70%。
当你业务为CPU密集时可以优先使用libevent,而为IO密集时可以考虑使用swoole。

1580 2 0
2个评论

latin

开了几个进程?

  • 暂无评论
luohonen

有可能你都没用到event

  • 暂无评论

nsnake

320
积分
0
获赞数
0
粉丝数
2023-03-03 加入
×
🔝