一次oceanbase数据库Sysbench性能测试实践

测试方案

– 此为实验场景,所有机器都为虚拟机

– OceanBase 集群部署规模为 1:1:1。部署成功后,新建执行 Sysbench 测试的租户及用户(sys 租户是管理集群的内置系统租户,请勿直接使用该租户进行测试),将租户的 PRIMARY_ZONE 设置为 RANDOM。

– 启动 Sysbench 客户端,进行 point_select、read_write、read_only 等测试。

– 每轮测试 –time 设置为 30s,线程数取值可以为 1000。

测试规格如下所示:

--mysql-db=test 
--mysql-host=$obproxy_ip(填写 OBProxy 的 IP)
--table_size=1000000 
--tables=30 
--threads=10000
--report-interval=3
--time=30
--db-ps-mode=disable

测试环境

硬件配置

项目类型 内存 CPU
OceanBase 数据库 3 台 * 132G 3 台 * 32 核
Sysbench(复用OCP) 1 台 * 132G 1 台 * 32 核
ODP(复用OBServer) 1 台 * 132G 1 台 * 32 核

租户规格

– 租户规格

说明

– 您需根据自身数据库的硬件配置进行动态调整。

– 进行性能测试时,租户需配置最大可用资源

CREATE RESOURCE UNIT box1 MAX_CPU 25, MAX_MEMORY '109G', MAX_IOPS 128, MAX_DISK_SIZE '10G', MAX_SESSION_NUM 64, MIN_CPU=25, MIN_MEMORY='109G', MIN_IOPS=128;
CREATE RESOURCE POOL fpool UNIT='box1', UNIT_NUM=1, ZONE_LIST=('z1','z2','z3');
CREATE TENANT tt1 RESOURCE_POOL_LIST=('fpool'), PRIMARY_ZONE='RANDOM' SET ob_compatibility_mode='mysql',ob_tcp_invited_nodes='%';

软件版本

项目类型 软件版本及型号
OceanBase 数据库 V3.2.4
ODP V3.2.9
Sysbench 1.0.20
OS CentOS Linux release 7.6.1810 (Core)
CPU Intel(R) Xeon(R) Gold 5320 CPU @ 2.20GHz

环境信息

操作系统信息
 $cat /etc/redhat-release
 $uname -a
CPU信息
cat /proc/cpuinfo
内存信息
free -g
软件信息
 #observer
 cd /home/admin/oceanbase/bin
 ./observer --version
 
 #obproxy
 cd /home/admin/oceanbase/obproxy/bin
 ./obproxy --version
 
 #sysbench
 cd /usr/sysbench/bin/
 ./sysbench --version

测试内容

创建测试租户

查看可用资源
select a.zone,concat(a.svr_ip,':',a.svr_port) observer,
cpu_total,(cpu_total-cpu_max_assigned) cpu_free,
floor(mem_total/1024/1024/1024) as mem_total_gb,floor((mem_total-mem_max_assigned)/1024/1024/1024) mem_free_gb,
floor(disk_total/1024/1024/1024) as disk_total_gb,floor((disk_total-disk_assigned)/1024/1024/1024) disk_free_gb
from __all_virtual_server_stat a
order by a.zone,a.svr_ip;
创建测试租户
CREATE RESOURCE UNIT box1 MAX_CPU 25, MAX_MEMORY '109G', MAX_IOPS 128, MAX_DISK_SIZE '10G', MAX_SESSION_NUM 64, MIN_CPU=25, MIN_MEMORY='109G', MIN_IOPS=128;
CREATE RESOURCE POOL fpool UNIT='box1', UNIT_NUM=1, ZONE_LIST=('z1','z2','z3');
CREATE TENANT tt1 RESOURCE_POOL_LIST=('fpool'), PRIMARY_ZONE='RANDOM' SET ob_compatibility_mode='mysql',ob_tcp_invited_nodes='%';

配置参数

