MySQL自带轻量压测工具mysqlslap

一款MySQL自带的专用轻量压测工具:mysqlslap

--query:测试要执行的sql语句

--number-of-queries:指定测试要执行sql语句执行的请求数

-c,concurrency:指定测试执行请求的并行度

-i,--iterations:指定测试运行的次数

--create-schema:指定此次测试在哪个schema下执行

[mysql@mysql1 ~]$ mysqlslap -usystem -p123456 -S /data/mysqldata/3306/mysql.sock --query="select user,host from mysql.user" --number-of-queries=10000 -c 30 -i 10 --create-schema=mysql

模拟30个用户连接,共执行100万次请求

Benchmark

         Average number of seconds to run all queries: 0.725 seconds

         Minimum number of seconds to run all queries: 0.698 seconds

         Maximum number of seconds to run all queries: 0.746 seconds

         Number of clients running queries: 30

         Average number of queries per client: 333

下面为QPS结果

| Com_select                                    | 0           |

| Com_select                                    | 0           |

| Com_select                                    | 8078        |

| Com_select                                    | 13867       |

| Com_select                                    | 13496       |

| Com_select                                    | 13681       |

| Com_select                                    | 13164       |

| Com_select                                    | 14373       |

| Com_select                                    | 13664       |

| Com_select                                    | 9577        |

| Com_select                                    | 0           |

| Com_select                                    | 0           |

简单例子

[mysql@mysql1 ~]$ mysqlslap -usystem -p123456 -S /data/mysqldata/3306/mysql.sock \

> --auto-generate-sql --auto-generate-sql-add-autoincrement \

> --auto-generate-sql-execute-number=10000 \

> --auto-generate-sql-unique-query-number=1000 \

> -c 30 --commit=1000 --create-schema=hugc

Benchmark

         Average number of seconds to run all queries: 25.771 seconds

         Minimum number of seconds to run all queries: 25.771 seconds

         Maximum number of seconds to run all queries: 25.771 seconds

         Number of clients running queries: 30

         Average number of queries per client: 10000

下面为QPS结果

| Questions                                     | 1           |

| Questions                                     | 2           |

| Questions                                     | 5413        |

| Questions                                     | 10789       |

| Questions                                     | 12418       |

| Questions                                     | 12025       |

| Questions                                     | 12102       |

| Questions                                     | 9874        |

| Questions                                     | 12376       |

| Questions                                     | 12616       |

| Questions                                     | 12452       |

| Questions                                     | 12376       |

| Questions                                     | 11818       |

| Questions                                     | 12998       |

| Questions                                     | 11436       |

| Questions                                     | 12122       |

| Questions                                     | 12156       |

| Questions                                     | 11479       |

| Questions                                     | 12182       |

| Questions                                     | 11924       |

| Questions                                     | 11693       |

| Questions                                     | 12146       |

| Questions                                     | 11135       |

| Questions                                     | 11963       |

| Questions                                     | 11359       |

| Questions                                     | 11908       |

| Questions                                     | 12372       |

| Questions                                     | 9390        |

| Questions                                     | 1           |

TPS测试结果

[mysql@mysql1 ~]$ mysqlslap -usystem -p123456 -S /data/mysqldata/3306/mysql.sock \

> --auto-generate-sql --auto-generate-sql-add-autoincrement \

> --auto-generate-sql-execute-number=10000 \

> --auto-generate-sql-unique-query-number=1000 \

> -c 30 --commit=1 --create-schema=hugc

Benchmark

         Average number of seconds to run all queries: 72.118 seconds

         Minimum number of seconds to run all queries: 72.118 seconds

         Maximum number of seconds to run all queries: 72.118 seconds

         Number of clients running queries: 30

         Average number of queries per client: 10000

下面为TPS部分结果

| Com_commit                                    | 3702        |

| Com_rollback                                  | 0           |

| Com_rollback_to_savepoint                     | 0           |

| Com_commit                                    | 4053        |

| Com_rollback                                  | 0           |

| Com_rollback_to_savepoint                     | 0           |

| Com_commit                                    | 4570        |

| Com_rollback                                  | 0           |

| Com_rollback_to_savepoint                     | 0           |

| Com_commit                                    | 4630        |

| Com_rollback                                  | 0           |

| Com_rollback_to_savepoint                     | 0           |

| Com_commit                                    | 4190        |

| Com_rollback                                  | 0           |

| Com_rollback_to_savepoint                     | 0           |

| Com_commit                                    | 4466        |

| Com_rollback                                  | 0           |

| Com_rollback_to_savepoint                     | 0           | 

| Com_commit                                    | 4627        |

 

 

你可能感兴趣的:(mysql)