系統技術非業餘研究 » Fio模擬Mysql伺服器IO壓力指令碼
阿新 • • 發佈:2018-12-31
fio是個非常好用的io壓力模擬工具,功能非常齊全, 有興趣的同學參看 這裡。
這裡我用fio模擬我們線上mysql伺服器的壓力來為廠家送來的pci-ssd卡做壓力測試,底下是指令碼(已經測試正確),也許有的同學有用。
$ cat mysql-test # QPS: 40000(10 cores) # Dataset: 200G # R/W: 8/2 # ThreadPool Num: 64 # IO ThreadNum: 32 [global] runtime=86400 time_based group_reporting directory=/your_dir ioscheduler=deadline refill_buffers [mysql-binlog] filename=test-mysql-bin.log bsrange=512-1024 ioengine=sync rw=write size=24G sync=1 rw=write overwrite=1 fsync=100 rate_iops=64 invalidate=1 numjobs=64 [innodb-data] filename=test-innodb.dat bs=16K ioengine=psync rw=randrw size=200G direct=1 rwmixread=80 numjobs=32 thinktime=600 thinktime_spin=200 thinktime_blocks=2 [innodb-trxlog] filename=test-innodb.log bsrange=512-2048 ioengine=sync rw=write size=2G fsync=1 overwrite=1 rate_iops=64 invalidate=1 numjobs=64 $ sudo fio mysql-test mysql-binlog: (g=0): rw=write, bs=512-1K/512-1K, ioengine=sync, iodepth=1 ... mysql-binlog: (g=0): rw=write, bs=512-1K/512-1K, ioengine=sync, iodepth=1 innodb-data: (g=0): rw=randrw, bs=16K-16K/16K-16K, ioengine=psync, iodepth=1 ... innodb-data: (g=0): rw=randrw, bs=16K-16K/16K-16K, ioengine=psync, iodepth=1 innodb-trxlog: (g=0): rw=write, bs=512-2K/512-2K, ioengine=sync, iodepth=1 ... innodb-trxlog: (g=0): rw=write, bs=512-2K/512-2K, ioengine=sync, iodepth=1 fio 1.50.2 Starting 160 threads ...
要注意的事項是:
1. 對iops的限制是針對每個執行緒的,總的限制是 限制*執行緒數
2. 在thinktime_blocks個io開始前先等待thinktime(其中thinktime_spin用於消耗cpu, 剩餘時間用於sleep)
3. 每個io需要花費時間。這個時間隨著裝置的不同差別很大,最好的方法是測試。用一個執行緒測試,然後用strace檢視。
上面的數字要根據具體的裝置和mysql場景去調整。
玩得開心!
Post Footer automatically generated by wp-posturl plugin for wordpress.