您好,登錄后才能下訂單哦!
MySQL數據庫壓力測試報告
類別 |
名稱 |
OS |
虛擬機 CentOS release 6.5 (Final) |
DISK |
765GB |
MySQLl |
v5.6.27 |
Sysbench |
v0.5 |
測試innodb buffer pool設置為24G和44G這兩種情形下的性能差距;
測試操作系統cpu個數在8和12這兩種情形下的性能差距;
測試表加索引和不加索引時數據庫性能差距;
測試硬盤的隨機讀、隨機寫、隨機讀寫、順序寫、順序讀、順序讀寫等所有模式的iops、吞吐量。
利用現在生產MySQL備庫搭建壓力測試環境,在測試時,停掉備庫的slave復制:
說明:本次測試,只測試在不同情況下的select查詢,用來測試的sql如下:
SELECT pad FROM test.sbtest1 where k = ‘xxxxxx;
表結構為:
dNSR2XMim4C7D6ZxzQAPoOlyW8cD2FuYoiSibBhc9celLPoemXPl+dYWz+UoRMxj5V9B7e1Z+u6lqlrbWbW1kN0k0IkxcKMEuAU5HOfX3q9NeamiRGLTEkZly6m5A2H06c0ATXmlWOoBBeWkMwj+5vUHb9KsxxpDGscSKiKMKqjAA9hVG4u9Rj8vyNNWbcgL5uAu1vTpz9aLm71GMp9n01ZgUBYm4C7W7jpz9aAH3Wj6fe3AuLqyglmGAHdATgdBn0ps2haZcztPNYW0krMGZ2jBJI6ZNJc3eoxuot9NWZSoLE3AXB7jp+tFzd6jFIot9NSZCoJY3AXB7jGKAJb3SrHUWja9tIZzH90yIDj1/lTbrRtOvZUlubKCV0AAZkB4HQfSmXN3qMUwW301ZkwCXNwF57jGKLm71GOfbb6as0eB85uAv14xQA6TRtOmvBdSWVu1wCD5hQbsjpz7U670mwv5o5bu0gmkj+60iAkd6jubvUY7nZBpqzRcfvDcBfrxii4u9RjuikGmrLDkfvDcBfrxigBZ9D026vBdz2UMlyuMSsvzDHv8AgKv1nzXeopdlIdNWSHI/em4C8dztxRLd6it2Y49NV4NwHm/aADj124oAsRWVvDeT3UcQE84USP3YL0H4ZNWKz5LvUVvPLTTVaDcB5v2gA49duKGu9RF55a6cpg3Y877QAceu3H6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OedCxVpfFmp3EYIhSGGBj2aQbmP5Bl/OhAbVFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf//Z">
數據量為100萬行:
QPS:Queries Per Second意思是“每秒查詢率”,是一臺服務器每秒能夠相應的查詢次數,是對一個特定的查詢服務器在規定時間內所處理流量多少的衡量標準。
cpu負載:通過top命令的load average獲取1分鐘內的平均值,它代表了任務隊列的平均長度。
執行下面的命令準備測試數據:
sysbench --test=/usr/local/src/sysbench-0.5/sysbench/tests/db/oltp.lua \
--mysql-host=localhost \
--mysql-user=root \
--mysql-password=xxxxx \
--mysql-db=test \
--oltp-tables-count=1 \
--oltp-table-size=1000000 \
--num-threads=50 \
--max-requests=1000000 \
--report-interval=1 \
prepare
上述命令會在MySQL的test數據庫里面創建sbtest1表,數據量為100w行。
參數說明:
--mysql-host=locahost #數據庫host
--mysql-port=3306 #數據庫端口
--mysql-user=your_username #數據庫用戶名
--mysql-password=your_password #數據庫密碼
--mysql-db=your_db_for_test #數據庫名
--oltp-tables-count=1 #模擬的表的個數,規格越高該值越大
--oltp-table-size=1000000 #模擬的每張表的行數,規格越高該值越大
--num-threads=50 #模擬的并發數量,規格越高該值越大
--max-requests=100000000 #最大請求次數
--report-interval=1 #每1秒打印一次當前的QPS等值
--test=/usr/local/src/sysbench-0.5/sysbench/tests/db/oltp.lua#選用的測試腳本(lua),此腳本可以從sysbench-0.5源代碼文件目錄下找 [prepare | run | cleanup] #prepare準備數據,run執行測試,cleanup清理數據
sysbench --test=/usr/local/src/sysbench-0.5/sysbench/tests/db/select.lua \
--mysql-host=localhost \
--mysql-user=root \
--mysql-password=xxxx \
--mysql-db=test \
--oltp-tables-count=1 \
--oltp-table-size=1000000 \
--num-threads=16 \
--max-requests=1000000 \
--report-interval=1 \
--max-time=60 \
run
說明:--num-threads=16 #模擬數據庫線程并發數量,規格越高該值越大
--max-time=60#最大測試時間(與--max-requests只要有一個超過,則退出)。
利用sysbench測試了并發線程個數不同的情況下,分別執行最大請求次數為100w的 select操作,通過修改--num-threads可以獲得不同并發線程數。
測試有索引和無索引這兩種情況下的 QPS(QPS越大,系統性能越好),每條sql平均執行時間(每條sql執行時間越小,系統性能越好), cpu負載,每組數據重復測試三次后取平均值,具體數據對比如下表所示:
buffer_pool:24G |
線程數 |
請求數 |
數據量 |
cpu負載 |
qps(r/s) |
min(ms) |
avg(ms) |
max(ms) |
95% |
有索引 |
16 |
701116 |
100萬行 |
3.21 |
11680 |
0.09 |
1.37 |
1274.83 |
0.73 |
沒有索引 |
16 |
720 |
100萬行 |
11 |
11 |
278 |
1345 |
5997 |
2373 |
有索引 |
32 |
707720 |
100萬行 |
4.46 |
11737 |
0.08 |
2.71 |
1995 |
1.38 |
沒有索引 |
32 |
688 |
100萬行 |
21 |
11 |
686 |
2829 |
12666 |
5700 |
有索引 |
64 |
746723 |
100萬行 |
18 |
12416 |
0.09 |
5.15 |
2253 |
9.52 |
沒有索引 |
64 |
726 |
100萬行 |
38 |
11 |
1587 |
5430 |
19856 |
11000 |
有索引 |
128 |
910519 |
100萬行 |
36 |
15145 |
0.09 |
8.43 |
3147 |
20.17 |
沒有索引 |
128 |
804 |
100萬行 |
43 |
12 |
1525 |
10379 |
68659 |
58056 |
有索引 |
256 |
896962 |
100萬行 |
80 |
14932 |
0.09 |
17.14 |
4945 |
38.97 |
沒有索引 |
256 |
917 |
100萬行 |
52 |
11 |
1673 |
20022 |
81671 |
77778 |
有索引 |
512 |
850414 |
100萬行 |
194 |
14161 |
0.1 |
36.15 |
5750 |
321 |
沒有索引 |
512 |
1133 |
100萬行 |
59 |
11 |
1252 |
38431 |
107995 |
103269 |
有索引 |
1024 |
818863 |
100萬行 |
252 |
13629 |
0.09 |
75 |
17780 |
401 |
沒有索引 |
1024 |
1667 |
100萬行 |
63 |
11 |
1535 |
66188 |
153542 |
147680 |
有索引 |
2048 |
799571 |
100萬行 |
652 |
13282 |
0.1 |
153 |
9599 |
563 |
沒有索引 |
2048 |
2595 |
100萬行 |
72 |
10 |
1325 |
132090 |
265936 |
255631 |
上表對應的QPS折線圖如下所示:
VpSGBCzCmByUza9dIu/oKRjQAJqb3JBFTHamEzt0k7YdKFcz+jEhUbRha8KclY3Exn7J55l1MR5DQGq6a3itco/qnznuhapV9cBv8pD65qnnz7EfKO56EXGXRuU8pTQqckk4Mq1KEIPWhDFzpRiS70oRS9aEQZqtGKchSiHsWoRUHa0ZKS9KQZRelIU8rSlbr0oy2F6UtFKtOa0vSmG8VpSHPK05361KQx1SlQZ9rTV8Jmln85VeC6BaZrkdNu/BSS3DyJyqoq76oZoipWtZpVq3Z1q17lqljDSlawmvWraB3rWdWa1rK2da1uZatc40pXuNr1rXid6131mte69tWut3SgX7bnLU017EXmXKrnPlRJfDr2Puz8ZqxqcqyJiZBFftTd5ZY5ysd61kDepMsduXVOr61SSTsaHiU/y9oJneY2EWstAbWlyCP/DTImNLljY2XbmtCiJra8FeipXCZNRiauLFDcbXBVE9nfKjeXOjGLNGxrBVYt9llzrFnFtKUXfTpOu0/tl2qXKx/u0ua5tWzFIPjA3j7wYRDwFQR8TzGIU6zqFOrFFk1c4QpdsWqKdtNvXr6GKjqVyon2ghOW4knebwaOVuhlJX+xwAcp8CEKFb5whjFs4SiwoAV9wHAUsJCvQWChDyRuwXoHIQAKr+gU8r0CHwRwhVO4ohU33olbrMU/xGC2SfrUpjYbDEfBHjXCkDwFH7DA5D7U98nwjTJ72RsADC95ySEWgIWZXGUms8AEUpCCAKIgBSYvWQoBYLKZ1cze+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WAziUitGvKpvArKczMaFvBtVzEfqqEYETMqjBEuTuMqwJMuWMMmyREsd0si0ZMvTcLq2hMuxuse4pMsVe8u6xMsCw8m85MuS+Mq+bMuxBMzBRAtwlJPDhEOJSEzDXEzEVMzHZEzIdMzIpMzJtMzGxEzJzMzK3MzL1MzP5EzQ9MzQJM3RNM3ORE3RTM3SXM3TVM3XZE3YdM3YpM3ZtM3WxE3ZzE1wBKdd9M0+3gTO3xTO4CTO4TTO4kTO41TO5GTO5XTO5oTO55TO6KTO6bTO6sTO69TO7OTO7fTO7gTP7xTP8CTP8VTOgAAAOw==">
從QPS折線圖可以看出,當sysbench的并發測試線程數小于128時,有索引的QPS在1萬2左右。這主要是因為當sysbench并發線程少時,數據庫性能沒有得到充分的發揮。
當sysbench的并發測試線程到128時,此時MySQL的性能就得到了充分的發揮,有索引的QPS達到了1萬5左右。如果繼續增加并發測試線程數,有索引的QPS稍有下降,但是還在1萬3左右,還是不錯的。
這時,我們再觀察無索引的情況,無論并發測試線程數是多少,無索引的QPS都是11,也就是,無索引時數據庫每秒只能處理11個select查詢,這對高并發的業務簡直不可接受。這說明了索引對數據庫的性能影響是多么巨大。
上表對應的每條SQL執行時間折線圖如下所示:
從每條SQL執行時間的折線圖來看,無索引的sql執行時間隨著并發測試線程數的增加而增加。也就是說,本來單條sql執行時間是1s,但是線程數越多,其執行時間越長,如上圖,當線程數128時,其執行時間已經由1s升到10.379s了。
這時,我們再觀察有索引的每條sql執行時間,不論線程數是多少,其執行時間都不會超過1s,可見有索引和無索引的性能差距太大了。
上表對應的cpu負載折線圖如下所示:
從cpu折線圖來看,在無索引情況下,當線程數128時,cpu負載為43,這和我們生產系統發生故障情況是吻合的,即當我們數據庫cpu負載在40~50時,確實有100左右的并發線程在數據庫里面執行。
再來看有索引情況下cpu的負載情況,可以看到,當并發線程數128以上時,有索引的cpu負載驟然升高,甚至高于無索引的。關于這個現象,出乎我的預料,甚至很不理解。
后來,我仔細分析了linux 里面的cpu負載的含義,CPU負載顯示的是一段時間內正在使用和等待使用CPU的平均任務數。不過,我也不好解釋上述現象,只能列在這,供人參考。
小知識:
CPU負載怎么理解?是不是CPU利用率?
這里要區別CPU負載和CPU利用率,它們是不同的兩個概念,但它們的信息可以在同一個top命令中進行顯示。CPU利用率顯示的是程序在運行期間實時占用的CPU百分比,而CPU負載顯示的是一段時間內正在使用和等待使用CPU的平均任務數。CPU利用率高,并不意味著負載就一定大。網上有篇文章舉了一個有趣比喻,拿打電話來說明兩者的區別,我按自己的理解闡述一下。
某公用電話亭,有一個人在打電話,四個人在等待,每人限定使用電話一分鐘,若有人一分鐘之內沒有打完電話,只能掛掉電話去排隊,等待下一輪。電話在這里就相當于CPU,而正在或等待打電話的人就相當于任務數。
在電話亭使用過程中,肯定會有人打完電話走掉,有人沒有打完電話而選擇重新排隊,更會有新增的人在這兒排隊,這個人數的變化就相當于任務數的增減。為了統計平均負載情況,我們5秒鐘統計一次人數,并在第1、5、15分鐘的時候對統計情況取平均值,從而形成第1、5、15分鐘的平均負載。
有的人拿起電話就打,一直打完1分鐘,而有的人可能前三十秒在找電話號碼,或者在猶豫要不要打,后三十秒才真正在打電話。如果把電話看作CPU,人數看作任務,我們就說前一個人(任務)的CPU利用率高,后一個人(任務)的CPU利用率低。
當然, CPU并不會在前三十秒工作,后三十秒歇著,只是說,有的程序涉及到大量的計算,所以CPU利用率就高,而有的程序牽涉到計算的部分很少,CPU利用率自然就低。但無論CPU的利用率是高是低,跟后面有多少任務在排隊沒有必然關系。
下面我們把cpu由8加到12,其他配置都不變,再進行壓力測試,看有什么變化。
buffer_pool:24G |
線程數 |
請求數 |
數據量 |
cpu負載 |
qps(r/s) |
min(ms) |
avg(ms) |
max(ms) |
95% |
有索引 |
16 |
716917 |
100萬行 |
3.4 |
11948 |
0.09 |
1.34 |
944 |
1.02 |
沒有索引 |
16 |
873 |
100萬行 |
10.34 |
14 |
282 |
1104 |
3224 |
2474 |
有索引 |
32 |
708405 |
100萬行 |
7.48 |
11787 |
0.09 |
2.71 |
1159 |
1.71 |
沒有索引 |
32 |
888 |
100萬行 |
20 |
14 |
292 |
2193 |
7901 |
4749 |
有索引 |
64 |
719369 |
100萬行 |
18.84 |
11920 |
0.08 |
5.37 |
1156 |
15 |
沒有索引 |
64 |
898 |
100萬行 |
40 |
14 |
638 |
4416 |
15063 |
9432 |
有索引 |
128 |
696889 |
100萬行 |
10 |
11614 |
0.09 |
11 |
1157 |
29.32 |
沒有索引 |
128 |
943 |
100萬行 |
42 |
14 |
817 |
8686 |
67268 |
49821 |
有索引 |
256 |
681509 |
100萬行 |
59 |
11588 |
0.1 |
22.53 |
2495 |
55 |
沒有索引 |
256 |
1051 |
100萬行 |
47 |
13 |
730 |
16978 |
78149 |
75079 |
有索引 |
512 |
704611 |
100萬行 |
78 |
11730 |
0.1 |
43.63 |
2800 |
413 |
沒有索引 |
512 |
1267 |
100萬行 |
54 |
13 |
822 |
31718 |
96230 |
92691 |
有索引 |
1024 |
593684 |
100萬行 |
204 |
9868 |
0.1 |
103 |
6522 |
545 |
沒有索引 |
1024 |
1764 |
100萬行 |
59 |
12 |
662 |
58212 |
139380 |
133509 |
有索引 |
2048 |
571730 |
100萬行 |
196 |
8898 |
0.09 |
225 |
8748 |
948 |
沒有索引 |
2048 |
2769 |
100萬行 |
116 |
12 |
606 |
103518 |
214829 |
205576 |
上表對應的QPS折線圖如下所示:
從上圖可以看到,當線程數為512時,有索引的qps開始驟降;但無索引的qps不論線程數是多少,都是14。
上表對應的每條SQL執行時間折線圖如下所示:
從上圖可以看到,隨著線程數的增加,無索引的每條sql執行時間在增加;而有索引的每條sql平均執行時間不到1s。
上表對應的cpu負載折線圖如下所示:
從上圖可以看到,隨著線程數的增加,cpu負載也在增加,但是當線程數為256時,有索引的cpu負載要比無索引的高,這個暫時沒法解釋。
下面我們把innodb buffer pool由24G升至44G,其他配置都不變,再進行壓力測試,看有什么變化。
buffer_pool:44G |
線程數 |
請求數 |
數據量 |
cpu負載 |
qps(r/s) |
min(ms) |
avg(ms) |
max(ms) |
95% |
有索引 |
16 |
709587 |
100萬行 |
3.56 |
11826 |
0.09 |
1.35 |
544 |
1.06 |
沒有索引 |
16 |
894 |
100萬行 |
11 |
14 |
279 |
1087 |
3211 |
2471 |
有索引 |
32 |
693606 |
100萬行 |
3.14 |
11503 |
0.08 |
2.77 |
1121 |
1.79 |
沒有索引 |
32 |
907 |
100萬行 |
20 |
14 |
549 |
2146 |
9473 |
4504 |
有索引 |
64 |
681148 |
100萬行 |
10.21 |
11352 |
0.08 |
5.64 |
1880 |
16 |
沒有索引 |
64 |
813 |
100萬行 |
42 |
14 |
722 |
4828 |
15398 |
9626 |
有索引 |
128 |
654430 |
100萬行 |
24 |
10906 |
0.09 |
11 |
1641 |
39 |
沒有索引 |
128 |
934 |
100萬行 |
40 |
14 |
774 |
12272 |
114780 |
61804 |
有索引 |
256 |
652889 |
100萬行 |
67 |
10828 |
0.09 |
23 |
2561 |
90 |
沒有索引 |
256 |
1091 |
100萬行 |
47 |
14 |
770 |
16203 |
76963 |
72930 |
有索引 |
512 |
651804 |
100萬行 |
143 |
10800 |
0.09 |
47 |
2816 |
448 |
沒有索引 |
512 |
1325 |
100萬行 |
88 |
14 |
506 |
30334 |
95839 |
90471 |
有索引 |
1024 |
466049 |
100萬行 |
220 |
7109 |
0.1 |
140 |
18282 |
573 |
沒有索引 |
1024 |
1818 |
100萬行 |
68 |
14 |
730 |
54924 |
132208 |
126847 |
有索引 |
2048 |
578978 |
100萬行 |
247 |
9574 |
0.09 |
212 |
5251 |
771 |
沒有索引 |
2048 |
2807 |
100萬行 |
105 |
14 |
616 |
100284 |
209988 |
200952 |
上表對應的QPS折線圖如下所示:
從上圖可以看到,當線程數為512時,有索引的qps開始驟降;但無索引的qps不論線程數是多少,都是14。
上表對應的每條SQL執行時間折線圖如下所示:
從上圖可以看到,隨著線程數的增加,無索引的每條sql平均執行時間在增加;而有索引的每條sql平均執行時間不到1s。
上表對應的cpu負載折線圖如下所示:
從上圖可以看到,隨著線程數的增加,cpu負載也在增加,但是當線程數為256時,有索引的cpu負載要比無索引的高,這種現象暫時沒法解釋。
io測試腳本:
[root@Mysql03 test]# cat iotest.sh
#!/bin/sh
set -u
set -x
set -e
for size in 2G ;do
for mode in seqrd seqrw rndrd rndwr rndrw;do
for blksize in 16384;do
sysbench --test=fileio --file-num=64 --file-total-size=$size prepare
for threads in 1 16 32 64 128 512 1024 2048;do
echo "====== testing $blksize in $threads threads"
echo PARAMS $size $mode $threads $blksize > sysbench-size-$size-mode-$mode-threads-$threads-blksz-$blksize
for i in 1 ;do
sysbench --test=fileio --file-total-size=$size --file-test-mode=$mode --max-time=180 --max-requests=100000000\
--num-threads=$threads --init-rng=on --file-num=64 --file-extra-flags=direct --file-fsync-freq=0\
--file-block-size=$blksize run | tee -a sysbench-size-$size-mode-$mode-threads-$threads-blksz-$blksize 2>&1
done
done
sysbench --test=fileio --file-total-size=$size cleanup
done
done
done
得到如下數據:
線程數 |
模式 |
數據塊大小 |
吞吐量(Mb/s) |
IOPS |
1 |
順序讀 |
16k |
59.639 |
3816.87 |
16 |
順序讀 |
16k |
139.81 |
8948 |
32 |
順序讀 |
16k |
158.85 |
10166.69 |
64 |
順序讀 |
16k |
147 |
9451 |
128 |
順序讀 |
16k |
149 |
9542 |
512 |
順序讀 |
16k |
153 |
9853 |
1024 |
順序讀 |
16k |
151 |
9712.16 |
2048 |
順序讀 |
16k |
151 |
9666 |
1 |
隨機讀 |
16k |
5 |
337 |
16 |
隨機讀 |
16k |
41 |
2668 |
32 |
隨機讀 |
16k |
61 |
3912.03 |
64 |
隨機讀 |
16k |
61 |
3939.21 |
128 |
隨機讀 |
16k |
61 |
3939 |
因為測試磁盤io會影響生產系統,所以只測試了上面幾組數據,沒有對順序讀、順序寫、順序讀寫、隨機讀、隨機寫、隨機讀寫等全面測試,即使測試可能意義也不大。
因為磁盤是機械硬盤,按理應該是220,上面出現1萬的情況,因為硬盤有閃存。
有索引的qps在1萬2左右,沒索引的qps只有14,兩者相差1000倍;
有索引的sql執行時間不論線程數是多少都不到一秒,而無索引的sql隨著線程數的增加,其執行時間也會增加,最高到132s,相差倍數可是千倍萬倍;
數據庫的線程數達到128時,會使數據庫性能明顯下降;當增加cpu和內存時,也不能很好的解決這個問題,這可能是my.cnf和linux 內核參數配置的不合適導致,后期仔細研究這些參數,使數據庫性能上一個新的臺階;
磁盤IO能力固定,只能從數據庫和操作系統參數著手。
完
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。