Replication · Interviews · replication-interview logging: what separates "readable" from "usable"

761
REr/replication-interview·posted by tang_hao·32 minutes agoJobs

replication-interview logging: what separates "readable" from "usable"

Some background first. Our setup is replication-interview plus three downstream services, seven figures of daily requests, peaking around nine in the evening.

The first thing was to collapse the variables. We were changing config and upgrading the version at the same time, and afterwards nobody could say which change caused what. We rolled back to moving one variable at a time, re-ran three times, and only then did the curve settle. Tedious, but not skippable.

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

Sstackoverflow.comExternal link · opens in a new tab
367 comments

367 comments

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

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

353
Kkite·2 days ago

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

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

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

103
Aalice_dev·12 minutes 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".

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

452
Mmike_xu·3 minutes ago

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

31
Ddev_zhou·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.

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

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

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

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

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

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

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

243
Aalice_dev·1 hour 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.

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

157
Lli_ming·1 hour ago

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

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

397
Rrase·5 hours 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.

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

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

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

209
Cchen_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.

360
Sslow_query·yesterday

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

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

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

198
Cchen_devOP·2 days ago

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

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

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

349
Cchen_dev·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".

1
Kkernel_panic·1 hour ago

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

333
Aalice_devOPMod·2 days ago

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

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

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

451
Mmike_xuMod·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.

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

264
Zzhu_zong·28 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.

183
Hhuang_ke·2 hours ago

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

148
Oops_wang·2 days ago

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

88
Hhuang_ke·2 hours 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.

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

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

272
Mmike_xu·2 hours 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.

131
Hhuang_ke·2 days ago

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

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

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

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

274
Kkernel_panic·yesterdayLevel 6

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.

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

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

235
Zzhu_zong·1 hour ago

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

258
Zzhou_yi·1 hour ago

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

414
Lli_ming·2 hours agoedited

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

268
Nnikic·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
Sswoole_leeOP·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.

311
Ddev_zhou·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".

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

8
Llinlin·2 hours 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.

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

192
KkiteMod·28 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.

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

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

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

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

178
Kkernel_panicOP·2 days ago

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

12
Sslow_query·2 days agoedited

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

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

177
Hhuang_ke·3 minutes ago

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

169
Rran_bo·yesterday

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.

168
Rran_bo·just now

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

95
Lli_ming·5 hours ago

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

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

5
Sswoole_lee·12 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.

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

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

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

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

65
Oops_wang·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".

122
Rrase·2 hours 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.

118
Rrase·yesterday

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

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

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

107
Hhuang_keOP·2 days ago

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

47
LlinlinMod·28 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.

63
Zzhou_yi·2 days ago

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

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

82
Zzhu_zong·3 minutes ago

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

76
Sswoole_lee·1 hour 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.

73
Zzhou_yi·12 minutes 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".

72
Lli_ming·2 hours 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.

66
Ddev_zhou·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.

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

41
Ddev_zhou·2 days ago

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

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

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

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

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

38
Nnikic·2 days agoedited

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

157
Kkernel_panic·yesterday

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.

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

32
Wwinter·2 days ago

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

310
Wwinter·2 days ago

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

25
Mmike_xu·2 days ago

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

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

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

127
Lli_ming·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".

165
Rran_bo·28 minutes agoedited

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

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

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

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

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

210
Lli_ming·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".

6
Lli_mingMod·2 days ago

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

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

30
Lli_ming·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
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
Hhuang_ke·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.

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

1

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