Skip to content

Aurora Global DB secondary cluster writes from reader using RDS Data API

0

One of the challenges my team is facing currently is planning the migration of a global business platform to AWS.

We have successfully set up a staging environment through which we can communicate with an Aurora Global DB through PHP code that provides a simple web UI on an instance that is behind a load balancer. There are 2 regions in which the above has been replicated, and the PHP code simply uses alternative endpoints to speak to the second cluster for Aurora Global DB in the second region.

The global DB has a primary region and a secondary region/cluster with a reader. Using the above setup, we can successfully use the reader endpoint in the secondary cluster to write changes to the primary cluster. This is progress, and latency is low.

Our next challenge is to set up a connection to the Aurora Global DB, location dependant, to a desktop application that the clients use. We assumed that RDS Data API would be the perfect fit solution for this use case. However, the RDS Data API is unable to read and write to the Auror Global DB when using the ARN for the secondary cluster.

We have read the article related to limitations when using the RDS Data API below: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.limitations.html

With Aurora global databases, you can enable Data API on both the primary and secondary DB clusters. However, a secondary cluster doesn't have a writer instance until it's promoted to be the primary. Data API requires access to the writer instance for query processing, even for read queries. As a result, read and write queries sent to the secondary cluster fail while it lacks a writer instance. Once a secondary cluster is promoted and has a writer instance available, Data API queries on that DB instance succeed.

This obviously will not work in our use case unless we have missed anything? Are there any plans to improve access via the RDS Data API to emulate the process that we have successfully achieved when connecting to the secondary cluster from an instance using PHP Code to connect?

asked a year ago368 views

1 Answer
-1

Based on your description, you've successfully set up a system where your PHP application can write to the primary Aurora Global Database cluster through the reader endpoint in the secondary region. This is likely using the write forwarding feature of Aurora Global Database, which allows secondary clusters to forward write operations to the primary cluster.

However, you're encountering limitations with the RDS Data API when trying to achieve the same functionality for your desktop application. The limitation you've quoted is accurate - the RDS Data API requires access to a writer instance for query processing (even for read queries), and since secondary clusters in an Aurora Global Database don't have writer instances until promoted to primary, the Data API cannot process queries against the secondary cluster.

For your use case, there are a few alternatives to consider:

  1. Use direct database connectivity from your desktop application instead of the Data API. This would allow you to leverage write forwarding similar to your PHP application.

  2. Set up an API layer (like a REST API using AWS Lambda or API Gateway) that connects to the appropriate Aurora cluster and provides endpoints for your desktop application.

  3. Use RDS Proxy with your Aurora Global Database. RDS Proxy can work with Aurora Global Databases and might provide a more suitable connection management solution for your desktop application.

The write forwarding feature you're using with your PHP application is specifically designed to allow secondary clusters to forward write operations to the primary cluster, but this functionality isn't currently integrated with the RDS Data API's architecture, which requires a writer instance to be present in the cluster it's connecting to.
Sources
Using write forwarding in an Aurora PostgreSQL global database - Amazon Aurora
Using write forwarding in an Aurora MySQL global database - Amazon Aurora
Using RDS Proxy with Aurora global databases - Amazon Aurora
Using the Amazon RDS Data API - Amazon Aurora
Using Amazon Aurora Global Database - Amazon Aurora

answered a year ago

AWS
SUPPORT ENGINEER

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.