• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    壓力測試工具Myysqlslap測試Mysql服務器性能

    發布: 2008-7-23 15:53 | 作者: 網絡轉載 | 來源: 網絡轉載 | 查看: 383次 | 進入軟件測試論壇討論

    領測軟件測試網

    關于他的選項手冊上以及--help介紹的很詳細。
    我解釋一下一些常用的選項。


    這里要注意的幾個選項:


    --concurrency代表并發數量,多個可以用逗號隔開,當然你也可以用自己的分隔符隔開,這個時候要用到--delimiter開關。--engines代表要測試的引擎,可以有多個,用分隔符隔開。--iterations代表要運行這些測試多少次。--auto-generate-sql 代表用系統自己生成的SQL腳本來測試。--auto-generate-sql-load-type 代表要測試的是讀還是寫還是兩者混合的(read,write,update,mixed)--number-of-queries 代表總共要運行多少次查詢。每個客戶運行的查詢數量可以用查詢總數/并發數來計算。比如倒數第二個結果2=200/100。--debug-info 代表要額外輸出CPU以及內存的相關信息。--number-int-cols 代表示例表中的INTEGER類型的屬性有幾個。--number-char-cols 意思同上。--create-schema 代表自己定義的模式(在MySQL中也就是庫)。--query 代表自己的SQL腳本。--only-print 如果只想打印看看SQL語句是什么,可以用這個選項。
    現在來看一些我測試的例子。


    1、用自帶的SQL腳本來測試。
    MySQL版本為5.1.23
    [root@localhost ~]# mysqlslap --defaults-file=/usr/local/mysql-maria/my.cnf --concurrency=50,100,200 --iterations=1 --number-int-cols=4 --number-char-cols=35 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --number-of-queries=200 --debug-info -uroot -p1 -S/tmp/mysql_3310.sock
    Benchmark
            Running for engine myisam
            Average number of seconds to run all queries: 0.063 seconds
            Minimum number of seconds to run all queries: 0.063 seconds
            Maximum number of seconds to run all queries: 0.063 seconds
            Number of clients running queries: 50
            Average number of queries per client: 4
    Benchmark
            Running for engine myisam
            Average number of seconds to run all queries: 0.070 seconds
            Minimum number of seconds to run all queries: 0.070 seconds
            Maximum number of seconds to run all queries: 0.070 seconds
            Number of clients running queries: 100
            Average number of queries per client: 2
    Benchmark
            Running for engine myisam
            Average number of seconds to run all queries: 0.092 seconds
            Minimum number of seconds to run all queries: 0.092 seconds
            Maximum number of seconds to run all queries: 0.092 seconds
            Number of clients running queries: 200
            Average number of queries per client: 1
    Benchmark
            Running for engine innodb
            Average number of seconds to run all queries: 0.115 seconds
            Minimum number of seconds to run all queries: 0.115 seconds
            Maximum number of seconds to run all queries: 0.115 seconds
            Number of clients running queries: 50
            Average number of queries per client: 4
    Benchmark
            Running for engine innodb
            Average number of seconds to run all queries: 0.134 seconds
            Minimum number of seconds to run all queries: 0.134 seconds
            Maximum number of seconds to run all queries: 0.134 seconds
            Number of clients running queries: 100
            Average number of queries per client: 2
    Benchmark
            Running for engine innodb
            Average number of seconds to run all queries: 0.192 seconds
            Minimum number of seconds to run all queries: 0.192 seconds
            Maximum number of seconds to run all queries: 0.192 seconds
            Number of clients running queries: 200
            Average number of queries per client: 1
    User time 0.06, System time 0.15
    Maximum resident set size 0, Integral resident set size 0
    Non-physical pagefaults 5803, Physical pagefaults 0, Swaps 0
    Blocks in 0 out 0, Messages in 0 out 0, Signals 0
    Voluntary context switches 8173, Involuntary context switches 528
    我來解釋一下結果的含義。拿每個引擎最后一個Benchmark示例。對于INNODB引擎,200個客戶端同時運行這些SQL語句平均要花0.192秒。相應的MYISAM為0.092秒。


    2、用我們自己定義的SQL 腳本來測試。
    這些數據在另外一個MySQL實例上。版本為5.0.45先看一下這兩個表的相關數據。
    1)、總記錄數。
    mysql> select table_rows as rows from information_schema.tables where table_schema='t_girl' and table_name='article';
    +--------+
    | rows     |
    +--------+
    | 296693 |
    +--------+
    1 row in set (0.01 sec)
    mysql> select table_rows as rows from information_schema.tables where table_schema='t_girl' and table_name='category';
    +------+
    | rows |
    +------+
    |  113  |
    +------+
    1 row in set (0.00 sec)
    2)、總列數。
    mysql> select count(*) as column_total from information_schema.columns where table_schema = 't_girl' and table_name = 'article';
    +--------------+
    | column_total |
    +--------------+
    |           32           |
    +--------------+
    1 row in set (0.01 sec)
    mysql> select count(*) as column_total from information_schema.columns where table_schema = 't_girl' and table_name = 'category';
    +--------------+
    | column_total |
    +--------------+
    |            9            |
    +--------------+
    1 row in set (0.01 sec)


    3)、調用的存儲過程
    DELIMITER $$
    DROP PROCEDURE IF EXISTS `t_girl`.`sp_get_article`$$
    CREATE DEFINER=`root`@`%` PROCEDURE `sp_get_article`(IN f_category_id int,
    IN f_page_size int, IN f_page_no int
    )
    BEGIN
      set @stmt = 'select a.* from article as a inner join ';
      set @stmt = concat(@stmt,'(select a.aid from article as a ');
      if f_category_id != 0 then
        set @stmt = concat(@stmt,' inner join (select cid from category where cid = ',f_category_id,' or parent_id = ',f_category_id,') as b on a.category_id = b.cid');
      end if;
      if f_page_size >0 && f_page_no > 0 then
        set @stmt = concat(@stmt,' limit ',(f_page_no-1)*f_page_size,',',f_page_size);
      end if; 

      set @stmt = concat(@stmt,') as b on (a.aid = b.aid)');
      prepare s1 from @stmt;
      execute s1;
      deallocate prepare s1;
      set @stmt = NULL;
    END$$
    DELIMITER ;


    4)、我們用mysqlslap來測試
    以下得這個例子代表用mysqlslap來測試并發數為25,50,100的調用存儲過程,并且總共調用5000次。
    [root@localhost ~]# mysqlslap --defaults-file=/usr/local/mysql-maria/my.cnf --concurrency=25,50,100 --iterations=1 --query='call t_girl.sp_get_article(2,10,1);' --number-of-queries=5000 --debug-info  -uroot -p -S/tmp/mysql50.sock
    Enter password:
    Benchmark
            Average number of seconds to run all queries: 3.507 seconds
            Minimum number of seconds to run all queries: 3.507 seconds
            Maximum number of seconds to run all queries: 3.507 seconds
            Number of clients running queries: 25
            Average number of queries per client: 200
    平均每個并發運行200個查詢用了3.507秒。
    Benchmark
            Average number of seconds to run all queries: 3.742 seconds
            Minimum number of seconds to run all queries: 3.742 seconds
            Maximum number of seconds to run all queries: 3.742 seconds
            Number of clients running queries: 50
            Average number of queries per client: 100
    Benchmark
            Average number of seconds to run all queries: 3.697 seconds
            Minimum number of seconds to run all queries: 3.697 seconds
            Maximum number of seconds to run all queries: 3.697 seconds
            Number of clients running queries: 100
            Average number of queries per client: 50
    User time 0.87, System time 0.33
    Maximum resident set size 0, Integral resident set size 0
    Non-physical pagefaults 1877, Physical pagefaults 0, Swaps 0
    Blocks in 0 out 0, Messages in 0 out 0, Signals 0
    Voluntary context switches 27218, Involuntary context switches 3100
    看一下SHOW PROCESSLIST 結果
    mysql> show processlist;
    +------+------+--------------------+--------------------+---------+-------+--------------------+------------------------------------------------------------------------------------------------------+
    | Id   | User | Host               | db                 | Command | Time  | State              | Info                                                                                                 |
    +------+------+--------------------+--------------------+---------+-------+--------------------+------------------------------------------------------------------------------------------------------+
    …………
    | 3177 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3178 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3179 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3181 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3180 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3182 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3183 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3187 | root | %                  | t_girl             | Query   |     0 | removing tmp table | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3186 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3194 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3203 | root | %                  | t_girl             | Query   |     0 | NULL               | deallocate prepare s1                                                                                |
    …………
    | 3221 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3222 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3223 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3224 | root | %                  | t_girl             | Query   |     0 | removing tmp table | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3225 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    | 3226 | root | %                  | t_girl             | Query   |     0 | NULL               | select a.* from article as a inner join (select a.aid from article as a  inner join (select cid from |
    +------+------+--------------------+--------------------+---------+-------+--------------------+------------------------------------------------------------------------------------------------------+
    55 rows in set (0.00 sec)
    上面的測試語句其實也可以這樣寫
    [root@localhost ~]# mysqlslap --defaults-file=/usr/local/mysql-maria/my.cnf --concurrency=25,50,100 --iterations=1 --create-schema='t_girl' --query='call sp_get_article(2,10,1);' --number-of-queries=5000 --debug-info  -uroot -p -S/tmp/mysql50.sock
    小總結一下。mysqlslap對于模擬多個用戶同時對MySQL發起“進攻”提供了方便。同時詳細的提供了“高負荷攻擊MySQL”的詳細數據報告。而且如果你想對于多個引擎的性能。這個工具再好不過了。

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: Mysql MySQL mysql mySQL 服務器 工具 性能 Myysqlslap


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>