proxysql压测

【1】测试架构

(1.1)机器架构

IP        server-id    db-version  desc

192.168.148.149  1493306    8.0.22    master(gtid)、proxysql 2.2.2-11

192.168.148.176  1793306    8.0.22    slave(gtid)

192.168.148.185  1853306    8.0.22    slave(gtid)

(1.2)mysql 与 proxysql配置

mysql主库执行:

-- mysql主库执行
create user repl@'192.168.191.%' identified by '123456';
grant replication client,replication slave on *.* to repl@'192.168.191.%';

create user proxysql@'192.168.191.%' identified by '123456';
grant all privileges on *.* to proxysql@'192.168.191.%';

create user monitor@'192.168.191.%' identified by '123456';
grant all privileges on *.* to monitor@'192.168.191.%';

mysql从库执行:

change master to
master_host='192.168.191.149',
master_user='repl',
master_password='123456',
master_auto_position=1;

start slave;
set global read_only=1;

proxysql 执行:

# (1)监控
set mysql-monitor_username='monitor';
set mysql-monitor_password='123456';
set mysql-monitor_enabled='true';

UPDATE global_variables SET variable_value='2000' 
WHERE variable_name IN ('mysql-monitor_connect_interval','mysql-monitor_ping_interval','mysql-monitor_read_only_interval');

load mysql variables to runtime; 
save mysql variables to disk;

# (2)用户
insert into mysql_users(username,password,active,default_hostgroup) values('proxysql','123456',1,1);
load mysql users to runtime; 
save mysql users to disk;

 

 

【2】1主1从压测

前置信息:

  网络延迟,内网 0.5-1ms

(2.1)proxysql配置

监控和连接相关信息已经在 (1.2)中配置好;

mysql_threads=4(这个参数表示proxysql能利用的与后面Mysql的线程数,默认4线程,也就是说CPU最高可以达到400%)

# 服务器
insert into mysql_servers(hostgroup_id,hostname,port) values(1,'192.168.191.149',3306);
insert into mysql_servers(hostgroup_id,hostname,port) values(2,'192.168.191.176',3306); 

# 复制组
insert into mysql_replication_hostgroups(writer_hostgroup,reader_hostgroup) values(1,2);

# 查询规则
insert into mysql_query_rules(rule_id,active,match_pattern,destination_hostgroup,apply) values (1,1,'^select',2,1);
load mysql servers to runtime;
load mysql query rules to runtime;
save mysql servers to disk;
save mysql query rules to disk;

(2.2)mysql 插入 与 proxysql 插入压测命令

mysql 插入: 

sysbench oltp_insert --mysql_storage_engine=innodb --db-driver=mysql --mysql-host=192.168.191.149 --mysql-port=3306 --mysql-user=proxysql --mysql-password=123456 --mysql-db=test --threads=4 --table_size=2000000 --tables=4  --time=120 run

 

结果:

TPS:3305
General statistics: total time: 120.0043s total number of events: 396720 Latency (ms): min: 0.39 avg: 1.21 max: 650.67 95th percentile: 1.37 sum: 478812.97

proxysql 插入:

  命令就是换了一个端口为 6033而已

SQL statistics:
    transactions:                        329822 (2743.12 per sec.)
    queries:                             329822 (2743.12 per sec.)

General statistics:
    total time:                          120.2332s
    total number of events:              329822

Latency (ms):
         min:                                    0.46
         avg:                                    1.45
         max:                                 2602.47
         95th percentile:                        1.34
         sum:                               479625.40

(2.3)proxysql与mysql 同机器压测 insert

  

 

(2.4)proxysql与 mysql不同机器的 select

  

(2.5)proxysql与mysql不同机器上的 insert

  

 

【结论】

性能方面:

(1)当proxysql 与 mysql 在同一台机器上的时候,效率几乎相同

(2)当proxysql 与 mysql 不在同一台机器上的时候,

  insert:proxysql 有90%左右 mysql直连的性能

  select:proxysql 有75%(70-80浮动) 左右 mysql直连的性能

  delete:proxysql 有75%(70-80浮动) 左右 mysql直连的性能

  update:proxysql 有75%(70-80浮动) 左右 mysql直连的性能

 

posted @ 2022-02-21 17:37  郭大侠1  阅读(282)  评论(0编辑  收藏  举报