IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> mysql自带的性能测试工具mysqlslap执行压力测试 -> 正文阅读

[大数据]mysql自带的性能测试工具mysqlslap执行压力测试

对于按照配置的数据库,需要对其基本的性能有个基本的了解,当系统整体性能下降或者不能提升的时候,就需要考虑,是否由于数据库的性能限制导致的结果,此时最好有数据库的性能测试结果作为参考。

mysqlslap [options]

-?, --help          Display this help and exit.
  -a, --auto-generate-sql #自动生成测试表和数据
  --auto-generate-sql-add-autoincrement #对生成的表自动添加auto_increment列
  --auto-generate-sql-execute-number=# 
                      Set this number to generate a set number of queries to
                      run.
  --auto-generate-sql-guid-primary 
                      Add GUID based primary keys to auto-generated tables.
  --auto-generate-sql-load-type=name #测试语句的类型: mixed, update, write, key, or
                      read; default is mixed.
  --auto-generate-sql-secondary-indexes=# 
                      Number of secondary indexes to add to auto-generated
                      tables.
  --auto-generate-sql-unique-query-number=# 
                      Number of unique queries to generate for automatic tests.
  --auto-generate-sql-unique-write-number=# 
                      Number of unique queries to generate for
                      auto-generate-sql-write-number.
  --auto-generate-sql-write-number=# 
                      Number of row inserts to perform for each thread (default
                      is 100).
  --commit=#          Commit records every X number of statements.
  -C, --compress      Use compression in server/client protocol.
  -c, --concurrency=name 
                      Number of clients to simulate for query to run.
  --create=name       File or string to use create tables.
  --create-schema=name 
                      Schema to run tests in.
  --csv[=name]        Generate CSV output to named file or to stdout if no file
                      is named.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
  --debug-check       This is a non-debug version. Catch this and exit.
  -T, --debug-info    This is a non-debug version. Catch this and exit.
  --default-auth=name Default authentication client-side plugin to use.
  -F, --delimiter=name 
                      Delimiter to use in SQL statements supplied in file or
                      command line.
  --detach=#          Detach (close and reopen) connections after X number of
                      requests.
  --enable-cleartext-plugin 
                      Enable/disable the clear text authentication plugin.
  -e, --engine=name   Storage engine to use for creating the table.
  -h, --host=name     Connect to host.
  -i, --iterations=#  Number of times to run the tests.
  --no-drop           Do not drop the schema after the test.
  -x, --number-char-cols=name 
                      Number of VARCHAR columns to create in table if
                      specifying --auto-generate-sql.
  -y, --number-int-cols=name 
                      Number of INT columns to create in table if specifying
                      --auto-generate-sql.
  --number-of-queries=# 
                      Limit each client to this number of queries (this is not
                      exact).
  --only-print        Do not connect to the databases, but instead print out
                      what would have been done.
  -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  --plugin-dir=name   Directory for client-side plugins.
  -P, --port=#        Port number to use for connection.
  --post-query=name   Query to run or file containing query to execute after
                      tests have completed.
  --post-system=name  system() string to execute after tests have completed.
  --pre-query=name    Query to run or file containing query to execute before
                      running tests.
  --pre-system=name   system() string to execute before running tests.
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -q, --query=name    Query to run or file containing query to run.
  --secure-auth       Refuse client connecting to server if it uses old
                      (pre-4.1.1) protocol. Deprecated. Always TRUE
  -s, --silent        Run program in silent mode - no output.
  -S, --socket=name   The socket file to use for connection.
  --sql-mode=name     Specify sql-mode to run mysqlslap tool.
  --ssl-mode=name     SSL connection mode.
  --ssl               Deprecated. Use --ssl-mode instead.
                      (Defaults to on; use --skip-ssl to disable.)
  --ssl-verify-server-cert 
                      Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.
  --ssl-ca=name       CA file in PEM format.
  --ssl-capath=name   CA directory.
  --ssl-cert=name     X509 cert in PEM format.
  --ssl-cipher=name   SSL cipher to use.
  --ssl-key=name      X509 key in PEM format.
  --ssl-crl=name      Certificate revocation list.
  --ssl-crlpath=name  Certificate revocation list path.
  --tls-version=name  TLS version to use, permitted values are: TLSv1, TLSv1.1,
                      TLSv1.2
  --server-public-key-path=name 
                      File path to the server public RSA key in PEM format.
  --get-server-public-key 
                      Get server public key
  -u, --user=name     User for login if not current user.
  -v, --verbose       More verbose output; you can use this multiple times to
                      get even more verbose output.
  -V, --version       Output version information and exit.

