环境说明:
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。
开了几个进程?
有可能你都没用到event