Course contentsShow
← Cloud and Infrastructure
Lesson 419 of 2,9898. Managed DatabasesFree lesson

Read Replica Lag and Consistency

Managing replication lag, monitoring replica health, and understanding eventual consistency implications.

Read Replica Lag and Consistency

You'll learn how replication delay affects data freshness and what "eventual consistency" means when using read replicas.

The Core Challenge

When you create a read replica, the primary database asynchronously copies data to the replica. This copying isn't instantaneous—there's a delay called replication lag. During this lag, the replica shows slightly outdated data compared to the primary.

Think of it like a newspaper: the primary database is "today's news happening right now," while the read replica is "this morning's printed paper." There's a time gap between events occurring and them appearing in print.

Understanding Replication Lag

Replication lag is measured in seconds (sometimes milliseconds or minutes under heavy load). If your primary writes 1,000 transactions per second but the replica can only process 900, lag increases until the replica catches up during quieter periods.

Monitoring replica health means tracking:

  • Replica lag time: How far behind is the replica?
  • Replication status: Is copying active or stalled?
  • Throughput: Can the replica keep pace with primary writes?

Most managed database services provide metrics dashboards showing real-time lag for each replica.

Eventual Consistency Implications

This creates an eventual consistency model: data written to the primary will eventually appear on replicas, but not immediately.

Practical impact: If a user updates their profile on the primary, then immediately refreshes the page (hitting a replica), they might see their old data for a few seconds. For many applications (analytics, reporting, search indexing), this slight delay is acceptable. For critical reads (financial transactions, inventory checks), you must query the primary directly.

Key Takeaway: Replication lag means read replicas show slightly stale data due to asynchronous copying; monitor lag metrics and design applications to tolerate eventual consistency or route critical reads to the primary.