mysql 壓力測試

來源:互聯網
上載者:User

標籤:mysql 壓力測試

mysql 壓力測試

一、測試載入器:sysbench

sysbench支援的測試模式:

1、CPU運算效能2、磁碟IO效能3、發送器效能4、記憶體配置及傳輸速度5、POSIX線程效能6、資料庫效能(OLTP基準測試)目前sysbench主要支援 mysql,drizzle,pgsql,oracle 等幾種資料庫。

二、編譯安裝sysbench

下載連結:http://imysql.com/wp-content/uploads/2014/09/sysbench-0.4.12-1.1.tgz

[[email protected] package]# tar  zxvf sysbench-0.4.12-1.1.tgz

[[email protected] sysbench-0.4.12-1.1]# ./autogen.sh

[[email protected] sysbench-0.4.12-1.1]# ./configure

[[email protected] sysbench-0.4.12-1.1]# make

[[email protected] sysbench-0.4.12-1.1]# make install

三、OLTP測試環境

初始化測試庫環境,對已經準備好的資料庫進行操作

首先需要在準備好的資料庫中建立一個名為,sbtest的庫,不可更改必須叫這個名字,能看得懂lua指令碼可以隨意更改,這個是個大前提

1、需要切到這個目錄下進行操作,如果不切目錄也可以使用絕對路徑,oltp.lua指令碼路徑

[[email protected] db]# cd /data/package/sysbench-0.4.12-1.1/sysbench/tests/db

2、在sbtest庫中,建立10個測試表,每個測試表中100000條記錄(行),填充隨機產生的資料

[[email protected] db]# sysbench  --mysql-host=192.168.4.100    --mysql-user=admin  --mysql-password=FJRUDKEISLWO    --test=oltp.lua   --oltp_tables_count=10  --oltp-table-size=100000  --rand-init=on  prepare

參數解釋:

--test=tests/db/oltp.lua 表示調用 ./tsysbench-0.4.12-1.1/sysbench/tests/db/oltp.lua 指令碼進行 oltp模式測試    --oltp_tables_count=10 表示會產生 10 個測試表    --oltp-table-size=100000 表示每個測試表填充資料量為 100000    --rand-init=on 表示每個測試表都是用隨機資料來填充的

他人經驗:

真實測試情境中,資料表建議不低於10個,單表資料量不低於500萬行,當然了,要視伺服器硬體設定而定。如果是配備了SSD或者PCIE SSD這種高IOPS裝置的話,則建議單表資料量最少不低於1億行。

四、進行OLTP測試

[[email protected] db]# sysbench  --mysql-host=10.10.95.235    --mysql-user=admin  --mysql-password=FJRUDKEISLWO    --test=oltp.lua   --oltp_tables_count=10  --oltp-table-size=10000000   --num-threads=10  --oltp-read-only=off --report-interval=10  --rand-type=uniform  --max-time=120 --max-requests=0  --percentile=99 run >/data/log/sysbench.log

參數解釋:

  --num-threads=8        # 表示發起 8個並發串連      --oltp-read-only=off  #表示不要進行唯讀測試,也就是會採用讀寫混合模式測試      --report-interval=10   #表示每10秒輸出一次測試進度報告      --rand-type=uniform  #表示隨機類型為固定模式,其他幾個可選隨機模式:uniform(固  定),gaussian(高斯),special(特定的),pareto(帕累托)     --max-time=120           #表示最大執行時間長度為 120秒     --max-requests=0       #表示總請求數為 0,因為上面已經定義了總執行時間長度,所以總請求數可以設定為 0;也可以只設定總請求數,不設定最大執行時間長度     --percentile=99          #表示設定採樣比例,預設是 95%,即丟棄1%的長請求,在剩餘的99%裡取最大值

他人經驗:

   真實測試情境中,建議持續壓測時間長度不小於30分鐘,否則測試資料可能不具參考意義。

五、測試結果解讀

   

sysbench 0.5:  multi-threaded system evaluation benchmarkRunning the test with following options:Number of threads: 8Report intermediate results every 10 second(s)Random number generator seed is 0 and will be ignoredThreads started!-- 每10秒鐘報告一次測試結果,tps、每秒讀、每秒寫、99%以上的響應時間長度統計[  10s] threads: 8, tps: 1111.51, reads/s: 15568.42, writes/s: 4446.13, response time: 9.95ms (99%)[  20s] threads: 8, tps: 1121.90, reads/s: 15709.62, writes/s: 4487.80, response time: 9.78ms (99%)[  30s] threads: 8, tps: 1120.00, reads/s: 15679.10, writes/s: 4480.20, response time: 9.84ms (99%)[  40s] threads: 8, tps: 1114.20, reads/s: 15599.39, writes/s: 4456.30, response time: 9.90ms (99%)[  50s] threads: 8, tps: 1114.00, reads/s: 15593.60, writes/s: 4456.70, response time: 9.84ms (99%)[  60s] threads: 8, tps: 1119.30, reads/s: 15671.60, writes/s: 4476.50, response time: 9.99ms (99%)OLTP test statistics:    queries performed:        read:                            938224    -- 讀總數        write:                            268064    -- 寫總數        other:                           134032    -- 其他動作總數(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)        total:                           1340320    -- 全部總數    transactions:                        67016  (1116.83 per sec.)     -- 總事務數(每秒事務數)    deadlocks:                           0      (0.00 per sec.)                -- 發生死結總數    read/write requests:                 1206288 (20103.01 per sec.)    -- 讀寫總數(每秒讀寫次數)    other operations:                      134032 (2233.67 per sec.)    -- 其他動作總數(每秒其他動作次數)General statistics:    -- 一些統計結果    total time:                                   60.0053s    -- 總耗時    total number of events:              67016    -- 共發生多少事務數    total time taken by event execution: 479.8171s    -- 所有事務耗時相加(不考慮並行因素)    response time:    -- 響應時間長度統計         min:                                  4.27ms    -- 最小耗時         avg:                                  7.16ms    -- 平均耗時         max:                                 13.80ms    -- 最長耗時         approx.  99 percentile:               9.88ms    -- 超過99%平均耗時Threads fairness:    events (avg/stddev):           8377.0000/44.33    execution time (avg/stddev):   59.9771/0.00

最重要的參數指標:

總的事物數,每秒事務數,時間統計資訊(最大、最小、平均、99%以上語句回應時間)

上述測試方式是在雲RDS(UDB),資料庫執行個體驗證的,我測試的時候是採用了迅達雲和ucloud雲進行的對比性測試,更容易拿出資料。

在測試環境,也就是自建的資料庫,會發生各種情況,只能依靠個人排查能力了。


本文出自 “10946218” 部落格,謝絕轉載!

mysql 壓力測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.