High Concurrency · Code review · Choosing high-concurrency-review: I turned 5 options into a side-by-side comparison

465
HCr/high-concurrency-review·posted by tang_hao·3 days agoJobsLocked

Choosing high-concurrency-review: I turned 5 options into a side-by-side comparison

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.

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

On trade-offs, my view is this: if nobody on the team owns this area long-term, do not introduce a second mechanism. With two coexistence you first have to work out which one is even in play when things break, and that costs far more than the performance you saved.

We also fixed monitoring along the way: replaced average-based alerts with percentiles and split them per endpoint. False alerts dropped by about seventy percent and the on-call rotation visibly cheered up.

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.

152 comments

152 comments

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

519
Rrase·2 days ago

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

489
Rran_bo·just now

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

477
Ttang_hao·2 days ago

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

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

473
Ttang_hao·1 hour ago

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

12
Cchen_dev·28 minutes ago

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

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

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

55
Sslow_query·5 hours ago

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

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

7
Lli_ming·2 days ago

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

471
Ttang_hao·2 days ago

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

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

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

464
Sslow_query·just now

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.

348
Kkite·12 minutes ago

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

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

297
Kkernel_panic·12 minutes ago

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

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

255
Hhuang_ke·yesterdayedited

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

115
Hhuang_ke·2 days ago

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

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

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

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

253
Sslow_query·2 days ago

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

49
Ddev_zhou·2 days ago

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

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.

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

93
Zzhu_zong·2 hours ago

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

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

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

3
Ttang_hao·28 minutes ago

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

249
Mmike_xu·2 days agoedited

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

186
Rrase·2 days ago

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

21
Bbob_chen·3 minutes ago

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

238
Mmike_xu·just nowedited

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

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

152
Ddev_zhou·5 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.

88
Aalice_dev·2 days ago

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

64
Lli_ming·2 days agoedited

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

230
Bbob_chen·just now

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

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

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

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

158
Nnikic·5 hours agoLevel 6

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

28
Aalice_dev·2 days agoedited

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

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

229
Zzhu_zong·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
Hhuang_ke·2 days agoedited

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

80
Sswoole_lee·5 hours agoedited

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

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

116
Hhuang_ke·1 hour agoedited

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

365
Llinlin·2 days ago

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

324
Llinlin·2 days ago

One counter-example: below high-concurrency-review 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
Aalice_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.

74
Zzhu_zong·2 days ago

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

112
Sswoole_leeOP·28 minutes ago

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

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

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

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

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

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

214
Zzhou_yi·2 days agoedited

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

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

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

97
Nnikic·2 days ago

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

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

156
Lli_mingOP·2 days ago

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

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

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

7
Bbob_chenOP·2 days ago

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

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

2
Bbob_chen·2 days ago

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

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

154
WwinterOP·2 days agoedited

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

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

1
Sslow_query·2 days ago

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

143
Lli_ming·2 days ago

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

13
Llinlin·2 days agoedited

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

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

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

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

380
Hhuang_ke·2 days ago

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

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

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

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

171
Aalice_devOP·2 days ago

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

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

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

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

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

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

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

57
Ttang_hao·2 days ago

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

52
Kkite·2 days ago

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

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

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

150
Rran_bo·2 days ago

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

80
Bbob_chen·just now

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

24
Mmike_xu·2 days ago

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

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

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

5
Zzhou_yi·2 days ago

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

296
Kkernel_panicOP·2 days ago

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

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

352
Ddev_zhouOP·2 days ago

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

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

1
Ttang_hao·2 hours ago

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

5
Nnikic·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
Rrase·2 days ago

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

116
WwinterMod·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.

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

4
Ttang_hao·12 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.

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

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

1
Zzhu_zong·2 days ago

One counter-example: below high-concurrency-review 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
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
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

This is the post detail page /en/c/high-concurrency-review/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 →