Sysbench 简介
Sysbench 是一个基于 LuaJIT 的可编写脚本的多线程基准测试工具,可以执行 CPU、内存、线程、IO、数据库等方面的性能测试,常用于评估测试各种不同系统参数下的数据库负载情况,不需要修改源码,通过自定义 Lua 脚本就可以实现不同业务类型的测试。
测试方案
OceanBase 集群部署规模为 1:1:1。部署成功后,新建执行 Sysbench 测试的租户及用户(
sys租户是管理集群的内置系统租户,请勿直接使用该租户进行测试),将租户的PRIMARY_ZONE设置为RANDOM。启动 Sysbench 客户端,进行
point_select、read_write、read_only等测试。每轮测试
--time设置为 60s,线程数取值可以为900/1200/1500/1800。测试规格如下所示:
--mysql-db=test --mysql-host=$obproxy_ip(填写 OBProxy 的 IP) --table_size=1000000 --tables=30 --threads=900/1200/1500/1800 --report-interval=10 --time=60 --db-ps-mode=disable
测试环境
硬件配置
项目类型 内存 CPU OceanBase 数据库 3 台 * 262 G 3 台 * 32 核 Sysbench 1 台 * 262 G 1 台 * 32 核 ODP 1 台 * 262 G 1 台 * 32 核 租户规格
CREATE RESOURCE UNIT box1 MAX_CPU 26, MAX_MEMORY 220554378624, MAX_IOPS 128, MAX_DISK_SIZE 536870912, MAX_SESSION_NUM 64, MIN_CPU=26, MIN_MEMORY=220554378624, MIN_IOPS=128; CREATE RESOURCE POOL fpool UNIT='box1', UNIT_NUM=1, ZONE_LIST=('zone1','zone2','zone3'); CREATE TENANT tt1 RESOURCE_POOL_LIST=('fpool'), PRIMARY_ZONE='RANDOM', LOCALITY='F@zone1,F@zone2,F@zone3' SET ob_compatibility_mode='mysql',ob_tcp_invited_nodes='%';说明
- 您需根据自身数据库的硬件配置进行动态调整。详细操作,参考 修改租户。
- 进行性能测试时,租户需配置最大可用资源。
软件版本
项目类型 软件版本及型号 OceanBase 数据库 V3.2.4 ODP V3.1.0 Sysbench 1.0.20 OS CentOS Linux release 7.9.2009 (Core) CPU Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
环境信息
操作系统信息
$cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
$uname -a
Linux testdriver 3.10.0-1160.24.1.el7.x86_64 #1 SMP Thu Apr 8 19:51:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
CPU 信息
$cat /proc/cpuinfo
processor : 31
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
stepping : 4
microcode : 0x1
cpu MHz : 2499.992
cache size : 33792 KB
physical id : 0
siblings : 32
core id : 31
cpu cores : 32
apicid : 47
initial apicid : 47
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips : 4999.98
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
内存信息
$free -m
total used free shared buffers cached
Mem: 262144 39697 222446 0 0 19948
-/+ buffers/cache: 19749 242394
Swap: 0 0 0
软件信息
OBServer
$./observer -V
observer (OceanBase 3.2.3)
REVISION: 20220125174436-b765b7557c36d62bcd42597142fe0ee34bd21f6e
BUILD_BRANCH: 3_2_x_release
BUILD_TIME: Jan 25 2022 17:56:14
BUILD_FLAGS: RelWithDebInfo
BUILD_INFO:
Copyright (c) 2011-2020 Alipay Inc.
OBProxy
$./obproxy -V
obproxy (OceanBase 3.1.0 4358.el6)
REVISION: 4358-local-9a6209a5e7db8e692882782ce67cf6359f03c3ab
BUILD_TIME: May 5 2021 23:00:26
BUILD_FLAGS: -g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wunused-parameter -Wformat -Wconversion -Wno-deprecated -Wno-invalid-offsetof -finline-functions -fno-strict-aliasing -mtune=core2 -Wno-psabi -Wno-sign-compare -DGCC_52 -DUSE_POSIX_FALLOCATE -DSUPPORT_SSE4_2 -DHAVE_SCHED_GETCPU -DHAVE_REALTIME_COARSE -DOB_HAVE_EVENTFD -DHAVE_FALLOCATE -DHAVE_MINIDUMP -Werror
Copyright (c) 2007-2020 Alipay Inc.
Sysbench
$./sysbench --version
sysbench 1.0.20
测试内容
配置参数
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
安装 Sysbench
按照以下步骤安装 Sysbench。
下载 Sysbench。
详细信息参考 Sysbench 下载地址。
解压 Sysbench。
unzip ./1.0.20.zip编译 Sysbench。
进入 Sysbench 解压后的目录,运行以下命令编译 Sysbench:
[wieck@localhost ~] $ cd sysbench-1.0.20 [wieck@localhost sysbench-1.0.20] $./autogen.sh [wieck@localhost sysbench-1.0.20] $./configure --prefix=/usr/sysbench/ --with-mysql-includes=/usr/include/mysql/ --with-mysql-libs=/usr/lib64/mysql/ --with-mysql [wieck@localhost sysbench-1.0.20] $make [wieck@localhost sysbench-1.0.20] $make install [wieck@localhost sysbench-1.0.20] $cp -r /usr/sysbench/share/sysbench/* /usr/sysbench/bin/参数说明:
参数名 说明 --prefix 指定 Sysbench 的安装目录。 --with-mysql-includes 指定 mysql 的 includes 目录。 --with-mysql-libs 指定 mysql 的 lib 目录。 --with-mysql Sysbench 默认支持 MySQL 运行以下命令,验证 Sysbench 是否安装成功:
[wieck@localhost sysbench-1.0.20] $./src/sysbench --help如果返回以下信息,则 Sysbench 安装成功。
Usage: sysbench [options]... [testname] [command] Commands implemented by most tests: prepare run cleanup help
测试过程
初始化环境。
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 ./oltp_read_write.lua cleanup导入 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预热 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执行每一个 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=10000000 --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=10000000 --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=10000000 --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=10000000 --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=10000000 --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=10000000 --threads=1000 ./oltp_write_only.lua run
测试结果
分布式场景 ( primary zone = 'RANDOM' )
| read write | write only | read only | point select | update_non | update | |
| qps | 230852.57 | 213142.05 | 346962.70 | 489069.73 | 182381.57 | 171456.98 |
| rt | 217.63 | 51.12 | 47.26 | 2.96 | 7.46 | 8.50 |