Reputation: 384
I have my app setup in 3 regions (EU, AP, US) and the master MySQL RDS resides in eu-west-1, with read replicas in the other regions.
This works great for read queries, with the region specific app connecting to it's local read replica RDS very quickly, but when my app needs to perform a write query, it has to connect to the master DB in eu-west-1.
When writing to the master DB from US or AP, the latency is huge, usually taking around 2.5s to complete the insert.
I've been really struggling to find any info on how to overcome this, Aurora comes up a lot in forums and tutorials for global databases, but it requires replication of the instance type, with db.r5 being the minimum, which soon becomes very expensive when running multiple instances.
Has anybody faced this issue with slow cross-region writes to the master DB? Would VPC peering help speed this up?
Upvotes: 1
Views: 618
Reputation: 23890
With cross-region queries you just can't overcome latency, because there's this limit called the speed of light. You have to work-around it by limiting number of required round trips.
You can for example:
insert … values (…), (…), …
);do $$ begin update …; update …; update …; …, end; $$;
- this might be a little tricky to quote properly;synchronous_standby_names
).Upvotes: 0