The Real Fullstack

The Replica That Lied

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

高级工程师8 分钟流程模拟器代码挑战
postgresqlspring-bootaws-rdshttp

此挑战尚未翻译为简体中文,你正在阅读英文版本。

任务:Show users their own writes immediately, even when the replica lags, without sending most reads back to the primary.背景 · 学习目标 ▾

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.

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

学习目标

  • Explain asynchronous replication lag.
  • Implement read-your-writes consistency.
  • Weigh primary load against freshness and latency.
模拟模拟数据
BrowserProfile APIPrimaryRead replica
运行模拟

运行模拟以查看输出。

简化说明

One write followed by one read 150 ms later; 8% of reads come from users who wrote in the last few seconds. 教学模型——数字用于说明行为,并非基准测试。

概念

相关挑战

参考资料