詳解Mysql5.7自帶的壓力測試命令mysqlslap及使用語法
前言
mysqlslap是一個診斷程序,旨在模擬MySQL服務(wù)器的客戶端負載并報告每個階段的時間。它就像多個客戶端正在訪問服務(wù)器一樣工作。
1、使用的語法:
mysqlslap [options]
--auto-generate-sql, -a :自動生成測試表和數(shù)據(jù),表示用mysqlslap自己生成的SQL腳本來測試并發(fā)壓力。
--auto-generate-sql-load-type=type :測試語句的類型,取值包括:read,key,write,update和mixed(默認)。
--auto-generate-sql-add-auto-increment :對生成的表自動添加auto_increment列。
--create-schema :自定義的測試庫名稱。
--commint=N :設(shè)置N條DML后提交一次。
--compress, -C :如果服務(wù)器和客戶端支持都壓縮,則壓縮信息傳遞。
--concurrency=N, -c N :表示并發(fā)量,也就是模擬多少個客戶端同時執(zhí)行select??芍付ǘ鄠€值,例如:--concurrency=100,200,500。
--detach=N :執(zhí)行N條語句后斷開重連。
--debug-info, -T :打印內(nèi)存和CPU的相關(guān)信息。
--engine=engine_name, -e engine_name :要測試的引擎,可以有多個,用分隔符隔開。例如:--engines=myisam,innodb。
--iterations=N, -i N :測試執(zhí)行的迭代次數(shù),表示要在不同并發(fā)環(huán)境下,各自運行測試多少次。
--number-char-cols=N, -x N :自動生成的測試表中包含N個字符類型的列,默認為1。
--number-int-cols=N, -y N :自動生成的測試表中包含N個數(shù)字類型的列,默認為1。
--number-of-queries=N :總的測試查詢次數(shù)(并發(fā)客戶數(shù)×每客戶查詢次數(shù))。
--only-print :只打印測試語句而不實際執(zhí)行。
--query=name,-q :使用自定義腳本執(zhí)行測試,例如可以自定義一個存儲過程或者sql語句來執(zhí)行測試。
2、案例
測試100個并發(fā),自動生成SQL測試腳本,執(zhí)行1000次總查詢:
root# mysqlslap -uroot -p123456 -a --concurrency=100 --number-of-queries 1000 Benchmark Average number of seconds to run all queries: 0.725 seconds Minimum number of seconds to run all queries: 0.725 seconds Maximum number of seconds to run all queries: 0.725 seconds Number of clients running queries: 100 Average number of queries per client: 10
測試100個并發(fā)線程,測試次數(shù)5次,自動生成SQL測試腳本,讀、寫、更新混合測試,自增長字段,測試引擎為innodb,執(zhí)行5000次總查詢
root# mysqlslap -uroot -p123456--concurrency=100 --iterations=5 --auto-generate-sql --auto-generate-sql-load-type=mixed --auto-generate-sql-add-autoincrement --engine=innodb --number-of-queries=5000 Benchmark Running for engine innodb Average number of seconds to run all queries: 1.264 seconds Minimum number of seconds to run all queries: 1.161 seconds Maximum number of seconds to run all queries: 1.404 seconds Number of clients running queries: 100 Average number of queries per client: 50
總結(jié)
以上所述是小編給大家介紹的Mysql5.7自帶的壓力測試命令mysqlslap及使用語法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
mysql給id設(shè)置默認值為UUID的實現(xiàn)方法
由于mysql并不支持默認值為函數(shù)類型,給id設(shè)值有兩種方式,本文主要介紹了mysql給id設(shè)置默認值為UUID的實現(xiàn)方法,具有一定的參考價值,感興趣的可以了解一下2023-08-083種高效的Tags標簽系統(tǒng)數(shù)據(jù)庫設(shè)計方案分享
這篇文章主要介紹了3種高效的Tags標簽系統(tǒng)數(shù)據(jù)庫設(shè)計方案分享,現(xiàn)在主流的博客、CMS系統(tǒng)都有一個標簽系統(tǒng),本文就探討它的數(shù)據(jù)庫設(shè)計方式,需要的朋友可以參考下2014-07-07MySQL之information_schema數(shù)據(jù)庫詳細講解
這篇文章主要介紹了MySQL之information_schema數(shù)據(jù)庫詳細講解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-08-08php 不能連接數(shù)據(jù)庫 php error Can''t connect to local MySQL server
php 不能連接數(shù)據(jù)庫 php error Can't connect to local MySQL server through socket '/tmp/mysql.sock'2011-05-05