Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: Tidb如何应对秒杀场景
To improve efficiency, please provide the following information. A clear problem description will help resolve the issue faster:
【TiDB Usage Environment】
【Overview】 Scenario + Problem Overview
In a flash sale scenario with a large number of sessions modifying a single row of data, such as the stock of a particular product or the total amount of a financial product, TiDB performs poorly.
【Background】 Actions Taken
Rate limiting on the application side.
【Phenomenon】 Business and Database Phenomenon
Version 2.0 uses optimistic locking, resulting in a large number of failed transactions.
【Problem】 Current Issue
I would like to know how TiDB should design the table structure and handle this scenario under pessimistic locking from version 4.0 onwards to achieve higher concurrency when modifying a single row of data.
【Business Impact】
【TiDB Version】
【Application Software and Version】
【Attachments】 Relevant Logs and Configuration Information
- TiUP Cluster Display Information
- TiUP Cluster Edit Config Information
Monitoring (https://metricstool.pingcap.com/)
- TiDB-Overview Grafana Monitoring
- TiDB Grafana Monitoring
- TiKV Grafana Monitoring
- PD Grafana Monitoring
- Corresponding Module Logs (including logs from 1 hour before and after the issue)
For questions related to performance optimization or troubleshooting, please download and run the script. Please select all and copy-paste the terminal output results for upload.