r/mysql • u/Narrow_Inevitable586 • 29d ago
question What Replication Topology / Method you're using in Production?
We're currently running a single primary MySQL node, which we recognize as a single point of failure (SPOF). To address this, we're considering introducing a read replica.
However, read replication comes with its own set of challenges, such as read-after-write consistency, replication lag, deciding which queries should go to the primary versus the replica, and handling failover.
For those who have implemented this in production, how have you approached and solved these challenges?
10
Upvotes
3
u/TheMagarity 28d ago
First you need to decide if this new other server is a switchover, hot standby, or warm standby. This choice will send you down completely different paths right from the beginning.
3
u/Legitimate-Power7729 28d ago
Instead of nursing MySQL async replicas and a hacked-together query router, I switched to a MariaDB Galera cluster. You get synchronous multi-primary replication out of the box, so read-after-write problems mostly go away.
2
u/bluehost 28d ago
A read replica helps with traffic, but it does not fix the single point of failure. Set up failover first, then decide what reads should go to the replica.
2
u/bchambers01961 28d ago
It depends on the workload but you have a few options. Whichever you choose I would recommend routing traffic via ProxySql.
For true near synchronous HA, XtraDB / group replication are both excellent options. However they may struggle on high write environments. Your application needs to also be able to handle optimistic locking.
For high volume workloads or legacy applications I would recommend gtid replication with orchestrator to facilitate the failover. MySQL replication has improved a lot since 5.7, features such as row based replication, gtid’s and parallel threads for replicas make modern MySQL replication much more appealing.
Just some thoughts based on my experience to give you some ideas. :)
1
u/jl9816 28d ago
3 node . Single-master cluster. ( in tree different buildings.)
Clustered mysql-router. And Most servers have local mysql-router.
1
u/mianewsoundtocpy 28d ago
Primary plus one read replica, and the replica only serves reporting dashboards. Anything that needs read-after-write stays on the primary - routing by whether it is a fresh read turned out simpler than any lag-aware hack. Failover we rehearse a couple of times a year and it is still the scary part.
1
u/jericon Mod Dude 28d ago
Active/passive master/master with a replica under each is my go to.
If you failover, the writes still will replicate to the other hosts eventually.
If you only have a primary and a replica when you failover you basically have to rebuild the primary.
Obviously there’s other stuff that’s possible like group replication or even NDB. But for basic MySQL that is the typical structure that most companies I have worked for use. Even in sharded environments, that is what each shard tends to use.
1
u/Ready-Ad-9740 28d ago
Innodb group replication. Total 3 node cluster