The Real Fullstack

The Replica That Lied

The update returned 200 OK. Why does the next page show the old value?

Engenheiro sênior8 minSimulador de fluxoDesafio de código
postgresqlspring-bootaws-rdshttp

Este desafio ainda não foi traduzido para Português (Brasil). Você está lendo a versão em inglês.

Missão:Show users their own writes immediately, even when the replica lags, without sending most reads back to the primary.Contexto · Objetivos de aprendizagem ▾

Tallow Cloud moved read-only queries to a PostgreSQL read replica to offload the primary. Since then, users sometimes see their old profile right after saving it — and submit the change again. Replication lag is usually tens of milliseconds but spikes during backups.

Missão: Show users their own writes immediately, even when the replica lags, without sending most reads back to the primary.

Objetivos de aprendizagem

  • Explain asynchronous replication lag.
  • Implement read-your-writes consistency.
  • Weigh primary load against freshness and latency.
SimulaçãoSimulado
BrowserProfile APIPrimaryRead replica
Executar simulação

Execute a simulação para ver a saída.

Simplificação

One write followed by one read 150 ms later; 8% of reads come from users who wrote in the last few seconds. Modelo educacional — os números ilustram comportamento, não são benchmarks.

Conceitos

Desafios relacionados

Referências