Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 大并发下的连接异常
The underlying database of a certain online teaching system uses TiDB (6.1). Before class, students scan a code to check in (which requires accessing multiple databases), and it was found that the connection time was excessively long, resulting in many login timeouts. Through full-link analysis, it was observed that connecting to TiDB took an excessively long time. Due to the urgency of the situation, some databases were migrated to MySQL. After reopening the system, connections were normal after migrating to MySQL, but those remaining in TiDB still experienced connection timeouts.
The following checks were performed on TiDB:
- Host resources and system parameters are configured according to official recommendations.
- Load balancing strategy is set to least connections.
- The number of compute nodes was expanded to 5.
- There are no issues with network firewalls, database auditing, or bandwidth.
- Unnecessary test data has been cleaned up.
- Optimized TiDB performance parameters:
- tidb_mem_quota_query is set to 4G;
- max_execution_time is set to 0;
- tidb_mem_oom_action is set to CANCEL;
- server-memory-quota is set to 32G;
- tidb_replica_read is set to leader-and-follower;
- max-server-connections is set to 0;
- token-limit is set to 1000;
- max-procs is set to 0;
- The database disk throughput reaches 4000 or above; database read/write performance was tested using sysbench.
- There are no relevant errors in the TiDB and TiKV logs.
I would like to ask everyone, what other directions should be investigated? Thank you!