Replication · Interviews · Help: replication-interview fails to start intermittently in containers, logs inside

549
REr/replication-interview·posted by alice_dev·5 minutes agoInternalsLocked

Help: replication-interview fails to start intermittently in containers, logs inside

Most replication-interview articles stop at "how to use it" and never cover "when not to use it". This is an attempt at the second half.

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.

Performance44%
Maintainability28%
Ecosystem and community17%
Hiring difficulty11%

933 votes total

299 comments

299 comments

· first 120 loaded
M
Zzhu_zong·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.

455
Mmike_xu·2 days ago

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

435
Mmike_xu·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.

430
Rran_bo·yesterday

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.

342
Oops_wang·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.

248
Sslow_query·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.

496
Zzhu_zong·12 minutes ago

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

65
Bbob_chen·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.

40
Kkernel_panic·2 days ago

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

20
Mmike_xu·2 days ago

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

339
Zzhou_yi·2 days ago

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

19
Bbob_chen·3 minutes agoedited

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.

331
Kkite·1 hour ago

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

9
Oops_wang·2 days ago

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

3
Bbob_chen·yesterday

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.

330
Hhuang_ke·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.

461
Aalice_dev·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.

297
Bbob_chen·3 minutes ago

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

273
Cchen_dev·2 hours 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.

109
Rrase·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.

326
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.

207
Sswoole_leeOP·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.

108
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.

71
Sswoole_lee·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
Oops_wang·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.

514
Kkernel_panic·2 days agoLevel 6

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

141
Bbob_chen·2 days agoLevel 6

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.

120
Rrase·2 days agoLevel 6

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.

111
Sswoole_lee·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.

378
Nnikic·2 days agoLevel 6

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

160
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.

21
Sslow_queryMod·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.

325
Wwinter·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.

331
Kkernel_panic·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.

137
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.

9
Bbob_chen·2 hours 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.

1
NnikicOP·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".

337
Hhuang_keOP·2 days ago

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

205
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.

31
Nnikic·5 hours 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.

226
Zzhu_zong·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".

253
Rran_bo·2 days ago

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

51
Bbob_chen·12 minutes ago

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

224
Oops_wang·12 minutes ago

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

223
Nnikic·28 minutes 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.

28
Ttang_hao·28 minutes 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.

513
Rran_bo·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.

501
Mmike_xu·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.

367
Hhuang_ke·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.

258
Ttang_haoOP·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.

340
Lli_ming·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.

322
Hhuang_ke·3 minutes agoLevel 6

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

496
Sswoole_lee·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.

206
Wwinter·just nowedited

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.

4
Hhuang_ke·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
Zzhu_zong·2 days agoLevel 6

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.

279
Wwinter·yesterdayedited

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.

22
Zzhou_yi·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.

390
Wwinter·2 days ago

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

380
Rrase·yesterday

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.

343
Hhuang_ke·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.

180
Llinlin·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.

70
Nnikic·2 days agoLevel 6

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

207
Ttang_haoOP·2 days agoLevel 6

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.

14
Mmike_xu·2 days agoLevel 6

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.

9
Mmike_xu·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.

29
Rrase·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.

48
Mmike_xu·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.

27
Cchen_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".

126
Hhuang_ke·2 days agoLevel 6

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

126
Cchen_devOP·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.

16
Ttang_hao·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.

32
Ddev_zhouMod·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.

14
Kkernel_panic·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.

298
Aalice_dev·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.

2
Oops_wangMod·just now

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

215
Bbob_chen·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".

185
Ttang_hao·5 hours ago

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

181
Zzhu_zong·2 days ago

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

169
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.

516
Aalice_dev·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.

4
Lli_ming·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.

148
Kkernel_panic·2 days agoedited

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

142
Zzhu_zong·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.

135
Kkite·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.

90
Kkernel_panic·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.

131
Sswoole_leeMod·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.

120
Nnikic·2 days agoedited

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

112
Hhuang_ke·1 hour 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.

99
Mmike_xuOP·yesterday

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
Kkite·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.

1
Aalice_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.

503
Ddev_zhou·3 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.

89
Mmike_xuMod·3 minutes 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.

127
Wwinter·2 days ago

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

404
Bbob_chen·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.

287
LlinlinOP·yesterday

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

14
Rran_bo·2 hours ago

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

185
Hhuang_ke·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.

305
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.

19
Ttang_hao·2 days agoedited

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

225
Rran_bo·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.

151
Wwinter·2 days ago

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

69
RraseOP·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.

7
Oops_wang·just now

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

55
Llinlin·2 days ago

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

20
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.

53
Nnikic·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.

30
Wwinter·2 days agoedited

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.

29
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.

26
Bbob_chenMod·28 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.

25
Lli_ming·2 days ago

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

13
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".

6
Hhuang_ke·12 minutes 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".

5
Oops_wang·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.

3
Ddev_zhou·3 minutes 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.

10
Rrase·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
Hhuang_ke·2 days ago

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

1
Zzhu_zong·2 days ago

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

194
Cchen_dev·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

This is the post detail page /en/c/replication-interview/post/p8. 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 →