Baking · Events · I upgraded our production baking-events and hit these 11 landmines

1.9K
BAr/baking-events·posted by li_ming·3 days agoOpen source

I upgraded our production baking-events and hit these 11 landmines

Short version: baking-events 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.

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.

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.

Jjvns.caExternal link · opens in a new tab
806 comments

806 comments

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

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

506
Lli_ming·yesterday

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.

303
Kkernel_panic·yesterday

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

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

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

2
Hhuang_ke·2 days ago

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

463
Rran_bo·12 minutes ago

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

460
Aalice_devOP·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.

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

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

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

37
Oops_wang·12 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.

3
Oops_wang·2 days ago

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

167
Ddev_zhouOP·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.

31
Ddev_zhou·2 days ago

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

171
Sswoole_leeOP·5 hours ago

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

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

200
Rran_bo·2 days agoedited

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

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

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

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

464
Kkite·2 days agoLevel 6

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

18
Lli_ming·1 hour ago

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

1
Aalice_dev·2 days ago

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

286
Oops_wang·28 minutes ago

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

424
Wwinter·2 days ago

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

261
Aalice_dev·2 days ago

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

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

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

341
Bbob_chen·5 hours ago

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

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

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

509
Kkernel_panic·2 days ago

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

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

13
Kkernel_panic·2 days ago

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

103
WwinterOP·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.

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

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

341
Bbob_chen·2 days agoedited

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

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

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

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

265
Cchen_dev·5 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.

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

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

234
Llinlin·1 hour 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.

81
Bbob_chen·yesterday

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

213
Cchen_dev·just now

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

162
Zzhu_zong·just nowedited

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.

92
Bbob_chen·3 minutes ago

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

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

20
Ddev_zhouOP·just now

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

1
Rran_bo·2 days agoedited

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

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

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

194
Aalice_dev·28 minutes ago

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

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

406
Llinlin·28 minutes ago

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

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

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

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

1
Nnikic·2 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.

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

176
Sswoole_leeOP·2 days ago

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

454
Hhuang_keOP·2 days ago

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

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

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

164
Sslow_query·2 days ago

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

157
Kkernel_panic·2 days ago

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

156
Zzhu_zong·3 minutes ago

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

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

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

143
Zzhu_zongMod·5 hours ago

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

271
Bbob_chen·28 minutes ago

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

2
Bbob_chen·2 days ago

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

197
Ttang_hao·2 days ago

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

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

1
Zzhu_zongOP·yesterday

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

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

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

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

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

88
Cchen_dev·2 days ago

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

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

32
Bbob_chen·2 days agoedited

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

36
Lli_ming·2 days ago

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

4
Bbob_chen·2 days ago

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

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

56
Mmike_xuMod·2 days ago

One counter-example: below baking-events 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
Rrase·2 days ago

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

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

54
Llinlin·3 minutes ago

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

52
Kkernel_panic·2 hours agoedited

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

52
Zzhou_yi·2 days ago

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

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

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

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

246
Sslow_query·5 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.

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

22
Ddev_zhou·yesterday

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

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

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

20
Oops_wang·2 days ago

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

283
Rran_bo·2 days ago

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

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

18
Zzhou_yi·2 days ago

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

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

15
Sslow_query·2 days ago

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

6
Zzhu_zong·2 days ago

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

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

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

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

1
Cchen_devOP·2 days ago

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

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

1
Wwinter·2 days ago

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

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

458
Hhuang_keOP·2 days ago

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

328
Ddev_zhou·2 days ago

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

54
Oops_wang·2 days ago

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

1

This is the post detail page /en/c/baking-events/post/p0. 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 →