ProxySQL--基础--01--介绍

ProxySQL–基础–01–介绍


1、介绍

  1. 是能用在生产环境的MySQL中间件
  2. 用C++语言开发
  3. 性能很好(据测试,能处理千亿级的数据)

1.1、资料

1.1.1、官方站点

https://www.proxysql.com/

1.1.2、官方github和手册

https://github.com/sysown/proxysql/wiki


1.1.3、percona ProxySQL手册

https://docs.percona.com/percona-xtradb-cluster/8.0/howtos/proxysql.html

1.1.4、中文手册(一个大佬翻译的)

https://github.com/malongshuai/proxysql/wiki

1.2、版本

  1. 官方版:是我们环境部署的版本
  2. percona版:是在官方版的基础上修改的,添加了几个比较实用的工具

1.3、功能

1.3.1、读/写分离

支持多种方式

1.3.2、读对SQL语句进行路由,有以下几种方式

  1. 基于用户
  2. 基于schema
  3. 基于语句的规则

1.3.3、读分库

基于schema和与语句级的规则,可以实现简单的sharding

1.3.4、读缓存查询结果。

虽然ProxySQL的缓存策略比较简陋,但实现了基本的缓存功能,绝大多数时候也够用了。

1.3.5、读监控后端节点。

ProxySQL可以监控后端节点的多个指标,包括:

  1. ProxySQL和后端的心跳信息
  2. 后端节点的read-only/read-write
  3. slave和master的数据同步延迟性(replication lag)。

2、MySQL Proxy,Atlas,MaxScale,ProxySQL 功能对比

资料来源

https://zhjwpku.com/2018/01/16/mysql-proxy-alternatives.html

2.1、MySQL Proxy,Atlas,MaxScale,ProxySQL 介绍

2.1.1、官方github

https://github.com/mysql/mysql-proxy
https://github.com/Qihoo360/Atlas
https://github.com/mariadb-corporation/MaxScale
https://github.com/sysown/proxysql 

2.1.2、MySQL Proxy

  1. 2014年后,项目已不再维护
  2. 最新版本是 Alpha 0.8.5版,不应该在生产环境使用

2.1.3、360/Atlas

  1. 基于 MySQL Proxy(0.8.2)修复了一些 bug 并进行了扩展
  2. 360 公司很多数据库业务会连接到 Atlas 平台,达到了百亿量级。

2.1.4、MaxScale

  1. 文档很全啊
  2. MaxScale 提供 CenOS 7 rpm 安装包,安装也相对较简单。

2.1.5、ProxySQL

  1. ProxySQL 官网上说它比 MaxScale 强大
  2. 虽然文档的质量比 MaxScale 差了点,但它的 Star 数却是 MaxScale 的两倍。

2.2、Atlas,MaxScale,ProxySQL 特性支持对比

由于 MySQL Proxy 官方不建议使用在生产环境,因此这里的特性对比将其忽略。

在这里插入图片描述

从文档的标准程度和项目的活跃度来说,技术选型更倾向MaxScale,ProxySQL

备注:上面数据是很在早的数据,现在有些已经不一样,需要看官方文档

3、MySQL Proxy,Atlas,MaxScale,ProxySQL 性能测试

使用 sysbench 进行测试,测试报告如下

3.1、Atlas

 

➜  ~ sysbench --db-driver=mysql --table-size=200000 --tables=24 --threads=4 --time=120 \
--mysql-host=10.0.63.204 --mysql-port=1234 --mysql-user=root --mysql-password=mysql_password \
 oltp_read_write run
sysbench 1.0.11 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            98840
        write:                           28240
        other:                           14120
        total:                           141200
    transactions:                        7060   (58.80 per sec.)
    queries:                             141200 (1176.08 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          120.0577s
    total number of events:              7060

Latency (ms):
         min:                                 42.58
         avg:                                 68.00
         max:                                251.61
         95th percentile:                    155.80
         sum:                             480113.03

Threads fairness:
    events (avg/stddev):           1765.0000/7.18
    execution time (avg/stddev):   120.0283/0.01

3.2、MaxScale

➜  ~ sysbench --db-driver=mysql --table-size=200000 --tables=24 --threads=4 --time=120 \
--mysql-host=10.0.63.204 --mysql-port=4006 --mysql-user=root --mysql-password=mysql_password \
 oltp_read_write run
sysbench 1.0.11 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            118734
        write:                           33924
        other:                           16962
        total:                           169620
    transactions:                        8481   (70.65 per sec.)
    queries:                             169620 (1413.05 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          120.0358s
    total number of events:              8481

Latency (ms):
         min:                                 39.88
         avg:                                 56.60
         max:                                459.62
         95th percentile:                     68.05
         sum:                             480038.36

Threads fairness:
    events (avg/stddev):           2120.2500/15.94
    execution time (avg/stddev):   120.0096/0.01

3.3、ProxySQL

➜  ~ sysbench --db-driver=mysql --table-size=200000 --tables=24 --threads=4 --time=120 \
--mysql-host=10.0.63.204 --mysql-port=6033 --mysql-user=root --mysql-password=mysql_password \
 oltp_read_write run
sysbench 1.0.11 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            99190
        write:                           28340
        other:                           14170
        total:                           141700
    transactions:                        7085   (59.01 per sec.)
    queries:                             141700 (1180.18 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          120.0646s
    total number of events:              7085

Latency (ms):
         min:                                 45.78
         avg:                                 67.77
         max:                                267.51
         95th percentile:                    102.97
         sum:                             480133.57

Threads fairness:
    events (avg/stddev):           1771.2500/11.84
    execution time (avg/stddev):   120.0334/0.02

多次测试结果显示,在性能上 MaxScale 要更胜一筹,且 MaxScale 的可配置性介于 Atlas 和 ProxySQL 之间,社区比较活跃,所以如果做技术选型的话笔者会首选 MaxScale。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值