不能使用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 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
php-fpm 設定靜態程式,數量開200
測試程式碼同上
測試引數
wrk -c 100 -t 10 -d 10s 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框架快多少倍.
也提供用資料庫查詢來測試
$res=Model::where('context',"like","%".rand()."%")->limit(1000)->get();
webman
wrk -c 400 -t 20 -d 10s –timeout 10s 127.0.0.1:8787/index/json/
Running 10s test @ http://127.0.0.1:8787/index/json/
20 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.87s 2.12s 9.92s 68.07%
Req/Sec 7.51 8.85 60.00 85.54%
332 requests in 10.05s, 43.12KB read
Requests/sec: 33.04
Transfer/sec: 4.29KB
QPS 33.04
wrk -c 400 -t 20 -d 10s –timeout 10s tp8.localhost/hello/json
Running 10s test @ http://tp8.localhost/hello/json
20 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.99s 1.89s 10.00s 74.32%
Req/Sec 8.61 8.23 40.00 71.12%
257 requests in 10.11s, 48.69KB read
Requests/sec: 25.43
Transfer/sec: 4.82KB
QPS 25.43
本作品採用《CC 協議》,轉載必須註明作者和本文連結