前文
快速部署OceanBase 集群 1ZONE 6节点,使用SysBench对比测试mysql8.4单节点
https://90apt.com/5039
一、环境准备
1、安装规划
仍在同一套超融合中部署测试,保证硬件性能相同。
本次部署的对象为:
Postgres17单机 32C64G
mariaDB11单机 32C64G
Citus Postgres单机6容器集群 2副本5工作节点哈希分布 32C64G
Citus Postgres集群 2副本5工作节点32分片哈希分布 48C96G
Citus Postgres集群 2副本5工作节点5分片哈希分布 48C96G
关闭防火墙,避免影响实验
systemctl stop firewalld && systemctl disable firewalld
2、安装部署
Postgres17单机、mariaDB11单机使用anolis8系统 1panel面板一键部署
Citus Postgres单机6容器集群 2副本5工作节点哈希分布 使用anolis8系统
Citus Postgres集群 使用alma9系统
二、1panel一键部署Postgres17单机、mariaDB11单机
1、使用1P面板一键部署即可Postgres17单机、mariaDB11单机
2、性能测试
2.1、MYSQL单机OLTP读写混合场景
清除数据
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=IP地址 --mysql-port=端口 --mysql-db=数据库名 --mysql-user=用户名 --mysql-password=密码 --table_size=1000000 --tables=350 --threads=80 --report-interval=10 --rand-type=uniform --time=60 cleanup
初始化测试数据
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=IP地址 --mysql-port=端口 --mysql-db=数据库名 --mysql-user=用户名 --mysql-password=密码 --table_size=1000000 --tables=350 --threads=80 --report-interval=10 --rand-type=uniform --time=60 prepare
执行测试
sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=IP地址 --mysql-port=端口 --mysql-db=数据库名 --mysql-user=用户名 --mysql-password=密码 --table_size=1000000 --tables=350 --threads=80 --report-interval=10 --time=60 --rand-type=uniform --db-ps-mode=disable run
2.2、MYSQL单机OLTP只读场景压测
准备数据
sysbench --db-driver=mysql --mysql-host=IP地址 --mysql-port=端口 --mysql-user=用户名 --mysql-password=密码 --mysql-db=数据库名 --table_size=1000000 --tables=350 --events=0 --time=300 --threads=80 oltp_read_only prepare
运行压测
sysbench --db-driver=mysql --mysql-host=IP地址 --mysql-port=端口 --mysql-user=用户名 --mysql-password=密码 --mysql-db=数据库名 --table_size=1000000 --tables=350 --events=0 --time=300 --threads=80 --percentile=95 --report-interval=1 oltp_read_only run
清理数据
sysbench --db-driver=mysql --mysql-host=IP地址 --mysql-port=端口 --mysql-user=用户名 --mysql-password=密码 --mysql-db=数据库名 --table_size=1000000 --tables=350 --events=0 --time=300 --threads=80 --percentile=95 oltp_read_only cleanup
2.3、PG单机OLTP读写混合场景
清除数据
sysbench /usr/share/sysbench/oltp_read_write.lua --db-driver=pgsql --pgsql-host=IP地址 --pgsql-port=端口 --pgsql-db=数据库名 --pgsql-user=用户名 --pgsql-password=密码 --table_size=1000000 --tables=350 --threads=80 --report-interval=10 --rand-type=uniform cleanup
初始化测试数据
sysbench /usr/share/sysbench/oltp_read_write.lua --db-driver=pgsql --pgsql-host=IP地址 --pgsql-port=端口 --pgsql-db=数据库名 --pgsql-user=用户名 --pgsql-password=密码 --table_size=1000000 --tables=350 --threads=80 --report-interval=10 --rand-type=uniform prepare
执行测试
sysbench /usr/share/sysbench/oltp_read_write.lua --db-driver=pgsql --pgsql-host=IP地址 --pgsql-port=端口 --pgsql-db=数据库名 --pgsql-user=用户名 --pgsql-password=密码 --table_size=1000000 --tables=350 --threads=80 --report-interval=10 --time=60 --rand-type=uniform --db-ps-mode=disable run
2.4、PG单机OLTP只读场景压测
准备数据
sysbench --db-driver=pgsql --pgsql-host=IP地址 --pgsql-port=端口 --pgsql-db=数据库名 --pgsql-user=用户名 --pgsql-password=密码 --table_size=1000000 --tables=350 --events=0 --time=300 --threads=80 oltp_read_only prepare
运行压测
sysbench --db-driver=pgsql --pgsql-host=IP地址 --pgsql-port=端口 --pgsql-db=数据库名 --pgsql-user=用户名 --pgsql-password=密码 --table_size=1000000 --tables=350 --events=0 --time=300 --threads=80 --percentile=95 --report-interval=1 oltp_read_only run
清理数据
sysbench --db-driver=pgsql --pgsql-host=IP地址 --pgsql-port=端口 --pgsql-db=数据库名 --pgsql-user=用户名 --pgsql-password=密码 --table_size=1000000 --tables=350 --events=0 --time=300 --threads=80 --percentile=95 oltp_read_only cleanup
最后放测试结果
三、搭建Citus Postgres单机容器集群
1、Citus相关概念
分布表
分布在所有节点
create_distributed_table
参考表
全部内容集中在一个分片中,每个数据节点复制该内容,保证数据一致性
create_reference_table
本地表
协调节点不切分就是普通本地数据库,默认
并行查询
跨多个节点查询允许同时运行更多查询,协调节点需增强性能
数据分布方式
按哈希分布 默认 扩容节点需要迁移数据重新分布
按数据范围分布
按数据量分布
2、下载docker镜像
docker pull citusdata/citus
3、创建docker网络
bridge网桥模式
docker network create --subnet=192.168.88.0/24 citus-network
查看创建的网络
docker network ls
NETWORK ID NAME DRIVER SCOPE
3ba81d539b5d 1panel-network bridge local
c24c0167d92e bridge bridge local
de9fd59a6f8a citus-network bridge local
a253a0857538 host host local
4aae934ed291 none null local
4、启动citus服务
创建协调节点 coordinate服务节点
docker run -dit --name citus-cod -p 5433:5432 -v /citus/citus-cod:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
创建工作节点
docker run -dit --name citus-worker10 -v /citus/worker10:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e POSTGRES_HOST_AUTH_METHOD='trust' --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
docker run -dit --name citus-worker11 -v /citus/worker11:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e POSTGRES_HOST_AUTH_METHOD='trust' --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
docker run -dit --name citus-worker12 -v /citus/worker12:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e POSTGRES_HOST_AUTH_METHOD='trust' --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
docker run -dit --name citus-worker13 -v /citus/worker13:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e POSTGRES_HOST_AUTH_METHOD='trust' --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
docker run -dit --name citus-worker14 -v /citus/worker14:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e POSTGRES_HOST_AUTH_METHOD='trust' --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
docker run -dit --name citus-worker15 -v /citus/worker15:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -e POSTGRES_HOST_AUTH_METHOD='trust' --net=citus-network citusdata/citus -c listen_addresses="*" -c shared_preload_libraries='citus'
5、往集群添加节点
进入postgresql协调节点
docker exec -it citus-cod psql -U postgres
添加工作节点
select * from master_add_node('citus-worker10',5432);
select * from master_add_node('citus-worker11',5432);
select * from master_add_node('citus-worker12',5432);
select * from master_add_node('citus-worker13',5432);
select * from master_add_node('citus-worker14',5432);
select * from master_add_node('citus-worker15',5432);
查看工作节点
select * from master_get_active_worker_nodes();
node_name | node_port
----------------+-----------
citus-worker10 | 5432
citus-worker11 | 5432
........
6、管理节点
删除工作节点
DELETE FROM pg_dist_placement WHERE groupid = (SELECT groupid FROM pg_dist_node WHERE nodename ='citus-worker11' AND nodeport = '5432' LIMIT 1);
移除节点
SELECT master_remove_node('citus-worker11', '5432');
重新平衡分片
SELECT rebalance_table_shards();
7、数据库文件转入转出
使用docker cp转入
docker cp 主机文件 容器名:/容器文件
使用docker cp转出
docker cp 容器名:/容器文件 主机文件
导入数据库备份
pg_restore -U postgres -d postgres < 数据库备份.backup
导出数据库备份
pg_dump -U postgres postgres > 数据库备份.sql
8、设置分布表
分片、副本
分片数为5
set citus.shard_count = 5;
副本数为2
SET citus.shard_replication_factor = 2;
分布表
SELECT create_distributed_table('表名','主键');
SELECT create_distributed_table('sbtest1','id');
查看分片数
show citus.shard_count;
citus.shard_count
-------------------
32
(1 row)
查看分片详情
select * from pg_dist_shard; 默认为hash分片
select * from pg_dist_shard_placement; 查看分片与节点的关系
更改分片数
SELECT alter_distributed_table('表名',shard_count:=2,cascade_to_colocated:=true);
SELECT alter_distributed_table('sbtest1',shard_count:=2,cascade_to_colocated:=true);
查看数据存放位置
select get_shard_id_for_distribution_column('sbtest1',1);
9、故障修复
9.1、模拟协调节点故障
docker stop citus-cod
工作节点仍然可以查询
进入工作节点10
docker exec -it citus-worker10 psql -U postgres
查看数据
select * from sbtest1;
9.2、工作节点故障
工作节点故障后,可以进行查询,不能进行写入;
若要继续写入,需要先禁用故障节点citus_disable_node
恢复节点后在重新复制分片 replicate_table_shards
10、性能测试
命令与单机相同,但准备数据库,要先进行表分片,分片后测试性能
SELECT create_distributed_table('sbtest1','id');
SELECT create_distributed_table('sbtest2','id');
......
SELECT create_distributed_table('sbtest350','id');
最后放测试结果
四、搭建Citus Postgres集群
有上面的搭建经验,其实多主机集群就很简单了
安装教程参考官网 https://docs.citusdata.com/en/stable/installation/multi_node_rhel.html#post-enterprise-rhel
1、添加仓库
curl https://install.citusdata.com/community/rpm.sh | sudo bash
2、安装 PostgreSQL + Citus 并初始化数据库
# 安装PG数据库和Citus扩展
sudo yum install -y citus121_16
# 初始化PG数据库
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
# 加载Citus扩展
echo "shared_preload_libraries = 'citus'" | sudo tee -a /var/lib/pgsql/16/data/postgresql.conf
3、配置连接和身份验证
在启动数据库之前,让我们更改其访问权限。默认情况下,数据库服务器仅侦听 localhost 上的 Client 端。作为此步骤的一部分,我们指示它侦听所有 IP 接口,然后配置客户端身份验证文件以允许来自本地网络的所有传入连接。
sudo vi /var/lib/pgsql/16/data/postgresql.conf
# Uncomment listen_addresses for the changes to take effect
listen_addresses = '*'
sudo vi /var/lib/pgsql/16/data/pg_hba.conf
# Allow unrestricted access to nodes in the local network. The following ranges
# correspond to 24, 20, and 16-bit blocks in Private IPv4 address spaces.
host all all 10.0.0.0/8 trust
# Also allow the host unrestricted access to connect to itself
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
启动数据库服务器,创建 Citus 扩展
# 启动数据库 sudo systemctl restart postgresql-16 # 配置开机启动 sudo systemctl enable postgresql-16 您必须将 Citus 扩展添加到要在集群中使用的每个数据库。以下示例将扩展添加到名为 postgres 的默认数据库。 sudo -i -u postgres psql -c "CREATE EXTENSION citus;"
5、要在 coordinator 节点上执行的步骤
在执行上述步骤后,只能在协调器节点上执行下面列出的步骤。
5.1、添加 worker 节点信息
我们需要通知 coordinator 有关其 worker 的信息。要添加此信息,请执行以下操作: 我们调用 UDF,它将节点信息添加到 pg_dist_node catalog 表,协调器使用该表来获取 worker 节点。对于我们的示例,我们假设有两个 worker(名为 worker-101、worker-102)。添加工作人员的 DNS 名称(或 IP 地址) 和服务器端口添加到表中。
# Register the hostname that future workers will use to connect
# to the coordinator node.
#
# You'll need to change the example, 'coord.example.com',
# to match the actual hostname
sudo -i -u postgres psql -c \
"SELECT citus_set_coordinator_host('coord.example.com', 5432);"
# Add the worker nodes.
#
# Similarly, you'll need to change 'worker-101' and 'worker-102' to the
# actual hostnames
5.2、验证安装是否成功
为了验证安装是否成功,我们检查协调器节点是否具有 选取所需的 worker 配置。此命令在 psql 中的 shell 应该输出我们添加到上面 pg_dist_node 表中的工作节点。
sudo -i -u postgres psql -c "SELECT * FROM citus_get_active_worker_nodes();"
6、性能测试
与容器集群相同
五、测试结果
MYSQL单机OLTP读写混合场景
[ 10s ] thds: 80 tps: 279.82 qps: 5649.14 (r/w/o: 3961.11/1120.39/567.64) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 336.51 qps: 6786.91 (r/w/o: 4759.38/1354.52/673.01) lat (ms,95%): 390.30 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 246.00 qps: 4918.91 (r/w/o: 3441.11/985.80/492.00) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 306.70 qps: 6129.61 (r/w/o: 4290.91/1225.30/613.40) lat (ms,95%): 434.83 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 354.50 qps: 7104.99 (r/w/o: 4974.69/1421.30/709.00) lat (ms,95%): 369.77 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 339.50 qps: 6785.12 (r/w/o: 4741.72/1364.40/679.00) lat (ms,95%): 376.49 err/s: 0.00 reconn/s: 0.00
MYSQL单机OLTP只读场景压测
[ 1s ] thds: 80 tps: 2322.83 qps: 37870.75 (r/w/o: 33145.27/0.00/4725.49) lat (ms,95%): 51.02 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 2927.99 qps: 46815.91 (r/w/o: 40960.92/0.00/5854.99) lat (ms,95%): 35.59 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 3440.21 qps: 55064.31 (r/w/o: 48183.89/0.00/6880.41) lat (ms,95%): 31.94 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 3973.17 qps: 63529.73 (r/w/o: 55585.39/0.00/7944.34) lat (ms,95%): 27.17 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 4175.91 qps: 66879.59 (r/w/o: 58526.76/0.00/8352.82) lat (ms,95%): 26.20 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 80 tps: 4714.21 qps: 75534.39 (r/w/o: 66105.97/0.00/9428.42) lat (ms,95%): 22.69 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 4679.42 qps: 74748.76 (r/w/o: 65388.92/0.00/9359.85) lat (ms,95%): 23.10 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 4737.18 qps: 75766.94 (r/w/o: 66295.57/0.00/9471.37) lat (ms,95%): 22.28 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 4650.49 qps: 74527.85 (r/w/o: 65222.87/0.00/9304.98) lat (ms,95%): 23.10 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 4664.70 qps: 74592.18 (r/w/o: 65266.78/0.00/9325.40) lat (ms,95%): 22.69 err/s: 0.00 reconn/s: 0.00
OB集群 1zone6主机OLTP读写混合场景
[ 10s ] thds: 80 tps: 194.03 qps: 3980.77 (r/w/o: 2799.12/785.60/396.05) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 585.61 qps: 11728.84 (r/w/o: 8211.80/2345.83/1171.21) lat (ms,95%): 267.41 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 1159.31 qps: 23173.24 (r/w/o: 16218.30/4636.33/2318.61) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 1573.49 qps: 31474.50 (r/w/o: 22032.76/6294.86/3146.88) lat (ms,95%): 70.55 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 1568.68 qps: 31364.68 (r/w/o: 21954.30/6272.92/3137.46) lat (ms,95%): 89.16 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 1876.77 qps: 37543.14 (r/w/o: 26280.21/7509.89/3753.04) lat (ms,95%): 55.82 err/s: 0.00 reconn/s: 0.00
OB集群 1zone6主机OLTP只读场景压测
[ 1s ] thds: 80 tps: 258.36 qps: 4791.07 (r/w/o: 4194.56/0.00/596.51) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 523.06 qps: 8405.99 (r/w/o: 7359.87/0.00/1046.12) lat (ms,95%): 601.29 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 678.97 qps: 10798.50 (r/w/o: 9440.56/0.00/1357.94) lat (ms,95%): 376.49 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 974.06 qps: 15628.02 (r/w/o: 13679.90/0.00/1948.13) lat (ms,95%): 277.21 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 1244.00 qps: 19876.04 (r/w/o: 17388.04/0.00/2488.01) lat (ms,95%): 207.82 err/s: 0.00
[ 76s ] thds: 80 tps: 5320.92 qps: 85129.68 (r/w/o: 74486.85/0.00/10642.83) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 5331.83 qps: 85282.34 (r/w/o: 74620.67/0.00/10661.67) lat (ms,95%): 18.95 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 5279.20 qps: 84432.24 (r/w/o: 73874.84/0.00/10557.41) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 5431.77 qps: 86835.31 (r/w/o: 75971.77/0.00/10863.54) lat (ms,95%): 18.61 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 5411.58 qps: 86724.27 (r/w/o: 75901.11/0.00/10823.16) lat (ms,95%): 18.61 err/s: 0.00 reconn/s: 0.00
PG单机OLTP读写混合场景
[ 10s ] thds: 80 tps: 150.17 qps: 3145.15 (r/w/o: 2213.04/623.77/308.34) lat (ms,95%): 1050.76 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 189.60 qps: 3731.26 (r/w/o: 2612.54/739.51/379.21) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 299.30 qps: 5992.23 (r/w/o: 4196.32/1197.31/598.60) lat (ms,95%): 530.08 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 340.40 qps: 6804.74 (r/w/o: 4763.56/1360.39/680.79) lat (ms,95%): 484.44 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 425.30 qps: 8512.85 (r/w/o: 5959.04/1703.21/850.61) lat (ms,95%): 376.49 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 592.39 qps: 11850.79 (r/w/o: 8294.72/2371.28/1184.79) lat (ms,95%): 257.95 err/s: 0.00 reconn/s: 0.00
PG单机OLTP只读场景压测
[ 1s ] thds: 80 tps: 358.25 qps: 6397.54 (r/w/o: 5602.21/0.00/795.33) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 675.16 qps: 10843.59 (r/w/o: 9492.27/0.00/1351.32) lat (ms,95%): 282.25 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 773.98 qps: 12380.60 (r/w/o: 10833.65/0.00/1546.95) lat (ms,95%): 235.74 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 583.02 qps: 9271.26 (r/w/o: 8104.23/0.00/1167.03) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 900.02 qps: 14466.28 (r/w/o: 12666.24/0.00/1800.03) lat (ms,95%): 272.27 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 80 tps: 7219.92 qps: 115510.73 (r/w/o: 101073.88/0.00/14436.84) lat (ms,95%): 16.12 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 80 tps: 7312.11 qps: 117077.83 (r/w/o: 102446.60/0.00/14631.23) lat (ms,95%): 15.55 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 7336.09 qps: 117346.48 (r/w/o: 102677.30/0.00/14669.19) lat (ms,95%): 15.27 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 6918.94 qps: 110807.00 (r/w/o: 96968.13/0.00/13838.88) lat (ms,95%): 18.61 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 6900.01 qps: 110262.12 (r/w/o: 96464.11/0.00/13798.02) lat (ms,95%): 20.00 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 7222.03 qps: 115629.55 (r/w/o: 101186.49/0.00/14443.07) lat (ms,95%): 15.00 err/s: 0.00 reconn/s: 0.00
PG单机6容器集群OLTP读写混合场景
[ 10s ] thds: 80 tps: 68.18 qps: 1453.28 (r/w/o: 1031.17/277.74/144.37) lat (ms,95%): 2362.72 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 111.10 qps: 2229.06 (r/w/o: 1564.75/442.21/222.11) lat (ms,95%): 893.56 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 128.00 qps: 2567.82 (r/w/o: 1796.71/515.00/256.10) lat (ms,95%): 773.68 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 136.10 qps: 2713.78 (r/w/o: 1898.08/543.60/272.10) lat (ms,95%): 719.92 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 138.90 qps: 2773.51 (r/w/o: 1940.90/554.70/277.90) lat (ms,95%): 707.07 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 137.50 qps: 2750.50 (r/w/o: 1927.00/548.50/275.00) lat (ms,95%): 719.92 err/s: 0.00 reconn/s: 0.00
PG单机6容器集群OLTP只读场景压测
[ 1s ] thds: 80 tps: 0.00 qps: 820.05 (r/w/o: 740.24/0.00/79.81) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 11.00 qps: 256.10 (r/w/o: 234.09/0.00/22.01) lat (ms,95%): 1973.38 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 71.01 qps: 1037.15 (r/w/o: 895.13/0.00/142.02) lat (ms,95%): 2778.39 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 67.00 qps: 1121.96 (r/w/o: 987.97/0.00/134.00) lat (ms,95%): 1678.14 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 84.00 qps: 1388.04 (r/w/o: 1220.03/0.00/168.00) lat (ms,95%): 2009.23 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 80 tps: 221.98 qps: 3532.71 (r/w/o: 3088.75/0.00/443.96) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 80 tps: 224.99 qps: 3537.87 (r/w/o: 3087.89/0.00/449.98) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 223.02 qps: 3609.26 (r/w/o: 3163.23/0.00/446.03) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 222.00 qps: 3577.02 (r/w/o: 3133.02/0.00/444.00) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 232.99 qps: 3643.80 (r/w/o: 3177.82/0.00/465.97) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 215.02 qps: 3571.29 (r/w/o: 3141.26/0.00/430.03) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
PG6主机集群 2副本5工作节点32分片哈希分布OLTP读写混合场景
[ 10s ] thds: 80 tps: 6.20 qps: 217.91 (r/w/o: 172.23/25.29/20.39) lat (ms,95%): 9624.59 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 17.80 qps: 351.61 (r/w/o: 244.91/71.10/35.60) lat (ms,95%): 11523.48 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 18.90 qps: 374.59 (r/w/o: 261.60/75.20/37.80) lat (ms,95%): 6476.48 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 14.60 qps: 294.10 (r/w/o: 206.50/58.40/29.20) lat (ms,95%): 7895.16 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 17.60 qps: 351.69 (r/w/o: 246.09/70.40/35.20) lat (ms,95%): 7615.89 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 20.70 qps: 414.81 (r/w/o: 290.50/82.90/41.40) lat (ms,95%): 6026.41 err/s: 0.00 reconn/s: 0.00
PG6主机集群 2副本5工作节点32分片哈希分布OLTP只读场景压测
[ 1s ] thds: 80 tps: 0.00 qps: 253.20 (r/w/o: 173.45/0.00/79.75) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 0.00 qps: 315.14 (r/w/o: 315.14/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 0.00 qps: 310.98 (r/w/o: 310.98/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 80 tps: 17.00 qps: 272.01 (r/w/o: 238.01/0.00/34.00) lat (ms,95%): 4280.32 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 80 tps: 22.00 qps: 351.98 (r/w/o: 307.98/0.00/44.00) lat (ms,95%): 4203.93 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 27.00 qps: 432.02 (r/w/o: 378.02/0.00/54.00) lat (ms,95%): 4855.31 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 20.00 qps: 320.00 (r/w/o: 280.00/0.00/40.00) lat (ms,95%): 4358.09 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 21.00 qps: 318.97 (r/w/o: 276.97/0.00/42.00) lat (ms,95%): 4280.32 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 26.00 qps: 435.97 (r/w/o: 383.98/0.00/52.00) lat (ms,95%): 4280.32 err/s: 0.00 reconn/s: 0.00
PG6主机集群 2副本5工作节点5分片哈希分布OLTP读写混合场景
[ 10s ] thds: 80 tps: 18.70 qps: 480.68 (r/w/o: 354.91/80.38/45.39) lat (ms,95%): 6247.39 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 49.90 qps: 992.92 (r/w/o: 693.82/199.30/99.80) lat (ms,95%): 2828.87 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 68.90 qps: 1369.50 (r/w/o: 958.00/273.70/137.80) lat (ms,95%): 2082.91 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 51.40 qps: 1051.00 (r/w/o: 736.00/212.20/102.80) lat (ms,95%): 2880.27 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 58.80 qps: 1164.10 (r/w/o: 815.90/230.60/117.60) lat (ms,95%): 2198.52 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 62.90 qps: 1242.19 (r/w/o: 867.69/248.70/125.80) lat (ms,95%): 1973.38 err/s: 0.00 reconn/s: 0.00
PG6主机集群 2副本5工作节点5分片哈希分布OLTP读写混合场景
[ 1s ] thds: 80 tps: 0.00 qps: 195.52 (r/w/o: 115.72/0.00/79.80) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 1.00 qps: 578.18 (r/w/o: 576.18/0.00/2.00) lat (ms,95%): 1973.38 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 67.00 qps: 989.03 (r/w/o: 855.03/0.00/134.00) lat (ms,95%): 2985.89 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 136.99 qps: 2305.88 (r/w/o: 2031.89/0.00/273.99) lat (ms,95%): 3095.38 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 200.98 qps: 3237.63 (r/w/o: 2835.67/0.00/401.95) lat (ms,95%): 787.74 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 80 tps: 795.93 qps: 12744.86 (r/w/o: 11154.01/0.00/1590.86) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 80 tps: 749.04 qps: 11941.61 (r/w/o: 10442.53/0.00/1499.08) lat (ms,95%): 475.79 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 729.03 qps: 11708.42 (r/w/o: 10250.37/0.00/1458.05) lat (ms,95%): 484.44 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 744.98 qps: 11892.74 (r/w/o: 10402.77/0.00/1489.97) lat (ms,95%): 442.73 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 739.02 qps: 11824.28 (r/w/o: 10346.25/0.00/1478.04) lat (ms,95%): 434.83 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 761.99 qps: 12226.87 (r/w/o: 10702.88/0.00/1523.98) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
mariaDB单机OLTP读写混合场景
[ 10s ] thds: 80 tps: 100.18 qps: 2130.57 (r/w/o: 1507.19/415.02/208.36) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 80 tps: 125.20 qps: 2464.65 (r/w/o: 1721.73/492.51/250.40) lat (ms,95%): 909.80 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 80 tps: 135.70 qps: 2726.24 (r/w/o: 1908.86/545.99/271.39) lat (ms,95%): 816.63 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 80 tps: 156.80 qps: 3113.73 (r/w/o: 2178.95/621.19/313.59) lat (ms,95%): 719.92 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 80 tps: 133.71 qps: 2690.01 (r/w/o: 1886.48/536.12/267.41) lat (ms,95%): 802.05 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 80 tps: 132.90 qps: 2663.70 (r/w/o: 1862.30/535.60/265.80) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
mariaDB单机OLTP只读场景压测
[ 1s ] thds: 80 tps: 1053.26 qps: 17530.32 (r/w/o: 15344.01/0.00/2186.30) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 80 tps: 3058.47 qps: 48963.52 (r/w/o: 42846.58/0.00/6116.94) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 80 tps: 3993.09 qps: 63878.37 (r/w/o: 55892.20/0.00/7986.17) lat (ms,95%): 29.19 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 80 tps: 3401.95 qps: 54410.25 (r/w/o: 47606.34/0.00/6803.91) lat (ms,95%): 38.25 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 80 tps: 3410.99 qps: 54540.82 (r/w/o: 47718.84/0.00/6821.98) lat (ms,95%): 38.25 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 80 tps: 3695.36 qps: 59142.79 (r/w/o: 51753.07/0.00/7389.72) lat (ms,95%): 34.33 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 80 tps: 3858.59 qps: 61812.42 (r/w/o: 54095.24/0.00/7717.18) lat (ms,95%): 31.94 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 80 tps: 3674.11 qps: 58735.75 (r/w/o: 51387.54/0.00/7348.22) lat (ms,95%): 36.24 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 80 tps: 3974.16 qps: 63621.59 (r/w/o: 55672.26/0.00/7949.32) lat (ms,95%): 33.12 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 80 tps: 5416.04 qps: 86639.63 (r/w/o: 75808.55/0.00/10831.08) lat (ms,95%): 21.11 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 80 tps: 5403.05 qps: 86473.78 (r/w/o: 75667.68/0.00/10806.10) lat (ms,95%): 21.50 err/s: 0.00 reconn/s: 0.00
六、小结
table_size=1000000 tables=350 threads=80 mysql单机数据量大约140G
MYSQL8.4.3单机 32C64G默认设置
PGSQL17单机 32C64G默认设置
OB集群 1zone6主机 租户48C96G默认设置
PG单机6容器集群 2副本5工作节点哈希分布
PG6主机集群 2副本5工作节点32分片哈希分布 48C96G
PG6主机集群 2副本5工作节点5分片哈希分布 48C96G
mariaDB11.5.2 32C64G默认设置
读写混合场景下
OB集群遥遥领先>PG单机>MYSQL单机>Maria DB单机>PG单机容器集群>PG6主机集群几乎无法使用
只读场景下
PG单机>OB集群>MYSQL单机≈mariaDB单机>PG单机容器集群>PG6主机集群几乎无法使用
评论