今天我想試一下 webman 做 api 服務(wù)的吞吐量 進(jìn)程數(shù)設(shè)置為 100 已安裝 event 擴展 使用環(huán)境是 windows wls2 + docker
使用 Jmeter 進(jìn)行測試
首先是 一個只做 redis 數(shù)據(jù)庫讀寫的接口
通過 Jmeter 測試結(jié)果如下
然后是是 一個只做 mysql 數(shù)據(jù)庫讀寫的接口
通過 Jmeter 測試結(jié)果如下
這兩個接口所測出的吞吐量和平均請求時長都不如我使用 AdapterMan + CI 的吞吐量和平均請求時長
(AdapterMan|論壇內(nèi)關(guān)于 adapterman 的文章)
首先是 redis 數(shù)據(jù)庫讀寫
通過 Jmeter 測試結(jié)果如下
首先是 mysql 數(shù)據(jù)庫讀寫
通過 Jmeter 測試結(jié)果如下
下面是我的問題
我看手冊首頁聲稱 webman 非??斓夷壳皽y試的結(jié)果來看效果并不是很好 這是我環(huán)境的原因嗎(測試時均是 進(jìn)程數(shù)設(shè)置為 100 已安裝 event 擴展 使用環(huán)境是 windows wls2 + docker 所連接 mysql 數(shù)據(jù)庫 redis 數(shù)據(jù)庫是相同的)
補充一點 在使用 AdapterMan 后也做過一些測試 與使用fpm的CI相比 (通過 Jmeter 測試帶業(yè)務(wù)API)性能提升也達(dá)不到2倍
這個性能也未達(dá)到其項目(AdapterMan)中的效果,也想請各位大佬幫忙看下是怎么回事
wls2本身性能很差,尤其是有磁盤讀寫的時候。因為wls2成為瓶頸,壓測結(jié)果相差不是不大。
還有,進(jìn)程數(shù)100感覺多了,進(jìn)程數(shù)開成4倍cpu即可,進(jìn)程太多性能會下降。
關(guān)于webman壓測略低于AdapterMan + CI,
是因為webman用的數(shù)據(jù)庫組件和CI的數(shù)據(jù)庫組件性能差異導(dǎo)致,尤其是laravel/think-orm的Model,性能較低。
如果都用原生PDO或者同一個數(shù)據(jù)庫組件,webman肯定會高于AdapterMan。
另外使用Model、 Db::table() 和原生PDO性能也有差異,之前有人壓測(數(shù)據(jù)庫隨機查詢)的對比數(shù)據(jù)。
http://wtbis.cn/a/1337
如果使用原生PDO webman QPS為1.78萬
如果使用laravel的Db::table() webman QPS降到 0.94萬QPS
如果使用laravel的Model webmanQPS降到 0.72萬QPS
最后建議壓測使用正式linux系統(tǒng)壓測,對于不同框架間的數(shù)據(jù)庫組件的那點性能差異可以忽略。
感謝回復(fù)
首先是關(guān)于 wsl2 的問題 稍后我會嘗試在 debian Linux 上測試
然后是進(jìn)程數(shù) 這個進(jìn)程數(shù)我在測試 webman 和 AdapterMan + CI 時設(shè)置的是相同的 我認(rèn)為的話這個應(yīng)該對結(jié)果差異影響不大 (稍后在 debian Linux 上測試時會嘗試調(diào)整為 cpu * 4)
目前我手邊有一個安裝了圖形界面的 debian11 今天在這個上面測試后我會再回復(fù)您
我的意思是100進(jìn)程對于webman和AdapterMan都有點多了,調(diào)整合適的進(jìn)程他們都會有更好的表現(xiàn)。不是說100進(jìn)程是webman QPS低于AdapterMan的原因。
webman低于AdapterMan的原因是數(shù)據(jù)庫組件的性能差異導(dǎo)致。
cpu 為 8 核
redis 與 webman服務(wù)在同一主機 ab測試發(fā)起端與webman服務(wù)在同一內(nèi)網(wǎng)
由于我本地部署的mysql在使用時報錯(通過 dbeaver 或 其他數(shù)據(jù)庫圖形工具可以正常連接)
PDOException: SQLSTATE[HY000] [2002] Operation timed out in /www/webman/vendor/illuminate/database/Connectors/Connector.php:66
并且我一時也不知怎么解決 所以 mysql 數(shù)據(jù)庫使用的是遠(yuǎn)程服務(wù)器的
用來測試的接口
無業(yè)務(wù)
ab 測試結(jié)果
situ@localhost:~$ ab -n100000 -c200 -k http://172.18.1.0:2345/index/json
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.18.1.0 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software: workerman
Server Hostname: 172.18.1.0
Server Port: 2345
Document Path: /index/json
Document Length: 21 bytes
Concurrency Level: 200
Time taken for tests: 11.365 seconds
Complete requests: 100000
Failed requests: 0
Keep-Alive requests: 100000
Total transferred: 13500000 bytes
HTML transferred: 2100000 bytes
Requests per second: 8799.24 [#/sec] (mean)
Time per request: 22.729 [ms] (mean)
Time per request: 0.114 [ms] (mean, across all concurrent requests)
Transfer rate: 1160.06 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.6 0 88
Processing: 8 23 13.5 19 404
Waiting: 6 23 13.5 19 404
Total: 9 23 14.7 19 444
Percentage of the requests served within a certain time (ms)
50% 19
66% 22
75% 24
80% 26
90% 32
95% 40
98% 55
99% 84
100% 444 (longest request)
帶 redis
ab 測試結(jié)果
situ@localhost:~$ ab -n100000 -c200 -k http://172.18.1.0:2345/index/redisTest
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.18.1.0 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software: workerman
Server Hostname: 172.18.1.0
Server Port: 2345
Document Path: /index/redisTest
Document Length: 61 bytes
Concurrency Level: 200
Time taken for tests: 16.403 seconds
Complete requests: 100000
Failed requests: 0
Keep-Alive requests: 100000
Total transferred: 17500000 bytes
HTML transferred: 6100000 bytes
Requests per second: 6096.32 [#/sec] (mean)
Time per request: 32.807 [ms] (mean)
Time per request: 0.164 [ms] (mean, across all concurrent requests)
Transfer rate: 1041.85 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 26.9 0 1104
Processing: 9 32 14.9 29 302
Waiting: 9 32 14.9 29 302
Total: 9 33 31.1 29 1155
Percentage of the requests served within a certain time (ms)
50% 29
66% 32
75% 36
80% 38
90% 47
95% 58
98% 75
99% 91
100% 1155 (longest request)
帶 sql
ab 測試結(jié)果
situ@localhost:~$ ab -n100000 -c200 -k http://172.18.1.0:2345/index/sqlTest
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.18.1.0 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software: workerman
Server Hostname: 172.18.1.0
Server Port: 2345
Document Path: /index/sqlTest
Document Length: 887 bytes
Concurrency Level: 200
Time taken for tests: 111.727 seconds
Complete requests: 100000
Failed requests: 0
Keep-Alive requests: 100000
Total transferred: 100200000 bytes
HTML transferred: 88700000 bytes
Requests per second: 895.04 [#/sec] (mean)
Time per request: 223.455 [ms] (mean)
Time per request: 1.117 [ms] (mean, across all concurrent requests)
Transfer rate: 875.81 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 8.2 0 276
Processing: 52 222 105.7 185 2517
Waiting: 52 222 105.7 185 2517
Total: 52 222 109.5 185 2777
Percentage of the requests served within a certain time (ms)
50% 185
66% 215
75% 262
80% 295
90% 355
95% 404
98% 482
99% 564
100% 2777 (longest request)
我想請大佬幫忙看下目前這個表現(xiàn)的 webman 是正常的嗎
根據(jù)我之前的壓測結(jié)果來看數(shù)據(jù)不太對。
無業(yè)務(wù) QPS 只有8799 太不正常了,正常應(yīng)該5萬-20萬之間。是不是用了啥中間件寫磁盤了,比如webman/log。
Redis QPS也應(yīng)該過萬才對。
數(shù)據(jù)庫讀寫各一次應(yīng)該有幾千QPS,幾百也不太正常。