10 points · by throaway_pirate · 4y ago · 10 comments
Latency became a huge issue for database writes. The solution we came up with was to split up the app -- multiple regions with their own master database (no syncing cross-regions) and subdomain (e.g. africa.mywebsite.com).
This is working well. There is no concern that there will be any cross-region collaboration between users (at least for now). But it feels like a hack. I want everyone to just be able to go to app.mywebsite.com regardless of region.
There has to be a better way. What strategies are other companies using to solve latency across the globe?
Shopify uses exactly the same model we (Fly.io) do, it's a slightly more evolved version of what you're doing. They run leaders in multiple regions with read replicas scattered around, and then assign the most appropriate leader region to a store.
CockroachDB and Spanner let you move ranges of data to different "leaders" within the cluster. If you model your schema well, they work great. But you do have to worry that queries aren't spanning regions or you end up making everything slow.
The Fly.io magic is the proxy layer that replays entire HTTP requests to the leader region. It works surprisingly well. If your databases is even close to half reads and half writes, something similar may work nicely.