Sign InTry Free

TiDB on Kubernetes Sysbench Performance Test

Since the release of TiDB Operator GA, more users begin to deploy and manage the TiDB cluster on Kubernetes using TiDB Operator. In this report, an in-depth and comprehensive test of TiDB has been conducted on GKE, which offers insight into the influencing factors that affect the performance of TiDB on Kubernetes.

Test purpose

  • To test the performance of TiDB on a typical public cloud platform
  • To test the influences that the public cloud platform, network, CPU and different Pod networks have on the performance of TiDB

Test environment

Version and configuration

In this test:

  • TiDB 3.0.1 and TiDB Operator 1.0.0 are used.
  • Three instances are deployed for PD, TiDB, and TiKV respectively.
  • Each component is configured as below. Components not configured use the default values.

PD:

[log] level = "info" [replication] location-labels = ["region", "zone", "rack", "host"]

TiDB:

[log] level = "error" [prepared-plan-cache] enabled = true [tikv-client] max-batch-wait-time = 2000000

TiKV:

log-level = "error" [server] status-addr = "0.0.0.0:20180" grpc-concurrency = 6 [readpool.storage] normal-concurrency = 10 [rocksdb.defaultcf] block-cache-size = "14GB" [rocksdb.writecf] block-cache-size = "8GB" [rocksdb.lockcf] block-cache-size = "1GB" [raftstore] apply-pool-size = 3 store-pool-size = 3

TiDB parameter configuration

set global tidb_hashagg_final_concurrency=1; set global tidb_hashagg_partial_concurrency=1; set global tidb_disable_txn_auto_retry=0;

Hardware recommendations

Machine types

For the test in single AZ (Available Zone), the following machine types are chosen:

ComponentInstance typeCount
PDn1-standard-43
TiKVc2-standard-163
TiDBc2-standard-163
Sysbenchc2-standard-301

For the test (2019.08) where the result in multiple AZs is compared with that in a single AZ, the c2 machine is not simultaneously available in three AZs within the same Google Cloud region, so the following machine types are chosen:

ComponentInstance typeCount
PDn1-standard-43
TiKVn1-standard-163
TiDBn1-standard-163
Sysbenchn1-standard-163

Sysbench, the pressure test platform, has a high demand on CPU in the high concurrency read test. Therefore, it is recommended that you use machines with high configuration and multiple cores so that the test platform does not become the bottleneck.

Disk

The NVMe disks on GKE are still in the Alpha phase, so it requires special application to use them and is not for general usage. In this test, the iSCSI interface type is used for all local SSD disks. With reference to the official recommendations, the discard,nobarrier option has been added to the mounting parameter. Below is a complete example:

sudo mount -o defaults,nodelalloc,noatime,discard,nobarrier /dev/[LOCAL_SSD_ID] /mnt/disks/[MNT_DIR]

Network

GKE uses a more scalable and powerful VPC-Native mode as its network mode. In the performance comparison, TiDB is tested with Kubernetes Pod and Host respectively.

CPU

  • In the test on a single AZ cluster, the c2-standard-16 machine mode is chosen for TiDB/TiKV.
  • In the comparison test on a single AZ cluster and on multiple AZs cluster, the c2-standard-16 machine type cannot be simultaneously adopted in three AZs within the same Google Cloud region, so n1-standard-16 machine type is chosen.

Operation system and parameters

GKE supports two operating systems: COS (Container Optimized OS) and Ubuntu. The Point Select test is conducted on both systems and the results are compared. Other tests are only conducted on Ubuntu.

The core is configured as below:

sysctl net.core.somaxconn=32768 sysctl vm.swappiness=0 sysctl net.ipv4.tcp_syncookies=0

The maximum number of files is configured as 1000000.

Sysbench version and operating parameters

In this test, the version of sysbench is 1.0.17.

Before the test, the prewarm command of oltp_common is used to warm up data.

Initialization

