Replication · Interviews · Discussion: is the replication-interview ecosystem being replaced by another stack?

1.4K
REr/replication-interview·posted by huang_ke·3 hours agoPostmortem

Discussion: is the replication-interview ecosystem being replaced by another stack?

Short version: replication-interview needs almost no tuning at small and medium scale — the point where it starts to hurt is much further out than most people assume. Full measurements below.

On trade-offs, my view is this: if nobody on the team owns this area long-term, do not introduce a second mechanism. With two coexistence you first have to work out which one is even in play when things break, and that costs far more than the performance you saved.

Worth noting: the official docs do cover this, just in a very inconspicuous spot. I only found it reading the source comments, where the author explains the reasoning — roughly "so that it degrades into predictable behaviour in extreme cases".

We also fixed monitoring along the way: replaced average-based alerts with percentiles and split them per endpoint. False alerts dropped by about seventy percent and the on-call rotation visibly cheered up.

One last trap: in container environments remember to adjust the memory-related parameters in step. Otherwise the host limit and the process expectation disagree, and the symptom is intermittent, unreproducible failure.

382 comments

382 comments

· first 120 loaded
M
Kkite·2 days agoedited

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

483
Kkite·28 minutes ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

481
Kkernel_panic·28 minutes ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

285
Mmike_xu·1 hour ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

461
Wwinter·2 days agoedited

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

2
Kkite·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

393
Ttang_hao·2 days agoLevel 6

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

459
Aalice_dev·2 days agoLevel 6

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

100
Wwinter·1 hour ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

5
Zzhu_zongOP·2 days agoLevel 6

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

96
NnikicMod·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

60
Kkernel_panic·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

31
Rran_bo·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

282
Llinlin·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

109
LlinlinMod·2 hours ago

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

309
Kkite·3 minutes agoedited

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

464
Zzhou_yi·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

427
Oops_wang·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

414
Cchen_dev·2 hours ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

414
Llinlin·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

395
Rrase·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

509
Wwinter·2 days agoedited

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

391
WwinterOP·2 days agoedited

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

320
Ttang_hao·12 minutes ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

364
Lli_ming·just now

Saved. I am reworking this area this week — this saves a lot of wrong turns.

63
NnikicOP·2 hours ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

283
Mmike_xu·2 hours ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

223
Mmike_xuOP·3 minutes ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

2
Rran_bo·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

119
Hhuang_keMod·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

1
Llinlin·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

134
Sslow_query·just now

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

103
Sslow_query·28 minutes ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

102
Lli_ming·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

39
Zzhu_zong·2 days agoLevel 6

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

467
Kkite·28 minutes ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

4
Wwinter·2 days agoedited

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

469
Sswoole_lee·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

357
Cchen_dev·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

67
Hhuang_ke·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

274
Zzhu_zong·2 days ago

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

272
Rran_bo·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

225
Hhuang_ke·3 minutes ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

220
Rrase·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

265
Kkite·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

214
Nnikic·2 days ago

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

199
Cchen_dev·2 days ago

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

195
Zzhu_zong·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

181
Bbob_chen·12 minutes ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

156
Kkite·2 days ago

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

146
Rran_bo·2 days ago

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

343
Ddev_zhou·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

58
Cchen_devOP·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

36
Cchen_dev·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

6
Ttang_hao·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

131
KkiteOP·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

69
Aalice_dev·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

113
Zzhu_zong·2 days ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

18
Oops_wang·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

106
Ttang_haoMod·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

9
RraseOPMod·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

45
Cchen_dev·28 minutes ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

98
Zzhu_zong·2 days ago

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

95
Cchen_devMod·2 hours ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

71
Kkernel_panicMod·2 days ago

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

70
Hhuang_ke·28 minutes ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

304
Zzhu_zong·28 minutes ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

69
Mmike_xu·2 days ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

333
Lli_ming·3 minutes ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

67
Hhuang_ke·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

66
Ttang_haoOP·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

1
Aalice_dev·28 minutes agoedited

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

56
Zzhou_yi·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

31
Ddev_zhou·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

435
Aalice_dev·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

1
Sswoole_lee·2 days agoedited

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

32
Lli_ming·2 days agoedited

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

44
Zzhou_yi·2 days agoedited

Saved. I am reworking this area this week — this saves a lot of wrong turns.

28
Nnikic·1 hour ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

101
Lli_ming·1 hour ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

395
Zzhu_zong·2 days ago

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

78
Rran_bo·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

45
Cchen_dev·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

1
Ddev_zhou·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

2
Aalice_dev·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

1
Kkernel_panic·2 days agoedited

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

24
Sswoole_lee·2 days ago

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

1
Llinlin·3 minutes ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

21
Lli_ming·28 minutes ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

245
Sslow_query·2 days ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

464
Lli_ming·12 minutes ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

4
Sswoole_lee·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

447
Bbob_chen·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

38
Zzhou_yi·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

3
Zzhou_yi·just now

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

15
Sswoole_lee·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

38
Sslow_query·12 minutes ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

11
Bbob_chen·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

11
Nnikic·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

10
Ddev_zhouMod·just now

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

8
Cchen_dev·2 days ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

484
Lli_ming·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

118
Llinlin·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

30
Ddev_zhou·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

31
Ddev_zhou·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

29
Kkite·28 minutes ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

33
Aalice_dev·2 hours ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

8
Rrase·2 days ago

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

8
Bbob_chen·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

4
Lli_ming·2 days agoedited

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

2
Hhuang_ke·2 days ago

One counter-example: below replication-interview 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

2
Ddev_zhou·2 days agoedited

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

2
Hhuang_ke·28 minutes ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

1
Oops_wangMod·2 days agoedited

I just read the replication-interview source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

47
Bbob_chen·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

271
Ttang_hao·1 hour ago

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

169
Oops_wang·12 minutes ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

3
Llinlin·2 days agoedited

This is not a replication-interview problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

5
Zzhou_yi·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

416
Mmike_xu·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

1

This is the post detail page /en/c/replication-interview/post/p12. Posts and comments are generated deterministically from a seeded PRNG, so the same post always renders the same content and the link can be shared, reloaded and indexed. In production this page reads MySQL for the post, Redis for hot-post caching, and fetches the whole comment tree in a single query on the path column.

See the database schema →