[TiDB Usage Environment] Production / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Enter TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots / Logs / Monitoring]
Currently, when our TiDB database performs batch insert operations, if another service concurrently reads the database content, the QPS of TiDB increases, which in turn affects the performance of the inserts. Can TiDB perform read-write separation? Can insert operations and data reads be handled by different servers without affecting each other’s performance?
From the TiDB layer (computing layer), it is possible, but TiKV cannot achieve this for now. Read-write separation in MySQL essentially refers to master-slave read-write separation. The TiDB architecture itself is distributed, with read and write operations evenly distributed across three machines at the KV layer. Theoretically, this model is superior to the master-slave model. If you insist on having read-write separation similar to MySQL’s master-slave setup, where read and write transactions do not affect each other, you could use two clusters with CDC synchronization, one for writing and one for reading.
First of all, TiDB is a distributed database. There is no need for read-write separation; you should consider whether the performance bottleneck is due to PD or TiDB. Configuring read-write separation should not be considered. In scenarios where the database is read-heavy, it is generally optimized into a cache cluster.
You can use the follow read feature, and limit the leader to a few servers. If you want to know how to enable the feature and set the limits, you can search on the official website.
TiDB itself is a distributed database with a separation of storage and computation, which has requirements for hardware resources. Adding additional sharding for read-write separation would result in significant hardware resource investment. It is recommended to design the data table structure well to avoid write hotspots, as the mutual impact should not be too significant. Alternatively, you can also use CDC to synchronize to other databases.
When performing batch insert operations in the TiDB database, if another service is concurrently reading the database content, the QPS of TiDB will increase.
To solve the problem, you can start from the problem itself, such as the insertion speed, how the insertion is done (different insertion methods have different performance impacts), and which resources have bottlenecks during insertion, etc. See if it is possible to optimize first.