Read/Write Split
Direct writes to the primary and reads to replicas to scale read-heavy workloads. Use a proxy (ProxySQL, MySQL Router) or application-level routing.
Direct writes to the primary and reads to replicas to scale read-heavy workloads. Use a proxy (ProxySQL, MySQL Router) or application-level routing.
// Laravel read/write split
// config/database.php
"mysql" => [
"read" => ["host" => ["replica1", "replica2"]],
"write" => ["host" => "primary"],
"sticky" => true, // same connection for rest of request after write
...
]
// ProxySQL routes automatically based on query type
// SELECT → replicas, INSERT/UPDATE/DELETE → primary
"sticky" ensures that writes are immediately readable in the same request — prevents stale read after write.