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. 教育用モデルです。数値は挙動を示すためのもので、ベンチマークではありません。

コンセプト

関連する課題

参考資料