[服务器教程] 使用sysbench对腾讯云轻量数据库进行基准测试
作者:精品下载站 日期:2021-08-26 00:00:00 浏览:94 分类:站长帮
使用sysbench对腾讯云轻量数据库进行基准测试
最近腾讯云开启了轻量数据库的公测,经过博主的测试轻量数据的性能要远高于在自己云服务器上面自建的数据库,这里建议有条件或者有需求的可以使用
一、 安装sysbench
首先选择一台轻量数据库同区域的腾讯云轻量应用服务器,安装sysbench。
这个是数据库
这个是服务器
yum安装
wget https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh
chmod +x script.rpm.sh
./script.rpm.sh
yum install -y sysbench
下载tar.gz安装
yum install -y automake libtool
wget https://github.com/akopytov/sysbench/archive/refs/tags/1.0.20.tar.gz
tar zvxf 1.0.20.tar.gz
cd sysbench-1.0.20
./autogen.sh
./configure
make -j4
make install
二、准备测试表
新建用户和数据库
登录轻量数据库DMC,可以通过这里管理数据库的用户和库表,这里我新建了一个test-db
新建用户并授予对应库所有权限
CREATE USER `test`@`` IDENTIFIED BY 'test';
GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables, Create View, Delete, Drop, Event, Execute, Grant Option, Index, Insert, Lock Tables, References, Select, Show View, Trigger, Update ON `test\_db`.* TO `test`@``;
执行命令
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare
sysbench
//基于mysql的驱动去连接mysql数据库
--db-driver=mysql
//连续访问300秒
--time=300
//10个线程模拟并发访问
--threads=10
//每隔1秒输出一下压测情况
--report-interval=1
//本机
--mysql-host=127.0.0.1
//端口号:3306
--mysql-port=3306
//测试用户
--mysql-user=root
//测试密码
--mysql-password=*******
//测试数据库
--mysql-db=test_db
//模拟新建20个表
--tables=20
//100万条数据 执行oltp数据库的读写测试
--table_size=1000000 oltp_read_write
//参照这个命令的设置去构造出来我们需要的数据库里的数据
//自动创建20个测试表,每个表里创建100万条测试数据
--db-ps-mode=disable prepare
三、开始测试
1、测试综合TPS
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable run
测试命令执行之后
反馈解释:thds 压测线程数 | tps 每秒事务数 | qps 每秒请求数 | (r/w/o) 每秒的请求数中读请求个数/写请求个数/其他请求个数 | lat(ms,95%) 95% 的请求延迟都在多少以下 | err/s 错误数 | reconn/s 重连数
测试结果:
SQL statistics:
queries performed:
read: 1379084 #300s执行了137万读请求
write: 394024 #300s执行了39万写请求
other: 197012 #300s执行了19万其他请求
total: 1970120 #300s执行了共197万请求
transactions: 98506 (328.27 per sec.) #300s执行了共9.8万次事务(每秒382.27次事务)
queries: 1970120 (6565.43 per sec.) #300s执行了查询共197万次请求(每秒0.65万次请求)
ignored errors: 0 (0.00 per sec.) #300s忽略错误总数(每秒忽略错误次数)
reconnects: 0 (0.00 per sec.) #300s重连总数(每秒重连次数)
General statistics:
total time: 300.0742s #总耗时
total number of events: 98506 #总发生的事务数
Latency (ms):
min: 20.68 #最小延迟 20.68ms
avg: 30.46 #平均延迟 30.46ms
max: 162.34 #最大延迟 162.34ms
95th percentile: 46.63 #95%的请求延迟 46.63ms
sum: 3000010.96
Threads fairness:
events (avg/stddev): 9850.6000/536.53
execution time (avg/stddev): 300.0011/0.03
2、其他测试
只读性能 oltp_read_only
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_only --db-ps-mode=disable run
删除性能 oltp_delete
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_delete --db-ps-mode=disable run
更新索引字段性能 oltp_update_index
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_index --db-ps-mode=disable run
更新非索引字段性能 oltp_update_non_index
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_non_index --db-ps-mode=disable run
插入性能 oltp_insert
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_insert --db-ps-mode=disable run
写入性能 oltp_write_only
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_write_only --db-ps-mode=disable run
测试完成进行清理 CleanUp
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable cleanup
至此本次基准测试到此结束,使用sysbench对腾讯云轻量数据库进行基准测试有其他不明白的地方,朋友可以到我博客和我交流
博主站点
博主的个人博客地址是:https://www.cdz432.com/
最后
安利一下,腾讯云限时秒的活动,优惠力度非常大,当前买到就是赚到了,1核2G的配置最低99元一年。
为了保证博主的写作兴趣,请大家有需要的一定要多多支持。以下连接内含(AFF)
【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元
腾讯云限时秒杀
【腾讯云】轻量应用服务器Lighthouse,上云「轻」而易举,1核1G3M低至128元/年,高带宽首选
期待下一次给大家带来更好的教程,我们下次再见。
猜你还喜欢
- 03-12 [建站系列] 如何轻松搭建专业企业邮箱:从域名到收发邮件的完整指南
- 03-12 [建站系列] Cloudflare R2个人免费图床:如何设置和使用Cloudflare R2图床
- 06-04 [站长技术] 如何开启WordPress Multisite多站点网络
- 03-29 [环境测试] Hexo部署GitHub Pages
- 03-22 [源码设置] 如何设置Xiuno BBS URL-Rewrite(伪静态设定)
- 03-06 [建站交流] PicGo + smms 构建图床
- 11-18 [emlog技巧] Emlog非插件显示评论者IP属地
- 11-09 [网站维护] WordPress 后台速度慢?加快仪表板速度的 15 种方法
- 11-09 [WordPress插件] 10 个最好用的 WordPress 聊天机器人插件(免费和付费)
- 11-09 [WordPress开发] 探索 WordPress 6.3 中的增强样板(Patterns)
- 11-09 [网站维护] 无需插件即可优化 WordPress 速度的 12 种策略
- 11-09 [网站安全] WordPress 安全统计:WordPress 到底有多安全?
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[短剧] 2025年06月03日 精选+付费短剧推荐25部
[软件合集] 25年6月3日 精选软件44个
[短剧合集] 2025年06月2日 精选+付费短剧推荐39部
[软件合集] 25年6月2日 精选软件18个
[软件合集] 25年6月1日 精选软件15个
[短剧合集] 2025年06月1日 精选+付费短剧推荐59部
[短剧] 2025年05月31日 精选+付费短剧推荐58部
[软件合集] 25年5月31日 精选软件66个
[电影] 黄沙漫天(2025) 4K.EDRMAX.杜比全景声 / 4K杜比视界/杜比全景声
[风口福利] 短视频红利新风口!炬焰创作者平台重磅激励来袭
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[影视] 内地绝版高清录像带 [mpg]
[书籍] 古今奇书禁书三教九流资料大合集 猎奇必备珍藏资源PDF版 1.14G
[美图] 2W美女个美女小姐姐,饱眼福
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag