当前位置:网站首页>How to test tidb with sysbench
How to test tidb with sysbench
2022-07-02 15:08:00 【Tianxiang shop】
It is recommended to use Sysbench 1.0 Or later updates , Can be found in Sysbench Release 1.0.14 page download .
Test plan
TiDB To configure
Raise the log level , You can reduce the number of print logs , Yes TiDB Has a positive impact on performance . Specific in TiUP Add to profile :
server_configs: tidb: log.level: "error"
TiKV To configure
elevated TiKV The log level of is also conducive to improving performance .
TiKV There are multiple clusters Column Family, Include Default CF、Write CF and LockCF, It is mainly used to store different types of data . about Sysbench test , Need to pay attention to Default CF and Write CF, Importing data Column Family stay TiDB The proportion in the cluster is fixed . The ratio is :
Default CF : Write CF = 4 : 1
stay TiKV It needs to be configured according to the memory size of the machine RocksDB Of block cache, To make the most of memory . With 40 GB Deploy a virtual machine in memory TiKV For example , Its block cache The recommended configuration is as follows :
server_configs: tikv: log-level: "error" rocksdb.defaultcf.block-cache-size: "24GB" rocksdb.writecf.block-cache-size: "6GB"
You can also use sharing block cache How to set :
server_configs: tikv: storage.block-cache.capacity: "30GB"
More detailed TiKV For parameter tuning, please refer to TiKV Memory parameter performance tuning .
Testing process
Be careful
The tests in this document do not use such as HAproxy And other load balancing tools . stay TiDB On a single node Sysbench test , And add the results . Load balancing tools and different version parameters also affect performance .
Sysbench To configure
The following is a Sysbench Sample configuration file :
mysql-host={TIDB_HOST} mysql-port=4000 mysql-user=root mysql-password=password mysql-db=sbtest time=600 threads={8, 16, 32, 64, 128, 256} report-interval=10 db-driver=mysql
Its parameters can be adjusted according to actual needs , among TIDB_HOST by TiDB server Of IP Address ( Multiple addresses cannot be written in the configuration file ),threads Is the number of concurrent connections in the test , Can be found in “8, 16, 32, 64, 128, 256” Medium adjustment , When importing data , It is recommended to set threads = 8 perhaps 16. After the adjustment , Save the file with the name config The file of .
The configuration file Reference examples are as follows :
mysql-host=172.16.30.33 mysql-port=4000 mysql-user=root mysql-password=password mysql-db=sbtest time=600 threads=16 report-interval=10 db-driver=mysql
Data import
Be careful
If TiDB The optimistic transaction model is enabled ( The default is pessimistic lock mode ), When concurrency conflicts are found , The transaction will be rolled back . take tidb_disable_txn_auto_retry Set to off The automatic retry mechanism after transaction conflict will be enabled , Try to avoid transaction conflict and error reporting Sysbench The problem of program exit .
Before data import , Need to be right TiDB Make simple settings . stay MySQL Execute the following commands in the client :
set global tidb_disable_txn_auto_retry = off;
Then exit the client .
Restart MySQL The client performs the following SQL sentence , Create database sbtest:
create database sbtest;
adjustment Sysbench The order in which the script creates the index .Sysbench according to “ Build table -> insert data -> Create index ” Import data in order . about TiDB for , This method will take more import time . You can speed up the data import by adjusting the order .
Suppose you use Sysbench Version is 1.0.14, You can modify it in the following two ways :
- Download directly as TiDB Modified oltp_common.lua file , Cover
/usr/share/sysbench/oltp_common.luafile . - take
/usr/share/sysbench/oltp_common.luaOf the 235 Go to the first place 240 Move line to 198 After that .
Be careful
This operation is optional , Only the data import time is saved .
The command line type the following command , Start importing data ,config The file is the file configured in the previous step :
sysbench --config-file=config oltp_point_select --tables=32 --table-size=10000000 prepare
Data preheating and statistical information collection
Data preheating can load the data in the disk into the memory block cache in , The preheated data greatly improves the overall performance of the system , It is recommended to warm up the data every time the cluster is restarted .
Sysbench 1.0.14 There is no function of data preheating , Therefore, it is necessary to preheat the data manually . If you use updated Sysbench edition , You can use the built-in preheating function .
With Sysbench A table in sbtest7 For example , The implementation is as follows SQL Statement to warm up data :
SELECT COUNT(pad) FROM sbtest7 USE INDEX (k_7);
Statistical information collection helps the optimizer choose a more accurate execution plan , Can pass analyze Command to collect tables sbtest Statistical information , Every table needs statistics .
ANALYZE TABLE sbtest7;
Point select The test command
sysbench --config-file=config oltp_point_select --tables=32 --table-size=10000000 run
Update index The test command
sysbench --config-file=config oltp_update_index --tables=32 --table-size=10000000 run
Read-only The test command
sysbench --config-file=config oltp_read_only --tables=32 --table-size=10000000 run
common problem
Under high concurrent pressure ,TiDB、TiKV The configuration is reasonable , Why is the overall performance still low ?
This situation may be related to the use of proxy of . You can try directly to single TiDB compression , Use the sum result proxy To compare the situation of .
With HAproxy For example .nbproc Parameter can increase its maximum number of started processes , Newer versions of HAproxy And support nbthread and cpu-map etc. . These can reduce the adverse impact on its performance .
Under high concurrent pressure , Why? TiKV Of CPU Utilization is still very low ?
TiKV Although the whole CPU Low , But some modules CPU It may have reached a high utilization rate .
TiKV Other modules of , Such as storage readpool、coprocessor and gRPC The maximum concurrency limit of can pass TiKV The configuration file of .
adopt Grafana Of TiKV Thread CPU The monitoring panel can observe its actual utilization . If there is a multi-threaded module bottleneck , It can be adjusted by increasing the concurrency of this module .
Under high concurrent pressure ,TiKV Also not reached CPU Use bottleneck , Why? TiDB Of CPU Utilization is still very low ?
On some high-end devices , It uses NUMA Architecturally CPU, Span CPU Accessing remote memory will greatly reduce performance .TiDB By default, all servers will be used CPU,goroutine Inevitably, there will be cross CPU Memory access .
therefore , It is suggested that NUMA On the architecture server , Deploy n individual TiDB(n = NUMA CPU The number of ), At the same time TiDB Of max-procs The value of the variable is set to and NUMA CPU Same number of cores for .
边栏推荐
- Reuse and distribution
- LeetCode_滑动窗口_中等_395.至少有 K 个重复字符的最长子串
- [C language] explain the initial and advanced levels of the pointer and points for attention (1)
- XML配置文件
- Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
- 【题解】Educational Codeforces Round 82
- mathML转latex
- Some Chinese character codes in the user privacy agreement are not standardized, which leads to the display of garbled codes on the web page. It needs to be found and handled uniformly
- Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
- LeetCode 2310. The number of digits is the sum of integers of K
猜你喜欢

