React · Architecture · I upgraded our production react-design and hit these 11 landmines

403
REr/react-design·posted by kernel_panic·6 hours agoPostmortem

I upgraded our production react-design and hit these 11 landmines

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

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.

Jjuejin.cnExternal link · opens in a new tab
179 comments

179 comments

· first 120 loaded
M
Kkernel_panic·1 hour ago

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

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

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

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

125
Cchen_devOP·2 days ago

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

293
Ttang_hao·12 minutes ago

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

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

282
Oops_wang·yesterday

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

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

123
Rrase·2 days ago

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

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

293
Nnikic·2 days ago

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

284
Rran_bo·28 minutes ago

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

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

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

273
WwinterMod·2 days ago

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

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

263
WwinterOP·2 days ago

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

181
Llinlin·2 days ago

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

228
Rrase·2 days ago

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

225
Ttang_hao·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
Aalice_dev·2 days ago

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

133
Rran_bo·2 days ago

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

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

356
Bbob_chenMod·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.

85
Ttang_hao·28 minutes ago

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

7
Bbob_chen·2 days ago

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

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

112
Aalice_dev·3 minutes ago

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

171
Hhuang_ke·2 days ago

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

169
Sswoole_leeOP·28 minutes ago

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

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

133
Hhuang_ke·1 hour ago

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

11
Mmike_xu·1 hour ago

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

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

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

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

139
Llinlin·yesterday

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.

139
Hhuang_ke·5 hours 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.

129
Sswoole_leeOP·5 hours ago

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

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

6
Sslow_query·12 minutes ago

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

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

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

286
Zzhou_yi·2 days ago

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

59
Ttang_hao·2 days ago

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

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

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

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

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

39
Cchen_dev·28 minutes ago

One counter-example: below react-design 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

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

2
Lli_mingOP·2 days ago

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

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

62
Mmike_xuOP·2 days agoedited

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

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

56
Llinlin·2 days ago

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

40
WwinterMod·2 days agoedited

One counter-example: below react-design 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
Cchen_dev·28 minutes ago

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

29
Ddev_zhou·2 days ago

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

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

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

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

23
Aalice_dev·2 days ago

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

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

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

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

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

134
Ddev_zhou·2 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.

4
Zzhou_yi·2 days ago

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

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

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

39
Cchen_dev·2 days ago

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

42
Sswoole_lee·3 minutes ago

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

2
Kkernel_panic·3 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.

443
Zzhu_zong·2 hours ago

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

337
Zzhu_zongOP·2 days ago

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

458
Rrase·12 minutes ago

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

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

304
Rrase·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
Llinlin·2 hours agoLevel 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.

16
Kkernel_panic·2 days agoLevel 6

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.

12
Bbob_chen·12 minutes agoeditedLevel 6

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
Kkernel_panic·yesterday

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

210
Bbob_chen·2 days agoLevel 6

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

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

192
Kkernel_panic·2 days agoLevel 6

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

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

85
Aalice_dev·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
Hhuang_ke·just nowedited

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

1
Zzhou_yiMod·2 days agoLevel 6

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

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

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

5
Zzhu_zong·2 days ago

One counter-example: below react-design 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
LlinlinOP·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.

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

26
LlinlinOP·just now

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

105
KkiteOP·2 days ago

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

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

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

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

1
Ttang_hao·2 days ago

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

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

419
Zzhou_yiOP·2 hours 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
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.

151
Sslow_query·just now

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

102
Cchen_dev·2 days agoedited

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

227
Aalice_dev·2 days ago

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

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

515
Rrase·2 days ago

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

188
Cchen_dev·2 days agoedited

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

11
Kkernel_panic·2 days ago

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

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

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

139
Nnikic·2 days ago

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

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

2
Wwinter·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
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
Oops_wang·2 days agoedited

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

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

126

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