Read-Write Split Pattern

Route reads vs writes.

Overview

The read-write split pattern routes write queries to the primary database and read queries to one of N replicas. The architecture is simple; the implementation is where it gets tricky. Per-query classification (is this a read or a write?) must be correct, read-after-write must fall back to the primary for the affected user, replica lag must inform routing, and the connection pool must understand the difference between read and write connections.

The approach

The practical approach is to put the routing at the application layer (proxies like ProxySQL work but add a hop), classify queries explicitly rather than parsing SQL on the fly, implement read-after-write fallback for any user-affecting write, monitor per-route correctness so misrouting surfaces in metrics, and document the per-database routing strategy committed to the repo.

Why this compounds

Read-write split discipline compounds across services. Each correctly-routed query offloads the primary; each correctly-monitored route catches misclassification; the team builds a vocabulary for routing decisions that pays off on every new feature. The opposite, where routing is implicit and unverified, accumulates correctness bugs that surface as flaky user-reported issues months later.

Read-write split discipline is a database discipline that pays off across years. Nova AI Ops integrates with database telemetry, surfaces routing patterns, and supports the team’s read-routing discipline.