sysbench \ --mysql-host=${tidb_host} \ --mysql-port=4000 \ --mysql-user=root \ --mysql-db=sbtest \ --time=600 \ --threads=16 \ --report-interval=10 \ --db-driver=mysql \ --rand-type=uniform \ --rand-seed=$RANDOM \ --tables=16 \ --table-size=10000000 \ oltp_common \ prepare

${tidb_host} is the address of the TiDB database, which is specified according to actual test needs. For example, Pod IP, Service domain name, Host IP, and Load Balancer IP (the same below).

Warming-up

sysbench \ --mysql-host=${tidb_host} \ --mysql-port=4000 \ --mysql-user=root \ --mysql-db=sbtest \ --time=600 \ --threads=16 \ --report-interval=10 \ --db-driver=mysql \ --rand-type=uniform \ --rand-seed=$RANDOM \ --tables=16 \ --table-size=10000000 \ oltp_common \ prewarm

Pressure test

sysbench \ --mysql-host=${tidb_host} \ --mysql-port=4000 \ --mysql-user=root \ --mysql-db=sbtest \ --time=600 \ --threads=${threads} \ --report-interval=10 \ --db-driver=mysql \ --rand-type=uniform \ --rand-seed=$RANDOM \ --tables=16 \ --table-size=10000000 \ ${test} \ run

${test} is the test case of sysbench. In this test, oltp_point_select, oltp_update_index, oltp_update_no_index, and oltp_read_write are chosen as ${test}.

Test report

In single AZ

Pod Network vs Host Network

Kubernetes allows Pods to run in Host network mode. This way of deployment is suitable when a TiDB instance occupies the whole machine without causing any Pod conflict. The Point Select test is conducted in both modes respectively.

In this test, the operating system is COS.

Pod Network:

ThreadsQPS95% latency(ms)
150246386.440.95
300346557.391.55
600396715.662.86
900407437.964.18
1200415138.005.47
1500419034.436.91

Host Network:

ThreadsQPS95% latency(ms)
150255981.111.06
300366482.221.50
600421279.842.71
900438730.813.96
1200441084.135.28
1500447659.156.67

QPS comparison:

Pod vs Host Network

Latency comparison:

Pod vs Host Network

From the images above, the performance in Host network mode is slightly better than that in Pod network.

Ubuntu vs COS

GKE provides Ubuntu and COS for each node. In this test, the Point Select test of TiDB is conducted on both systems.

The network mode is Host.

COS:

ThreadsQPS95% latency(ms)
150255981.111.06
300366482.221.50
600421279.842.71
900438730.813.96
1200441084.135.28
1500447659.156.67

Ubuntu:

ThreadsQPS95% latency(ms)
150290690.510.74
300422941.171.10
600476663.442.14
900484405.993.25
1200489220.934.33
1500489988.975.47

QPS comparison:

COS vs Ubuntu

Latency comparison:

COS vs Ubuntu

From the images above, TiDB performs better on Ubuntu than on COS in the Point Select test.

Kubernetes Service vs Google Cloud LoadBalancer

After TiDB is deployed on Kubernetes, there are two ways of accessing TiDB: via Kubernetes Service inside the cluster, or via Load Balancer IP outside the cluster. TiDB is tested in both ways.

In this test, the operating system is Ubuntu and the network mode is Host.

Service:

ThreadsQPS95% latency(ms)
150290690.510.74
300422941.171.10
600476663.442.14
900484405.993.25
1200489220.934.33
1500489988.975.47

Load Balancer:

ThreadsQPS95% latency(ms)
150255981.111.06
300366482.221.50
600421279.842.71
900438730.813.96
1200441084.135.28
1500447659.156.67

QPS comparison:

Service vs Load Balancer

Latency comparison:

Service vs Load Balancer

From the images above, TiDB performs better when accessed via Kubernetes Service than accessed via Google Cloud Load Balancer in the Point Select test.

n1-standard-16 vs c2-standard-16

