#云計(jì)算-產(chǎn)品體驗(yàn)優(yōu)化私房菜課程(騰訊云篇)#
最近看到一個(gè)網(wǎng)友在問(請(qǐng)問一下切端,每天3~4W次的讀寫挤庇,用什么樣子的配置比較好,麻煩推薦一個(gè)配置旁仿,謝謝 MySQL5.7的.)看著應(yīng)該是一個(gè)比較簡(jiǎn)單的場(chǎng)景藕夫,不過筆者通過這問題在想云MySQL不同的配置他的性能究竟如何?如果推薦了這個(gè)用戶配置后枯冈,他的業(yè)務(wù)又漲了該如何再選擇其他的配置毅贮? 所以這里我們可以來測(cè)試一下云MySQL的性能,從測(cè)試數(shù)據(jù)上看是否可以更好的解答此用戶的問題尘奏。
本文內(nèi)容提供了B站視頻:https://www.bilibili.com/video/BV1vt4y1U71S
我們使用《高性能MySQL》第二章推薦的工具sysbench(http://sysbench.sourceforge.net)這是一款開源的多線程系統(tǒng)基準(zhǔn)測(cè)試工具滩褥,可以用于測(cè)試CPU、內(nèi)存炫加、磁盤I/O線程和數(shù)據(jù)庫(kù)的性能瑰煎,目前數(shù)據(jù)庫(kù)支持MySQL铺然、Oracle和PostgreSQL等常見的數(shù)據(jù)庫(kù)。
本文主要介紹以下兩個(gè)話題:
1.騰訊云MySQL性能測(cè)試結(jié)果
2.sysbench安裝與使用介紹
騰訊云MySQL性能測(cè)試結(jié)果
以下筆者測(cè)試了騰訊云MySQL5.7版本的不同配置服務(wù)器對(duì)應(yīng)的指標(biāo)酒甸。為了簡(jiǎn)化介紹用戶場(chǎng)景這里筆者將不同的規(guī)格分為三個(gè)等級(jí)分別為初級(jí)探熔、中級(jí)和高級(jí)(筆者個(gè)人的定義),可以看到初級(jí)的配置基本可以滿足網(wǎng)友的需求烘挫,如果用戶后續(xù)業(yè)務(wù)增長(zhǎng)也可以按照以下做參考诀艰。
數(shù)據(jù)庫(kù)最有價(jià)值的指標(biāo)TPS,什么是TPS如下饮六。
TPS(Transactions Per Second)每秒事務(wù)數(shù)其垄。一個(gè)事務(wù)是指一個(gè)客戶機(jī)向服務(wù)器發(fā)送請(qǐng)求然后服務(wù)器做出反應(yīng)的過程÷遍希客戶機(jī)在發(fā)送請(qǐng)求時(shí)開始計(jì)時(shí)绿满,收到服務(wù)器響應(yīng)后結(jié)束計(jì)時(shí),以此來計(jì)算使用的時(shí)間和完成的事務(wù)個(gè)數(shù)窟扑。
QPS(Queries Per Second)每秒查詢喇颁。是一臺(tái)服務(wù)器每秒能夠響應(yīng)的查詢次數(shù),是對(duì)一個(gè)特定的查詢服務(wù)器(比如是讀寫分離的架構(gòu)嚎货,就是讀的服務(wù)器)在規(guī)定時(shí)間內(nèi)所處理流量多少的衡量標(biāo)準(zhǔn)橘霎。
以上測(cè)試過程中的參數(shù)見在線表格,表格在不斷更新完善中殖属。(數(shù)據(jù)庫(kù)性能測(cè)試(騰訊云 ))https://docs.qq.com/sheet/DTmNWZWdzdFJJWERR?tab=nw95wo&c=O10A0C0
sysbench安裝與使用介紹
我們繼續(xù)來看一下sysbench如何安裝姐叁,sysbench不同的版本一些細(xì)節(jié)參數(shù)是有一些區(qū)別的,這里我們使用的是sysbench 1.1.0-bd4b418版本以下為安裝步驟:
#? yum -y install? git
# git clone https://github.com/akopytov/sysbench.git
# yum -y install make automake libtool pkgconfig libaio-devel
# yum -y install mariadb-devel
# ./autogen.sh
# ./configure
# make -j
# make install
源碼目錄中提供了lua腳本洗显,各腳本功能如下外潜,關(guān)于lua腳本內(nèi)容介紹見(https://blog.csdn.net/L835311324/article/details/98618821)
測(cè)試方法
sysbench 測(cè)試分為三步,分別(prepare -> run -> cleanup):
1.準(zhǔn)備數(shù)據(jù) (prepare)
sysbench ./oltp_read_write.lua --mysql-host= --mysql-port=3306? --mysql-user=root --mysql-password='密碼'? --mysql-db=test? --tables=4 --table-size=100000? --threads=128? prepare
2.測(cè)試數(shù)據(jù)(run)
sysbench ./oltp_read_write.lua --mysql-host=IP --mysql-port=? --mysql-user=root --mysql-password='密碼'? --mysql-db=test? --tables=4 --table-size=100000? --threads=128 --report-interval=3? --time=60 run
3.清理測(cè)試數(shù)據(jù)(cleanup)
sysbench? ./oltp_read_write.lua --mysql-host=IP--mysql-port=3306? --mysql-user=root --mysql-password='密碼'? --mysql-db=test --tables=4 --table-size=100000? --threads=128? cleanup
參數(shù)介紹:
--mysql-host=? MySQL服務(wù)器IP
--mysql-port=? 端口
--mysql-user= 賬戶名
--mysql-password= 密碼
--mysql-db= 數(shù)據(jù)庫(kù)名
--tables=表數(shù)
--table-size= 表行數(shù)
--threads= 進(jìn)程數(shù)
--time = 限制測(cè)試時(shí)長(zhǎng)(秒)
以下是測(cè)試數(shù)據(jù)后的結(jié)果
Initializing worker threads...
Threads started!
[ 3s ] thds: 128 tps: 369.44 qps: 7947.23 (r/w/o: 5629.62/1538.08/779.53) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 128 tps: 414.71 qps: 8288.14 (r/w/o: 5823.90/1633.49/830.75) lat (ms,95%): 590.56 err/s: 0.33 reconn/s: 0.00
[ 9s ] thds: 128 tps: 451.33 qps: 9002.31 (r/w/o: 6300.32/1798.33/903.66) lat (ms,95%): 404.61 err/s: 0.67 reconn/s: 0.00
SQL statistics:
? ? queries performed:
? ? ? ? read:? ? ? ? ? ? ? ? ? ? ? ? ? ? 59108? ? ? ? # 讀
? ? ? ? write:? ? ? ? ? ? ? ? ? ? ? ? ? 16879? ? ? ? # 寫
? ? ? ? other:? ? ? ? ? ? ? ? ? ? ? ? ? 8441? ? ? ? ? #其他操作總數(shù)(SELECT挠唆、INSERT处窥、UPDATE、DELETE之外的操作玄组,例如COMMIT等)
? ? ? ? total:? ? ? ? ? ? ? ? ? ? ? ? ? 84428 .? ? ? ? #全部總數(shù)
? ? transactions:? ? ? ? ? ? ? ? ? ? ? ? 4219? (414.71 per sec.) .? ? ? ? #? tps 總事務(wù)數(shù)(每秒事務(wù)數(shù))
? ? queries:? ? ? ? ? ? ? ? ? ? ? ? ? ? 84428? (8299.00 per sec.) .? ? ? # QPS(每秒讀寫次數(shù))
? ? ignored errors:? ? ? ? ? ? ? ? ? ? ? 3? ? ? (0.29 per sec.)
? ? reconnects:? ? ? ? ? ? ? ? ? ? ? ? ? 0? ? ? (0.00 per sec.)
Throughput:
? ? events/s (eps):? ? ? ? ? ? ? ? ? ? ? 414.7143
? ? time elapsed:? ? ? ? ? ? ? ? ? ? ? ? 10.1733s
? ? total number of events:? ? ? ? ? ? ? 4219
Latency (ms):
? ? ? ? min:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 36.82
? ? ? ? avg:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 305.95
? ? ? ? max:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 809.03
? ? ? ? 95th percentile:? ? ? ? ? ? ? ? ? ? ? 493.24 .? ? ? # 超過95%平均耗時(shí)
? ? ? ? sum:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1290817.07
Threads fairness:
? ? events (avg/stddev):? ? ? ? ? 32.9609/2.49
? ? execution time (avg/stddev):? 10.0845/0.03
End...
更多參考
1. sysbench參數(shù)和一些測(cè)試案例 https://blog.csdn.net/weixin_44218035/article/details/89424166
2. 什么是TPS滔驾,什么是QPS 他們區(qū)別是什么 。https://www.cnblogs.com/uncleyong/p/11059556.html
3. 《高性能MySQL》第二章