1. 单线程测试

# ./mysqlslap -a -uroot -p
Enter password: 
Benchmark
        Average number of seconds to run all queries: 0.012 seconds
        Minimum number of seconds to run all queries: 0.012 seconds
        Maximum number of seconds to run all queries: 0.012 seconds
        Number of clients running queries: 1
        Average number of queries per client: 0

2.?多线程测试

# ./mysqlslap -a -c 100 -uroot -p
Enter password: 
Benchmark
        Average number of seconds to run all queries: 1.608 seconds
        Minimum number of seconds to run all queries: 1.608 seconds
        Maximum number of seconds to run all queries: 1.608 seconds
        Number of clients running queries: 100
        Average number of queries per client: 0

可以看出100个并发测试时,响应时间明显比单个线程测试时的响应时间长。?

3.?迭代测试

# ./mysqlslap -a -i 10 -uroot -p
Enter password: 
Benchmark
        Average number of seconds to run all queries: 0.012 seconds
        Minimum number of seconds to run all queries: 0.012 seconds
        Maximum number of seconds to run all queries: 0.013 seconds
        Number of clients running queries: 1
        Average number of queries per client: 0

4. 多线程迭代测试

# ./mysqlslap -a -c 100 -i 10 -uroot -p
Enter password: 

5. 不同并发用户数的测试

# ./mysqlslap -a --concurrency=50,100 --number-of-queries 1000  -uroot -p            
Enter password: 
Benchmark
        Average number of seconds to run all queries: 1.312 seconds
        Minimum number of seconds to run all queries: 1.312 seconds
        Maximum number of seconds to run all queries: 1.312 seconds
        Number of clients running queries: 50
        Average number of queries per client: 20

Benchmark
        Average number of seconds to run all queries: 1.581 seconds
        Minimum number of seconds to run all queries: 1.581 seconds
        Maximum number of seconds to run all queries: 1.581 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10

6. 不同引擎的测试对比

# ./mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --engine=myisam,innodb,ndbcluster  -uroot -p
Enter password: 
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 0.065 seconds
        Minimum number of seconds to run all queries: 0.063 seconds
        Maximum number of seconds to run all queries: 0.074 seconds
        Number of clients running queries: 50
        Average number of queries per client: 20

Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 0.072 seconds
        Minimum number of seconds to run all queries: 0.071 seconds
        Maximum number of seconds to run all queries: 0.073 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 0.744 seconds
        Minimum number of seconds to run all queries: 0.641 seconds
        Maximum number of seconds to run all queries: 0.849 seconds
        Number of clients running queries: 50
        Average number of queries per client: 20

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 0.389 seconds
        Minimum number of seconds to run all queries: 0.318 seconds
        Maximum number of seconds to run all queries: 0.473 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10

Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 1.314 seconds
        Minimum number of seconds to run all queries: 1.313 seconds
        Maximum number of seconds to run all queries: 1.318 seconds
        Number of clients running queries: 50
        Average number of queries per client: 20

Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 1.581 seconds
        Minimum number of seconds to run all queries: 1.564 seconds
        Maximum number of seconds to run all queries: 1.615 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10

可以看出,平均响应速度最快的是myisam引擎,其次是innodb,最慢的是ndbcluster。ndbcluster引擎在cluster环境中,受网络环境的影响很大。

7. 查询性能测试(select)

ndbcluster引擎测试:

