DAS provides the SQL throttling feature. You can use SQL throttling to control the amount of database access requests and concurrent SQL statements to ensure service availability. This topic describes how to use SQL throttling. ApsaraDB RDS for MySQL is used as an example.
SQL throttling is applicable only to ApsaraDB RDS for MySQL 5.6, ApsaraDB RDS for 5.7, and PolarDB MySQL 5.6.
Most applications are dependent on databases. To alleviate pressure on databases, you can perform throttling operations at the application side. However, in the following scenarios, you must configure throttling at the database side.
|Sharp rise in concurrent SQL statements||Cache penetration or abnormal calls may result in unexpected rise in concurrent SQL statements.|
|SQL statements that result in data skew||If a large amount of data is queried during a sale promotion, the overall system will be affected.|
|Tables that are not indexed||If a large number of SQL statements are executed on new database tables that are not indexed, the system will slow down and normal services will be affected. |
Go to the Instance Sessions page. For more information about how to go to the Instance Sessions page, see View instance sessions.
On the Instance Sessions page, click SQL Throttling.
In the SQL Throttling dialog box that appears, click Create.
In the Create SQL Throttling Rule dialog box that appears, configure the parameters described in the following table. Then, click Create.
Parameter Description SQL Type Select an SQL statement type. Valid values: SELECT, UPDATE, and DELETE. Max Concurrency The maximum number of concurrent SQL statements. The throttling rule will be triggered when the number of SQL statements that contain a specific keyword reaches the value specified for this parameter. If this parameter is set to 0, all requests that contain the keyword are denied. Throttling Duration The duration within which the SQL throttling rule takes effect. SQL throttling is used only in emergencies. We recommend that you set the throttling duration based on your actual requirements and disable SQL throttling when it is no longer needed. SQL Keywords The keywords that SQL statements on which SQL throttling takes effect contain. Separate multiple keywords with tildes (~).
After the SQL throttling rule is created, the application will receive the “query execution was interrupted” error with the 1317 error code if the application uses SQL statements that contain the specified keywords.
After the SQL throttling rule is created, you can view the status of the rule in the SQL throttling list.
If you want to modify an SQL throttling rule or disable it before the specified throttling duration expires, you can click Close or Edit in the Actions column.