Introduction to RDS for MySQL Database Proxies
Context
In read-intensive workloads, a single DB instance may be unable to handle the read pressure. If this happens, performance deteriorates and, under peak loads, workloads will suffer.
To scale the read capacity of your instance, RDS for MySQL allows you to create read replicas and enable read/write splitting. With read/write splitting enabled, write requests are routed to the primary instance and read requests to read replicas. The read pressure on the primary instance is reduced, and database performance improves.
Function Description
A database proxy enables read and write requests to be automatically routed through a read/write splitting address. You can enable read/write splitting after read replicas are created. Write requests are automatically routed to the primary DB instance and read requests are routed to read replicas by user-defined weights.
Basic Concepts
- Proxy address
After a database proxy, you can view the proxy address on the Database Proxy page. The database proxy sends write requests to the primary instance and read requests to read replicas through this address.
- Routing policy
RDS for MySQL database proxies support weighted and load balancing routing policies.
- Weighted: Read requests are routed based on the read weights you specify.
- Load balancing: Read requests are routed to database nodes with fewer active connections. With this policy enabled, you do not need to configure the weights of nodes.
For more information about routing policies, see Configuring the Delay Threshold and Routing Policy.
Constraints
- To use read/write splitting, connect to your DB instance through a private network because read/write splitting addresses are private IP addresses.
- If you delete a primary DB instance after read/write splitting is enabled, the read replicas are also deleted and the read/write splitting function is disabled.
- After read/write splitting is enabled, database ports, security groups, and floating IP addresses of both the primary DB instance and read replicas cannot be changed. If you do need to change any of them, change it before enabling read/write splitting.
- Read/write splitting does not support SSL encryption.
- Read/write splitting does not support the compression protocol.
- Read/write splitting does not support the READ UNCOMMITTED transaction isolation level.
- If multi-statements are executed, all subsequent requests will be routed to the primary DB instance. To restore the read/write splitting function, disconnect the connection from your applications and establish a connection again.
- When read and write requests are split through the read/write splitting address, all transaction requests are routed to the primary DB instance while the non-transaction read consistency is not ensured. To ensure read consistency, encapsulate requests into transactions.
- When the read/write splitting address is used, the LAST_INSERT_ID() function can be used only in transactions.
- When the read/write splitting address is used, the execution results of the show processlist command are inconsistent.
- When the read/write splitting address is used, the show errors and show warnings commands are not supported.
- When the read/write splitting address is used, user-defined variables, such as the SET @variable statements, are not supported.
- When the read/write splitting address is used, if stored procedures and functions depend on user variables (@variable), the execution result may be incorrect.
- Context
- Function Description
- Basic Concepts
- Constraints