./mysqlslap --engine=ndbcluster -uroot -p --auto-generate-sql-guid-primary  --concurrency=50,100 --number-of-queries=10000 --iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql --create-schema=rdb10 --auto-generate-sql-load-type=read
Enter password: 
Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 54.835 seconds
        Minimum number of seconds to run all queries: 47.827 seconds
        Maximum number of seconds to run all queries: 61.844 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200

Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 59.451 seconds
        Minimum number of seconds to run all queries: 57.080 seconds
        Maximum number of seconds to run all queries: 61.822 seconds
        Number of clients running queries: 100
        Average number of queries per client: 100

innodb引擎测试:

# ./mysqlslap --engine=innodb -uroot -p --auto-generate-sql-guid-primary  --concurrency=50,100 --number-of-queries=10000 --iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql --create-schema=rdb10 --auto-generate-sql-load-type=read    
Enter password: 
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 1.886 seconds
        Minimum number of seconds to run all queries: 1.877 seconds
        Maximum number of seconds to run all queries: 1.895 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 2.022 seconds
        Minimum number of seconds to run all queries: 1.878 seconds
        Maximum number of seconds to run all queries: 2.167 seconds
        Number of clients running queries: 100
        Average number of queries per client: 100

可以看出,innodb引擎的查询效率更高。?

8. 写库测试(insert)

ndbcluster引擎测试:

# ./mysqlslap --engine=ndbcluster -uroot -p --auto-generate-sql-guid-primary  --concurrency=50,100 --number-of-queries=10000 --iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql --create-schema=rdb10 --auto-generate-sql-load-type=write
Enter password: 
Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 1.529 seconds
        Minimum number of seconds to run all queries: 1.528 seconds
        Maximum number of seconds to run all queries: 1.531 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200

Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 1.475 seconds
        Minimum number of seconds to run all queries: 1.469 seconds
        Maximum number of seconds to run all queries: 1.482 seconds
        Number of clients running queries: 100
        Average number of queries per client: 100

innodb写入测试:?

# ./mysqlslap --engine=innodb -uroot -p --auto-generate-sql-guid-primary  --concurrency=50,100 --number-of-queries=10000 --iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql --create-schema=rdb10 --auto-generate-sql-load-type=write
Enter password: 
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 17.523 seconds
        Minimum number of seconds to run all queries: 17.409 seconds
        Maximum number of seconds to run all queries: 17.637 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 15.521 seconds
        Minimum number of seconds to run all queries: 15.106 seconds
        Maximum number of seconds to run all queries: 15.937 seconds
        Number of clients running queries: 100
        Average number of queries per client: 100

可以看出ndbcluster引擎的写入效率更高。

9. 更新性能测试(update)

ndbcluster引擎测试:

# ./mysqlslap --engine=ndbcluster -uroot -p --auto-generate-sql-guid-primary  --concurrency=50,100 --number-of-queries=10000 --iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql --create-schema=rdb10 --auto-generate-sql-load-type=update
Enter password: 
Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 1.474 seconds
        Minimum number of seconds to run all queries: 1.474 seconds
        Maximum number of seconds to run all queries: 1.475 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200

Benchmark
        Running for engine ndbcluster
        Average number of seconds to run all queries: 1.426 seconds
        Minimum number of seconds to run all queries: 1.424 seconds
        Maximum number of seconds to run all queries: 1.428 seconds
        Number of clients running queries: 100
        Average number of queries per client: 100

innodb引擎测试:

# ./mysqlslap --engine=innodb -uroot -p --auto-generate-sql-guid-primary  --concurrency=50,100 --number-of-queries=10000 --iterations=2 --number-char-cols=10 --number-int-cols=10 --auto-generate-sql --create-schema=rdb10 --auto-generate-sql-load-type=update
Enter password: 
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 17.469 seconds
        Minimum number of seconds to run all queries: 17.227 seconds
        Maximum number of seconds to run all queries: 17.712 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 15.241 seconds
        Minimum number of seconds to run all queries: 15.137 seconds
        Maximum number of seconds to run all queries: 15.346 seconds
        Number of clients running queries: 100
        Average number of queries per client: 100

可以看出ndbcluster引擎性能比innodb更好。

  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2022-06-26 16:58:01  更:2022-06-26 16:58:56 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/23 16:32:50-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码