Monitoring · Advanced · Why this monitoring-pro pattern gets slow in production: a source-level explanation

200
MOr/monitoring-pro·posted by swoole_lee·32 minutes agoOpen source

Why this monitoring-pro pattern gets slow in production: a source-level explanation

Most monitoring-pro articles stop at "how to use it" and never cover "when not to use it". This is an attempt at the second half.

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

-- 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;

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

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.

77 comments

77 comments

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

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

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

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

493
Llinlin·2 days ago

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

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

491
Oops_wang·yesterday

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.

446
Lli_ming·2 days ago

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

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

293
Zzhou_yi·28 minutes ago

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

17
Zzhu_zong·2 days ago

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

273
Lli_ming·2 days ago

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

10
Rran_bo·2 days ago

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

4
Ddev_zhou·2 days ago

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

422
Rrase·1 hour ago

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

321
Rran_bo·3 minutes agoedited

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

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

157
Oops_wang·2 days agoedited

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

278
Sslow_query·5 hours ago

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

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

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

254
Hhuang_ke·1 hour agoedited

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

222
Sslow_queryOPMod·2 days agoedited

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

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

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

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

124
Ttang_haoMod·3 minutes agoedited

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

181
KkiteOP·just nowedited

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

37
Mmike_xuOP·just now

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.

86
Ttang_hao·2 days ago

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

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

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

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

88
Kkite·3 minutes ago

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

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

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

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

51
Zzhou_yiMod·2 days ago

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

107
Bbob_chen·just now

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

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

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

38
Sswoole_lee·2 days agoedited

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

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

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

467
Nnikic·yesterday

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

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

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

37
Cchen_dev·28 minutes ago

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

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

75
Oops_wang·2 days agoeditedLevel 6

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

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

1
Kkernel_panic·2 days agoLevel 6

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

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

35
Rran_bo·2 days ago

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

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

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

373
Zzhu_zong·12 minutes ago

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

201
RraseOP·2 days agoedited

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

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

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

373
Zzhu_zong·3 minutes agoedited

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

3
Cchen_dev·5 hours ago

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

44
WwinterMod·just now

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

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

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

18
Mmike_xu·2 days agoedited

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

221
LlinlinMod·2 days ago

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

17
Cchen_dev·2 days ago

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

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

364
Sswoole_lee·1 hour ago

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

9
Lli_mingMod·12 minutes 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.

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

57
Hhuang_ke·2 hours ago

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

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

1

This is the post detail page /en/c/monitoring-pro/post/p1. 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 →