kibana 基础操作

CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E

IE 浏览器正式退休

It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen

【NOI模拟赛】伊莉斯elis(贪心,模拟)

Full of knowledge points, how to use JMeter to generate encrypted data and write it to the database? Don't collect it quickly
![[C language] explain the initial and advanced levels of the pointer and points for attention (1)](/img/61/1619bd2e959bae1b769963f66bab4e.png)
[C language] explain the initial and advanced levels of the pointer and points for attention (1)
![[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment](/img/e1/c8e81570ab78de1e488a611c25ebb9.png)
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment

MFC timer usage

fatal: unsafe repository is owned by someone else 的解决方法
随机推荐
[c voice] explain the advanced pointer and points for attention (2)
TiDB混合部署拓扑
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
Factal: Unsafe repository is owned by someone else Solution
Implement a server with multi process concurrency
info [email protected]: The platform “win32“ is incompatible with this module.
Large top heap, small top heap and heap sequencing
C语言中的算术运算及相关练习题
JMeter script parameterization
MFC timer usage
Fundamentals of software testing
使用 TiUP 部署 TiDB 集群
C#代码审计实战+前置知识
MFC CString to char*
Wechat applet uses towxml to display formula
C#延时、在线程中开启定时器、获取系统时间
2021-2022学年编译原理考试重点[华侨大学]
C# 线程传参
[development environment] install the visual studio community 2013 development environment (download the installation package of visual studio community 2013 with update 5 version)
关于网页中的文本选择以及统计选中文本长度