SQL Rate Limiting
SQL Rate Limiting is a crucial technique for throttling the number of requests for specific SQL queries, especially during traffic peaks. It is often employed as a means to protect the backend database. With the SQL Rate Limiting feature in a database proxy, you can promptly restrict the concurrency of certain SQL queries, ensuring the normal operation of the database and preventing overloads, even in extreme situations. Here are some common scenarios where SQL Rate Limiting is useful:
- Cache penetration or attacks on a business interface leading to a sudden surge in concurrent requests for a specific SQL query.
- SQL queries that retrieve a massive amount of data, causing a drop in database performance due to excessive requests.
- Incorrectly configured indexes or overly complex SQL queries that consume a significant amount of database CPU resources.
Access SQL Rate Limiting
Click on 'Details' for the proxy to enter the details page.
On the right side of the Database Proxy details page, you will find the SQL Rate Limiting templates. Click on the 'Edit' button to access the SQL Rate Limiting configuration page.
At the top left corner of the page, there is a 'Create Template' button. Clicking on it will bring up a dialog to create a rate limiting template.
Create Rate Limiting Templat
On the Rate Limiting Template page, you can set rate limits for four types of SQL statements: SELECT, UPDATE, INSERT, and DELETE.
We can input the corresponding SQL statements based on the actual business scenario. The system will automatically replace variables ('hello world') with placeholders to accommodate incoming parameters.
After configuring the rate limiting thresholds, click 'Confirm,' and you will see that the rule has been added to the list page.
Update Rate Limiting Template Thresholds
After creating the rate limiting template, you can modify the rate limiting thresholds. Click on the 'Edit' button next to the rate limit value, and a small pop-up box will appear at the top, allowing you to set the thresholds.
Disable and Enable Rate Limiting Template
You can disable and enable rate limiting templates by using the small toggle button on the right-hand side. This button allows you to toggle the status of the rate limiting template between disabled and enabled.
Delete Rate Limiting Template
You can also delete rate limiting templates, and once deleted, they will not be retained.