OBServer启动参数
启动参数设置完成后,需要重启
ALTER SYSTEM SET net_thread_count=12;
ALTER SYSTEM SET use_large_pages="true";
ALTER SYSTEM SET system_cpu_quota=10;
ALTER SYSTEM SET syslog_io_bandwidth_limit='20M';
ALTER SYSTEM SET major_freeze_duty_time='disable';
ALTER SYSTEM SET memstore_limit_percentage=50;
ALTER SYSTEM SET merger_warm_up_duration_time='0s';
ALTER SYSTEM SET zone_merge_concurrency=0;
ALTER SYSTEM SET schema_history_expire_time='1d';
ALTER SYSTEM SET minor_freeze_times=3;
ALTER SYSTEM SET enable_syslog_wf=false;
OBProxy启动参数
启动参数设置完成后,需要重启
ALTER PROXYCONFIG SET enable_strict_kernel_release=false;
ALTER PROXYCONFIG SET work_thread_num=128;
ALTER PROXYCONFIG SET automatic_match_work_thread=false;
ALTER PROXYCONFIG SET enable_prometheus=false;
ALTER PROXYCONFIG SET enable_compression_protocol=false;
ALTER PROXYCONFIG SET proxy_mem_limited=4g;
ALTER PROXYCONFIG SET enable_qos=true;
集群参数
ALTER SYSTEM SET enable_sql_audit=false;
ALTER SYSTEM SET cpu_quota_concurrency=4;
ALTER SYSTEM SET server_data_copy_out_concurrency=1000;
ALTER SYSTEM SET server_data_copy_in_concurrency=1000;
ALTER SYSTEM SET memory_chunk_cache_size='16G';
ALTER SYSTEM SET minor_freeze_times=200;
ALTER SYSTEM SET clog_transport_compress_all=false;
ALTER SYSTEM SET trx_try_wait_lock_timeout='0ms';
ALTER SYSTEM SET large_query_threshold='1s';
ALTER SYSTEM SET trace_log_slow_query_watermark='500ms';
ALTER SYSTEM SET syslog_io_bandwidth_limit='30m';
ALTER SYSTEM SET enable_async_syslog=true;
ALTER SYSTEM SET merger_warm_up_duration_time='0';
ALTER SYSTEM SET merger_switch_leader_duration_time='0';
ALTER SYSTEM SET large_query_worker_percentage=10;
ALTER SYSTEM SET minor_compact_trigger= 2;
ALTER SYSTEM SET builtin_db_data_verify_cycle=0;
ALTER SYSTEM SET micro_block_merge_verify_level=0;
ALTER SYSTEM SET freeze_trigger_percentage=50;
ALTER SYSTEM SET sys_bkgd_io_low_percentage=70;
ALTER SYSTEM SET _mini_merge_concurrency=5;
ALTER SYSTEM SET weak_read_version_refresh_interval=0;
ALTER SYSTEM SET _ob_enable_prepared_statement=true;
ALTER SYSTEM SET _clog_aggregation_buffer_amount=4 tenant=all;
ALTER SYSTEM SET enable_early_lock_release=false tenant=all;
ALTER SYSTEM SET enable_perf_event=false;
ALTER SYSTEM SET enable_auto_leader_switch=false;
ALTER SYSTEM SET weak_read_version_refresh_interval='5s';
OBProxy 参数
ALTER PROXYCONFIG SET enable_ob_protocol_v2=false;
ALTER PROXYCONFIG SET proxy_mem_limited='10G';
ALTER PROXYCONFIG SET enable_qos=false;
ALTER PROXYCONFIG SET slow_proxy_process_time_threshold='500ms';
租户配置
ALTER SYSTEM SET _clog_aggregation_buffer_amount=4;
ALTER SYSTEM SET _flush_clog_aggregation_buffer_timeout='1ms';
ALTER SYSTEM SET weak_read_version_refresh_interval='5s';
ALTER SYSTEM SET enable_monotonic_weak_read=false;
SET GLOBAL binlog_row_image='MINIMAL';
Kernal 配置
sudo sysctl kernel.sched_migration_cost_ns=0

测试过程

注意:

lua脚本默认路径:/usr/sysbench/share/sysbench/

在实测时:–warmup-time=5这个参数不可用,这个参数时预热时间,本次省略

1.初始化环境。

sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=10000000 --warmup-time=5 ./oltp_read_write.lua cleanup

2.导入 30 张表,每张表包含 1000 w 数据。

sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=10000000  --threads=20 ./oltp_read_write.lua prepare

3.预热 10 s。

sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=10000000  --threads=1000 --time=10 ./oltp_point_select.lua run 

4.执行每一个 case 执行 30 s,避免执行过程中发生转储。

sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=1000000  --threads=1000 ./oltp_point_select.lua run
sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=1000000  --threads=1000 ./oltp_read_only.lua run
sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=1000000  --threads=1000 --rand-type=uniform  ./oltp_read_write.lua run
sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=1000000  --threads=1000 ./oltp_insert.lua run
sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=1000000  --threads=1000 ./oltp_update_non_index.lua run
sysbench --mysql-host=127.0.0.1 --mysql-port=2828 --mysql-user=root@tt1 --mysql-db=test --report-interval=3 --time=30 --threads=1000 --db-ps-mode=disable --percentile=99 --auto_inc=on --tables=30 --mysql-ignore-errors=1062 --table_size=1000000  --threads=1000 ./oltp_write_only.lua run

测试结果

分布式场景 ( primary zone = ‘RANDOM’ ),这里只举一例(read_write),用来说明各统计信息的含义。

SQL statistics:
    queries performed:
        read:          1173858   # 执行的读操作数量
        write:         335388   # 执行的写操作数量
        other:         167694    # 执行的其它操作数量
        total:         1676940
    transactions:      83847   (2766.99 per sec.)    # 执行事务的平均速率
    queries:           1676940  (55339.80 per sec.)   # 平均每秒能执行多少次查询
    ignored errors:    0      (0.00 per sec.)
    reconnects:        0      (0.00 per sec.)

General statistics:
    total time:                  30.3008s     # 总消耗时间
    total number of events:      83847         # 总请求数量(读、写、其它)

Latency (ms):
         min:                            134.14
         avg:                           359.09
         max:                          822.37
         99th percentile:              623.33    # 采样计算的平均延迟
         sum:                        30108634.12

Threads fairness:
    events (avg/stddev):           83.8470/0.39
    execution time (avg/stddev):   30.1086/0.07

测试结果统计表:

项目 read write insert write only read only point select update_non_index update_index
qps 55339.80 14728.48 72092.68 66955.33 143621.07 15545.55 15819.75
Latency(ms)avg 359.09 67.48 82.73 237.84 7.37 64.02 62.90
Latency(ms)(99th percentile) 623.33 101.13 125.52 287.38 11.04 102.97 82.96

上一篇 Linux上首款太空剧场级游戏'The Mandate'发布预告片!!
下一篇 戴文的Linux内核专题:06 内核配置(2)