Monorepo Frontend · Q&A · Help: monorepo-frontend-qa fails to start intermittently in containers, logs inside

424
MFr/monorepo-frontend-qa·posted by tang_hao·just nowTutorial

Help: monorepo-frontend-qa fails to start intermittently in containers, logs inside

Some background first. Our setup is monorepo-frontend-qa 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.

-- The query that broke: a full scan over 20M rows.
-- A composite index took P99 from 1.8s down to 42ms.
SELECT id, title, created_at
  FROM posts
 WHERE community_id = ?
   AND status = 1
 ORDER BY score DESC
 LIMIT 20;

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.

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.

172 comments

172 comments

· first 120 loaded
M
Llinlin·2 days ago

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

503
Lli_ming·2 days ago

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

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

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

467
Bbob_chen·2 days ago

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

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

18
Ttang_hao·2 days ago

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

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

406
Ttang_hao·just now

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

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

235
Bbob_chen·2 days ago

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

1
Llinlin·2 days ago

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

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

327
Oops_wang·5 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.

157
Cchen_dev·1 hour ago

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

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

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

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

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

231
Mmike_xu·12 minutes ago

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

192
Kkite·yesterday

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

1
Oops_wang·2 days ago

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

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

165
Zzhou_yi·2 hours ago

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

40
Kkernel_panic·2 days ago

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

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.

160
Ttang_hao·2 hours agoedited

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

286
Ttang_hao·2 days ago

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

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

115
Lli_ming·just now

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

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

176
Sslow_query·2 days ago

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

34
Llinlin·12 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.

96
WwinterMod·1 hour ago

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

156
Aalice_dev·5 hours 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.

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

25
Wwinter·just now

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

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

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

96
Cchen_dev·2 days agoeditedLevel 6

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

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

307
Rran_boOP·2 days agoLevel 6

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

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

33
Kkite·2 hours ago

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

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

27
Aalice_dev·2 days agoLevel 6

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

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

24
LlinlinOP·just now

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.

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

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

2
Zzhu_zong·12 minutes 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.

401
Sslow_query·5 hours agoLevel 6

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

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

205
Sswoole_lee·2 days agoLevel 6

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

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

7
Zzhu_zong·just nowLevel 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.

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

389
Kkite·2 days agoLevel 6

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

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

357
RraseOP·2 days ago

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

103
Ddev_zhou·just nowLevel 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.

394
Ttang_hao·28 minutes 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.

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

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

22
Llinlin·5 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.

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

443
Nnikic·3 minutes agoLevel 6

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.

435
Lli_ming·2 days agoLevel 6

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

310
Rrase·3 minutes ago

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

383
Ttang_haoOP·2 days ago

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

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

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

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

121
WwinterMod·2 days agoedited

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

117
Sswoole_leeOP·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.

45
Nnikic·2 hours ago

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

92
LlinlinOP·12 minutes ago

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

32
Sslow_query·2 days ago

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

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

92
Cchen_dev·2 days ago

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

483
NnikicMod·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.

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

191
Zzhou_yi·2 days ago

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

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

321
Wwinter·2 days ago

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

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

506
Oops_wang·2 hours ago

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

76
NnikicOP·3 minutes ago

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

44
Ttang_hao·5 hours 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.

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

74
Rran_boOP·2 days ago

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

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

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

60
Rran_bo·2 hours agoedited

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

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

6
Kkernel_panic·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·1 hour ago

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

54
Llinlin·28 minutes ago

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

110
Hhuang_ke·12 minutes ago

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

2
Bbob_chen·2 days agoedited

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

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

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

22
Llinlin·2 days ago

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

20
Rrase·2 hours agoedited

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

17
Kkernel_panic·2 days ago

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

15
Cchen_dev·2 days ago

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

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

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

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

8
Ddev_zhou·2 days ago

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

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

37
Llinlin·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
Cchen_devMod·2 days ago

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

2
Cchen_dev·2 days ago

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

329
Nnikic·2 days ago

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

2
Zzhu_zong·12 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.

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

1
Rran_bo·2 days ago

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

1

This is the post detail page /en/c/monorepo-frontend-qa/post/p4. 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 →