[MySQL FAQ]系列 -- 用mysqlslap进行压力测试

mysqlslap是官方提供的压力测试工具之一,官方介绍如下:

mysqlslap is a diagnostic program designed to emulate client load for a MySQL server and to report
the timing of each stage. It works as if multiple clients are accessing the server. mysqlslap is
available as of MySQL 5.1.4.

下面介绍一些常见参数:

--auto-generate-sql-write-number

每个线程中产生多少个insert

--auto-generate-sql-guid-primary

自动产生guid格式的主键

--number-of-queries=50000

每个连接客户端总共发起的查询次数

--concurrency=10,50,100

并发连接线程数,分别是10、50、100个并发

-i, --iterations

重复执行测试的次数

--number-char-cols=10

创建测试表的 char 型字段数量

--number-int-cols=10

创建测试表的 int 型字段数量
下面是一个完整的例子:

mysqlslap -hlocalhost -uroot --engine=innodb --auto-generate-sql-write-number=100000 \
--auto-generate-sql-guid-primary --concurrency=10,50,100 --number-of-queries=500000 \
--iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql \
--create-schema=sbtest --auto-generate-sql-load-type=mixed

具体的慢慢看手册吧,不多啰嗦了,哈。

回复

此内容将保密,不会被其他人看见。
  • 允许的 HTML 标签: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • 行和段被自动切分。
  • 网页地址和电子邮件地址将会被自动转换为链接。

更多格式化选项信息

随机验证
本功能用于防止垃圾信息
在输入框中输入图片上的字符(注意大小写)