React · Architecture · Why does react-design use twice the memory of comparable tools?

1.2K
REr/react-design·posted by chen_dev·32 minutes agoJobs

Why does react-design use twice the memory of comparable tools?

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 react-design itself but our upstream connection reuse — the load test traffic was too clean and hid the long-tail requests.

Documentation first44%
Source code first28%
Just ask someone17%
Run a demo and learn by error11%

2004 votes total

671 comments

671 comments

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

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

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

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

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

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

421
Rran_boOP·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.

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

391
Rran_boMod·2 days agoedited

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

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

276
Rran_bo·2 days ago

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

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

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

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

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

181
Wwinter·2 days ago

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

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

169
Aalice_dev·2 days ago

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

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

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

133
Rrase·2 days ago

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

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

132
Kkernel_panic·1 hour ago

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

126
Sswoole_lee·2 days ago

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

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

188
Ttang_haoOP·2 days ago

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

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

97
Mmike_xu·3 minutes ago

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

87
Mmike_xu·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".

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

81
Sswoole_lee·28 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.

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

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

337
Rran_bo·1 hour ago

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

502
Mmike_xu·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
Mmike_xuOP·2 days ago

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

153
Ttang_hao·2 days agoLevel 6

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
Mmike_xuOP·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.

20
Rrase·28 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.

1
Kkite·2 days agoLevel 6

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.

13
Lli_ming·2 hours agoedited

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

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

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

154
Cchen_dev·2 days ago

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

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

134
Ddev_zhou·just now

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.

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

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

439
Rrase·1 hour agoLevel 6

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

423
Sslow_query·2 days ago

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

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

394
Oops_wang·3 minutes agoLevel 6

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.

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

38
Sslow_query·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".

55
Ddev_zhouMod·just nowLevel 6

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

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

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

6
Lli_ming·2 days agoeditedLevel 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.

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

2
Sslow_query·1 hour 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
Ttang_hao·3 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.

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

204
Oops_wang·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".

22
Cchen_dev·yesterday

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.

7
Mmike_xu·2 hours ago

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

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

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

59
Nnikic·2 days agoLevel 6

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

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

169
Aalice_dev·2 days agoedited

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

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

1
Sswoole_lee·2 days ago

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

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

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

367
Kkite·2 days agoLevel 6

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

41
Hhuang_ke·2 days agoLevel 6

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

1
Mmike_xu·12 minutes agoedited

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

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

15
Sslow_query·1 hour 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".

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

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

365
Oops_wang·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".

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

62
Mmike_xu·12 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.

50
Hhuang_ke·2 days ago

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

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

72
Oops_wangOP·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
Mmike_xu·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.

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

56
Ddev_zhou·2 days ago

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

137
Zzhu_zong·2 days ago

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

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

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

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

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

294
Oops_wang·2 days ago

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

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

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

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

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

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

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

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

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

10
Kkite·3 minutes ago

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

9
NnikicMod·2 days ago

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

9
Zzhou_yi·28 minutes ago

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

8
Nnikic·yesterdayedited

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.

7
Lli_ming·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
Cchen_dev·2 days agoedited

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

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

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

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

1
Ttang_hao·2 days ago

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

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

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

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/react-design/post/p13. 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 →