简介
super-smack是一款开源压测工具,支持MySQL、PostgreSQL、Oracle。本篇主要介绍一下使用super-smack压测MySQL体会。
1.SQL定义
2.数据字典定义
3.表结构
4.自动生成数据
5.SQL执行顺序与次数
6.多终端混合压测
MySQL性能表现与实际业务场景有很大关系。压测结果不代表正式生产环境容量,并且对于不同业务场景来说,QPS、TPS可能不再是决定性的指标。
安装
1. wgethttp://vegan.net/tony/supersmack/super-smack-1.3.tar.gz
2. tar xvzfsuper-smack-1.3.tar.gz
3../configure --prefix=/usr/local/super-smack--with-mysql \
--with-mysql-lib=/app/mysql/lib\
--with-mysql-include=/app/mysql/include/mysql
4. make
5. make install
本次安装是针对MySQL。通过./configure --help 可以看到帮助。
--with-mysql Build with MySQL support
--with-pgsql Build with PostgreSQL support
--with-oracle Build with Oracle support
在64位系统面安装需要做一些变量声明修改。在github上面有相应patch
https://github.com/yasunorikaku/super_smack_patch_for_x86_64
目录结构
gen-data
数据生成工具.用于生成数据表测试数据
./gen-data -n10000000 -f %48-64s%n,%32-64s,%n,%d >words.dat
1.-n 10000000 表示行数
2.-f 表示格式
3.s 表示字符串
4.n 表示序列
5.d 表示数字
super-smack
super-smack 客户主程序。用于发起压力测试,模拟操作客户端.
example smacks
模板文件一般有以下组成部分:
Client
client"admin"
{
user "用户名称";
host "主机";
db "数据库名称";
pass "密码";
socket "mysql socket ";
}
Table
table "http_auth"
{
client "admin";
create "create table http_auth
(username char(64) not null primary key,
pass char(12),
mail char(16),
uid integer not null,
gid integer not null,
key mail_key (mail)
)";
min_rows"90000";
data_file"words.dat";
gen_data_file"gen-data -n 90000 -f %36-36s%n, %10-10s,%10-10s,%n,%d";
}
dictionary
dictionary"word"
{
type "rand"; //Seq、Unique、Rand
source_type "file"; // file、list、template
source "words.dat";
delim ",";
file_size_equiv "55000";
}
query
query"delete_by_username"
{
query "delete from http_auth where username = '$word'";
type "delete_index";
has_result_set "y";
parsed "y";
}
smacker
client"smacker"
{
user "用户名称";
pass "用户密码";
host "主机";
db "数据库名称";
socket " mysql socket ";
query_barrel "5 select_by_username ";
}
注:可以定义多个client.
main
main
{
smacker.init();
smacker.set_num_rounds($2);
smacker.set_num_rounds($2);
smacker.create_threads($1);
smacker.connect();
smacker.unload_query_barrel();
smacker.collect_threads();
smacker.disconnect();
}
注:
1.运行客户需要输入$1、$2 .$2表示循环次数,$1表示线程个数.
2.可以加入多个client
输出
./super-smack -dmysql update-select-delete.smack -D/data/ 10 10
输出结果:[此处我定义两个终端]
Query BarrelReport for client smacker1
connect:max=14ms min=0ms avg= 6ms from 10clients
Query_type num_queries max_time min_time q_per_s
delete_index 60 25 0 329.64
insert_index 50 31 1 274.70
select_index 100 36 0 549.41
update_index 50 31 0 274.70
Query BarrelReport for client smacker
connect:max=20ms min=0ms avg= 5ms from 10clients
Query_type num_queries max_time min_time q_per_s
delete_index 60 4 0 328.13
insert_index 50 39 1 273.44
select_index 100 1 0 546.88
update_index 50 0 0 273.44
最后
1.可以自定义多个Query;
2.对于不同的查询需要定义多个数据字典;
3.支持多个客户端。