webmen等框架真的比php-fpm并发数高吗?
不能使用sleep方法测试,改用http请求来测试.
webman 8787启动
测试代码,http请求
try {
$client = new Client();
$client->request('GET', "https://cn.bing.com", ['connect_timeout' => 1]);
}catch (\GuzzleHttp\Exception\ConnectException $exception){
}
return json(['code' => 0, 'msg' => 'ok']);
测试参数
wrk -c 100 -t 10 -d 10s http://127.0.0.1:8787/index/json/
结果
Running 10s test @ http://127.0.0.1:8787/index/json/
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 721.60ms 276.84ms 1.77s 78.78%
Req/Sec 13.33 9.37 50.00 82.31%
1053 requests in 10.04s, 138.82KB read
Socket errors: connect 0, read 0, write 0, timeout 68
Requests/sec: 104.88
Transfer/sec: 13.83KB
QPS 104
thinkphp8+nginx
php-fpm 设置静态进程,数量开200
测试代码同上
测试参数
wrk -c 100 -t 10 -d 10s http://127.0.0.1/hello/json/
Running 10s test @ http://tp8.localhost/hello/json/
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 922.59ms 175.13ms 1.96s 69.22%
Req/Sec 13.66 9.13 60.00 80.39%
1033 requests in 10.01s, 195.71KB read
Requests/sec: 103.15
Transfer/sec: 19.54KB
QPS 103
结论,测不出webman框架比传统php-fpm框架快多少倍.