App Design · News · Six rules for error handling in app-design-news that I settled on

514
ADr/app-design-news·posted by mike_xu·2 days agoOpen source

Six rules for error handling in app-design-news that I settled on

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

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.

Image placeholder · object storage in production
POST /api/uploads → CDN origin pull
234 comments

234 comments

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

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

433
Zzhu_zong·2 days ago

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

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

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

396
Ddev_zhou·just now

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

392
Aalice_dev·2 days ago

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

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

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

364
Sslow_query·2 days ago

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

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

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

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

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

249
Rran_bo·2 days agoLevel 6

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

183
Ttang_hao·2 days ago

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

319
Sswoole_lee·2 days ago

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

307
Kkernel_panicOP·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.

233
Zzhu_zong·2 days ago

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

291
Rrase·2 days agoedited

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

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

232
Oops_wang·2 days ago

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

35
Kkernel_panic·5 hours ago

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

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

285
Lli_ming·2 days agoedited

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

111
Kkernel_panic·2 days ago

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

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

215
Sswoole_lee·2 days ago

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

473
Lli_ming·2 days agoedited

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

93
Sswoole_lee·2 days ago

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

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

48
Rran_bo·2 days ago

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

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

199
WwinterOP·2 days ago

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

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

170
Ttang_hao·2 days ago

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

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

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

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

120
Wwinter·2 days ago

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

105
Wwinter·12 minutes ago

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

103
Llinlin·2 days ago

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

94
Bbob_chen·2 days ago

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

93
Aalice_devMod·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.

77
Zzhu_zong·2 days ago

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

72
Mmike_xu·2 days ago

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

67
Llinlin·2 days ago

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

463
Kkite·28 minutes ago

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

159
Zzhou_yi·2 days ago

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

262
Zzhou_yiMod·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.

67
Ddev_zhou·5 hours ago

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

52
Rrase·2 days ago

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

67
Wwinter·2 days ago

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

19
Nnikic·2 days ago

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

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

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

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

37
Bbob_chen·just now

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.

34
Ddev_zhou·yesterday

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

42
WwinterMod·3 minutes ago

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

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

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

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

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

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

22
Wwinter·2 days ago

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

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

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

17
Sslow_query·2 days ago

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

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

99
Aalice_dev·2 days agoedited

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

425
Hhuang_ke·2 days agoeditedLevel 6

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

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

55
Bbob_chen·2 days agoLevel 6

One counter-example: below app-design-news 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
Rrase·3 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.

90
Lli_ming·28 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.

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

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

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

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

501
Kkite·2 days ago

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

446
Hhuang_ke·2 days agoedited

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

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

273
Zzhou_yiOP·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.

160
Kkite·5 hours ago

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

99
Sswoole_lee·yesterday

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

127
Lli_mingOP·5 hours 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.

17
Zzhou_yiOPMod·28 minutes ago

One counter-example: below app-design-news 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
Wwinter·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.

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

26
Wwinter·1 hour ago

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

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

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

13
Ddev_zhou·2 days ago

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

13
Sswoole_lee·2 hours ago

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

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

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

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

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

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

13
Llinlin·2 days ago

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

3
Bbob_chen·2 days ago

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

2
Sswoole_lee·2 days ago

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

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

2
Zzhou_yi·2 days agoedited

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

33
Ddev_zhou·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
Rrase·2 days ago

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

5
Zzhou_yi·28 minutes ago

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

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

73
Rran_bo·2 days ago

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

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

8
Rrase·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
Zzhou_yi·just now

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.

268
Lli_ming·2 days ago

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

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

1
Sslow_query·5 hours ago

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

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

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

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

This is the post detail page /en/c/app-design-news/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 →