CLI Tools · Career · Six rules for error handling in cli-tools-career that I settled on

625
CTr/cli-tools-career·posted by huang_ke·1 hour agoDiscussionPinned

Six rules for error handling in cli-tools-career that I settled on

It took me two weeks of on-and-off digging and plenty of wrong turns. Writing the process down as it happened so the next person spends less time.

What genuinely surprised me was the tail. The average looked great while P99 jumped by an order of magnitude past some threshold. The cause was not cli-tools-career itself but our upstream connection reuse — the load test traffic was too clean and hid the long-tail requests.

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

257 comments

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

517
Sslow_query·2 days ago

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

460
Kkernel_panic·2 days ago

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

455
Kkite·2 days ago

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

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

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

149
WwinterOP·1 hour ago

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

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

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

354
Nnikic·12 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.

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

285
Zzhou_yi·2 days ago

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

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

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

279
Kkernel_panic·2 days agoedited

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

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

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

233
Bbob_chen·12 minutes ago

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

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

403
Oops_wangMod·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.

116
Lli_ming·2 days ago

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

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

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

6
NnikicMod·2 days ago

One counter-example: below cli-tools-career 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
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.

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

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

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

205
Rran_bo·2 days ago

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

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

167
Oops_wang·3 minutes ago

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

134
Aalice_dev·2 days ago

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

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

110
Kkite·2 days ago

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

47
Ttang_hao·28 minutes ago

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

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

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

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

400
Kkernel_panicMod·28 minutes ago

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

126
Mmike_xu·2 days agoLevel 6

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

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

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

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

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

1
Mmike_xu·28 minutes ago

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

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

339
Ttang_hao·2 days ago

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

1
RraseOP·2 days agoedited

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

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

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

80
Oops_wang·2 days ago

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

74
Hhuang_keOP·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.

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

22
Lli_ming·2 days ago

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

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

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

46
Bbob_chen·2 hours ago

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

213
Hhuang_ke·2 days ago

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

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

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

28
Nnikic·2 days ago

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

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

26
Wwinter·5 hours ago

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

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

159
Mmike_xu·2 days ago

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

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

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

10
Kkite·2 days ago

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

19
Ttang_haoOP·2 days agoedited

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

282
Kkite·just now

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.

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

286
Kkite·2 days ago

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

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

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

142
Kkernel_panic·2 days ago

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

9
Sswoole_lee·2 days agoLevel 6

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

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

3
Sswoole_lee·2 days ago

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

3
Zzhou_yi·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
Lli_ming·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.

1
NnikicOP·2 days agoLevel 6

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

27
Ttang_hao·2 days ago

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

155
Kkite·2 days ago

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

7
Zzhou_yi·just now

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

6
Zzhou_yi·2 days ago

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

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

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

321
Lli_ming·2 days agoedited

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

145
Llinlin·yesterday

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

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

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

5
Rran_bo·2 days ago

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

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

3
Sswoole_lee·2 days agoedited

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

3
Kkernel_panic·12 minutes ago

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

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

2
Wwinter·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
Cchen_dev·5 hours ago

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

1
Ddev_zhou·28 minutes ago

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

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

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

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

82
Rran_bo·2 days agoedited

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

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

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

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

1
Oops_wang·3 minutes ago

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

232
WwinterOP·2 days ago

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

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

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

332
Bbob_chen·2 days ago

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

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

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

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

51
Zzhu_zong·3 minutes ago

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

5
RraseOP·2 days ago

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

503
Llinlin·2 days ago

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

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

254
Rrase·2 days ago

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

1

This is the post detail page /en/c/cli-tools-career/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 →