• Home
  • 归档
文章检索 作品与友邻 关于我
暴君乔博客
Home 归档

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

发布于: 2021-04-27
更新于: 2023-07-09
文章目录
  1. MySQL 性能
    1. mysqlslap

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从开始翻书到放弃の一
© 2026 tyrantqiao 本站总访问量次 本站访客数人次 载入天数...载入时分秒...
  • 文章检索
  • 作品与友邻
  • 关于我

展开标签

  • 随笔
  • 旅行
  • Java
  • 面经
  • 源码
  • 架构
  • Hadoop
  • 计算机网络
  • 技术
  • IDEA
  • maven
  • JDK
  • Linux
  • MySQL
  • 性能
  • 数据库
  • Redis
  • MQ
  • Spring
  • SquirrelFin
  • 记账
  • Android
  • 个人财务
  • TIDB
  • unity
  • chatgpt
  • 前端
  • Vue
  • Git
  • shadowsocks
  • Hexo
  • 问题排查
  • 业务
  • JVM
  • 算法
  • nginx
  • ssh
  • Python
  • 爬虫
  • test
  • vim
  • 影视剧
  • 中间件
  • 事务
  • 表达
  • 运动
  • mybatis
  • 域名
  • AI
  • 产品
  • 家装
  • 土巴兔
  • github
  • 软件
  • 个人项目
  • Leaves
  • 幽默
  • 穿搭
  • 画画
  • 缓存
  • 摄影
  • 设计模式
  • c
  • 课程设计
  • 调酒
  • 数学

Collection

作品与友邻

我做的小工具、朋友的站点和一些长期值得回访的灵感来源。

  • 土 土巴兔 AI 导购交互演示 可点击体验用户导购、平台运营、装修公司、材料商及 AI 话术知识库的多端增长流程。 /demos/tubatu-ai-guide/
  • L Leaves 行程记录 我做的行程记录页面小工具,用来沉淀旅行路线、日程安排和途中的灵感。 https://leaves.tyrantqiao.com/
  • 本 本网站主题yilia设计者的主页 http://litten.me/
tyrantqiao的头像

tyrantqiao

github rss qq mail facebook linkedin

About

关于我

代码、海浪和持续折腾,都是生活的一部分。

<div class="aboutme-card"> <p class="aboutme-eyebrow">tyrantqiao</p> <h3>Java 全栈开发</h3> <p>常年和 Java、后端服务、前端工程、数据与部署打交道,喜欢把复杂问题拆开、写清楚,也把踩坑过程整理成文章留给后来的人。</p> <div class="aboutme-tags"> <span>Java</span> <span>Full Stack</span> <span>Backend</span> <span>Frontend</span> <span>Extreme Sports</span> </div> <p>工作之外偏爱冲浪等极限运动,享受在浪上找平衡,也享受在代码里找边界。</p> <div class="aboutme-contact"> <a href="mailto:[email protected]">Gmail</a> <a href="mailto:[email protected]">QQ Mail</a> </div> </div>