Read/write splitting lets you offload read traffic from your primary RDS instance to one or more read-only instances, increasing overall database throughput without changing your application code. This feature is available for MySQL and SQL Server.
When read/write splitting is enabled, ApsaraDB RDS generates a read/write splitting endpoint or a read-only routing endpoint. This endpoint automatically routes write requests to the primary instance and distributes read requests across your read-only instances.
Use cases
-
Read-heavy workloads: When read traffic saturates the primary instance, add read-only instances behind a read/write splitting endpoint to scale out without resizing the primary.
-
Reporting and analytics: Run long-running queries on a read-only instance so they don't compete with transactional writes on the primary.
How it works
-
Create one or more read-only instances manually. The primary instance replicates data to each read-only instance.
-
Enable read/write splitting. ApsaraDB RDS generates a shared endpoint for your application to connect to.
-
Point your application to the read/write splitting endpoint or read-only routing endpoint. No other application changes are needed.
All write requests are forwarded to the primary instance. Read requests are distributed among the available read-only instances.
Limitations
Replication lag: Read-only instances receive data from the primary with some replication lag. If your application requires reading the latest committed data immediately after a write — for example, in a read-your-own-writes scenario — connect directly to the primary instance instead of the shared endpoint.
Manual instance creation: Read-only instances are not created automatically. You must manually create read-only RDS instances.
Minimum read-only instance requirement: The shared endpoint requires at least one active read-only instance to distribute read traffic.
What's next
Use the following guides to set up read/write splitting for your database engine: