MySQL基準測試載入器-mysqlslap

來源:互聯網
上載者:User

  mysqlslap是MySQL5.1之後內建的benchmark基準測試載入器,該工具可以類比多個用戶端同時並發的向伺服器發出查詢更新,給出了效能測試資料而且提供了多種引擎的效能比較。

      使用方式:

      --concurrency  並發數量 可逗號隔開),例如:concurrency=10,50,100 並發連接線程數是10,50,100

      --engines 要測試的儲存引擎,逗號隔開

      --iterations   運行多少次後,得到結果;

      --auto-generate-sql  自動產生SQL指令碼來測試;

      --auto-generate-sql-load-type  測試類型是read還是write,還是mixed;可以使用--only-print 查看到底是哪些SQL語句)

      --number-of-queries 執行查詢的次數,

      --debug-info  輸出CPU、記憶體等系統相關資訊

      --number-int-cols  測試表int欄位類型的數量;

      --auto-generate-sql-add-autoincrement  對產生的測試表 自動產生含有auto_increment屬性的列;

      --number-char-cols  測試表的char類型欄位的數量;

      --create-schema = db  建立測試的資料庫;

      --query 使用自訂指令碼進行測試, 可以是一個預存程序或者SQL語句來執行;

      --only-print  只列印測試過程中涉及到的SQL語句,不真正的執行;

  舉例:

  測試200個並發寫入效能,測試20次,自動產生SQL指令碼,測試表包含35個int欄位,20個char欄位,測試引擎分別為innodb,myisam;每次執行3000個query;

 

./bin/mysqlslap --socket=/usr/local/mysql/mysql.sock --port=3306 --concurrency=200  --iterations=20 --auto-generate-sql --auto-generate-sql-load-type=write  --auto-generate-sql-add-autoincrement --number-int-cols=35 --number-char-cols=20  --engine=innodb,myisam   --create-schema=sysbench  --number-of-queries=3000 --debug-info


        結果為:

       

Benchmark        Running for engine innodb        Average number of seconds to run all queries: 6.385 seconds        Minimum number of seconds to run all queries: 3.021 seconds        Maximum number of seconds to run all queries: 12.969 seconds        Number of clients running queries: 200        Average number of queries per client: 15Benchmark        Running for engine myisam        Average number of seconds to run all queries: 0.621 seconds        Minimum number of seconds to run all queries: 0.442 seconds        Maximum number of seconds to run all queries: 1.134 seconds        Number of clients running queries: 200        Average number of queries per client: 15User time 0.66, System time 1.97Maximum resident set size 10060, Integral resident set size 0Non-physical pagefaults 50486, Physical pagefaults 5, Swaps 0Blocks in 584 out 96, Messages in 0 out 0, Signals 0Voluntary context switches 298373, Involuntary context switches 1469


自訂SQL測試指令碼:

 

mysqlslap --create=/yourpath/test.sql --query=/yourpath/test1.sql --concurrency=50,100,200 --iterations=20 --engine=myisam,innodb


本文出自 “技術成就夢想” 部落格,請務必保留此出處http://weipengfei.blog.51cto.com/1511707/1249295

相關文章

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.