• Home
  • Archives
  • 随笔
所有文章 友链 关于我

  • Home
  • Archives
  • 随笔

MySQL性能压力测试从0开始到宕机

发布于: 2021-04-27
更新于: 2023-07-09

MySQL 性能

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.
通过模拟多个并发的客户端对 MySQL 服务器进行诊断,并报告每一个阶段的耗时

$ mysqlslap -a --concurrency=50 --number-of-queries 100 -i 5  -uroot -p
Enter password:
Benchmark
    Average number of seconds to run all queries: 0.091 seconds
    Minimum number of seconds to run all queries: 0.067 seconds
    Maximum number of seconds to run all queries: 0.146 seconds
    Number of clients running queries: 50
    Average number of queries per client: 2

测试案例(使用自动造数的数据)

可通过私有的建表语句 or 造数语句进行测试,或者直接使用默认的造数形式

# 私有的建表语句和造数内容,模拟50个用户进行200次的查询

$            mysqlslap --delimiter=";" \
             --create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)" \
             --query="SELECT * FROM a" --concurrency=50 --iterations=200 -uroot -p


# 制造有2个int columns 和3个varchar的字段用于压测
$            mysqlslap --delimiter=";" \
             --create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)" \
             --query="SELECT * FROM a" --concurrency=50 --iterations=200 -uroot -p
Enter password:
Benchmark
    Average number of seconds to run all queries: 0.027 seconds
    Minimum number of seconds to run all queries: 0.020 seconds
    Maximum number of seconds to run all queries: 0.052 seconds
    Number of clients running queries: 50
    Average number of queries per client: 1

测试案例(使用自己的测试数据)

# 对现有数据库查询性能状况如何
# --only-print 只打印会干点啥,不会实际执行

$            mysqlslap --delimiter=";" \
             --create-schema="jarvis" \
             --query="SELECT count(*) from test_student" --concurrency=1 --iterations=1 --only-print  -uroot -p

Enter password:
Benchmark
    Average number of seconds to run all queries: 0.060 seconds
    Minimum number of seconds to run all queries: 0.060 seconds
    Maximum number of seconds to run all queries: 0.060 seconds
    Number of clients running queries: 1
    Average number of queries per client: 1
MySQL性能压力测试从0开始到宕机
/archives/5dbdb603/
作者
tyrantqiao
发布于
2021-04-27
更新于
2023-07-09
许可协议
CC BY-NC-SA 4.0
赏

蟹蟹大佬的打赏,大家一起进步

支付宝
微信
  • mysql
  • 性能

扫一扫,分享到微信

微信分享二维码
会计-程序员角度
mysql从开始翻书到放弃の一
© 2024 tyrantqiao 本站总访问量次 本站访客数人次 载入天数...载入时分秒...
  • 所有文章
  • 友链
  • 关于我

tag:

  • 复盘
  • 我
  • 规划
  • java
  • 面试
  • 源码
  • 架构
  • Hadoop
  • HTTP
  • TCP
  • 学习笔记
  • IDEA
  • maven
  • idea
  • Java
  • jdk
  • 面经
  • linux
  • 爱情
  • mysql
  • 性能
  • sql
  • Mysql
  • JAVA
  • 技术
  • Redis
  • MQ
  • Spring
  • 数据库
  • TIDB
  • spring
  • unity
  • chatgpt
  • 经验分享
  • 前端
  • redis
  • vue
  • git
  • shadowsocks
  • hexo
  • blog
  • bug
  • 开发
  • 业务
  • jvm
  • 算法
  • MySQL
  • nginx
  • Linux
  • mq
  • db
  • springCloud
  • ssh
  • python
  • 爬虫
  • test
  • vim
  • 影视剧
  • 中间件
  • 事务
  • 性格
  • 音乐
  • 程序员
  • 随笔
  • mybatis
  • 演讲
  • 域名
  • 猫咪
  • 她
  • github
  • 计划
  • 旅游
  • 软件
  • 心理
  • 情商
  • 幽默
  • 才艺
  • 穿搭
  • 编程
  • 排序
  • 查找
  • 缓存
  • 网络
  • 设计模式
  • c
  • 课程设计
  • centos
  • 数学
  • 本网站主题yilia设计者的主页
如果有问题或者想讨论的可以联系[email protected]或者[email protected]