In the Point Select read test, TiDB's CPU usage exceeds 1400% (16 cores) while TiKV's CPU usage is about 1000% (16 cores).

The test compares the TiDB performance on general machine types with that on machines which are optimized for computing. In this performance comparison, the frequency of n1-standard-16 is about 2.3G, and the frequency of c2-standard-16 is about 3.1G.

In this test, the operating system is Ubuntu and the Pod network is Host. TiDB is accessed via Kubernetes Service.

n1-standard-16:

ThreadsQPS95% latency(ms)
150203879.491.37
300272175.712.3
600287805.134.1
900295871.316.21
1200294765.838.43
1500298619.3110.27

c2-standard-16:

ThreadsQPS95% latency(ms)
150290690.510.74
300422941.171.10
600476663.442.14
900484405.993.25
1200489220.934.33
1500489988.975.47

QPS comparison:

n1-standard-16 vs c2-standard-16

Latency comparison:

n1-standard-16 vs c2-standard-16

OLTP and other tests

The Point Select test is conducted on different operating systems and in different network modes, and the test results are compared. In addition, other tests in the OLTP test set are also conducted on Ubuntu in Host network mode where the TiDB cluster is accessed via Kubernetes Service.

OLTP Update Index

ThreadsQPS95% latency(ms)
1506726.5930.26
30011067.5536.24
60017358.4648.34
90021025.2364.47
120022121.8790.78
150022650.13118.92

OLTP Update Index OLTP Update Index

OLTP Update Non Index

ThreadsQPS95% latency(ms)
1509230.6023.95
30016543.6354.83
60023551.0161.08
90031100.1065.65
120033942.6054.83
150042603.13125.52

OLTP Update No Index OLTP Update No Index

OLTP Read Write

ThreadsQPS95% latency(ms)
15060732.8469.29
30091005.9890.78
600110517.67167.44
900119866.38235.74
1200125615.89282.25
1500128501.34344.082

OLTP Read Write OLTP Read Write

Performance comparison between single AZ and multiple AZs

The network latency on communication across multiple AZs in Google Cloud is slightly higher than that within the same zone. In this test, machines of the same configuration are used in different deployment plans under the same standard. The purpose is to learn how the latency across multiple AZs might affect the performance of TiDB.

Single AZ:

ThreadsQPS95% latency(ms)
150203879.491.37
300272175.712.30
600287805.134.10
900295871.316.21
1200294765.838.43
1500298619.3110.27

Multiple AZs:

ThreadsQPS95% latency(ms)
150141027.101.93
300220205.852.91
600250464.345.47
900257717.417.70
1200258835.2410.09
1500280114.0012.75

QPS comparison:

Single Zonal vs Regional

Latency comparison:

Single Zonal vs Regional

From the images above, the impact of network latency goes down as the concurrency pressure increases. In this situation, the extra network latency is no longer the main bottleneck of performance.

Conclusion

This is a test of TiDB using sysbench running on Kubernetes deployed on a typical public cloud platform. The purpose is to learn how different factors might affect the performance of TiDB. On the whole, these influencing factors include the following items:

  • In the VPC-Native mode, TiDB performs slightly better in Host network than in Pod network. (The difference, ~7%, is measured in QPS. Performance differences caused by the factors below are also measured by QPS.)
  • In Host network, TiDB performs better (~9%) in the read test on Ubuntu provided by Google Cloud than on COS.
  • The TiDB performance is slightly lower (~5%) if it is accessed outside the cluster via Load Balancer.
  • Increased latency among nodes in multiple AZs has a certain impact on the TiDB performance (30% ~ 6%; the impact diminishes as the concurrent number increases).
  • The QPS performance is greatly improved (50% ~ 60%) if the Point Select read test is conducted on machines of computing type (compared with general types), because the test mainly consumes CPU resources.

Was this page helpful?

Download PDFRequest docs changesAsk questions on DiscordEdit this page
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.