Alertmanager · English · Cut our alertmanager-en build from 4 minutes to 40 seconds with these 5 changes

2.2K
ALr/alertmanager-en·posted by linlin·6 hours agoReview

Cut our alertmanager-en build from 4 minutes to 40 seconds with these 5 changes

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

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.

Image placeholder · object storage in production
POST /api/uploads → CDN origin pull
764 comments

764 comments

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

501
Zzhou_yiMod·2 days ago

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

391
Zzhu_zong·12 minutes ago

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

480
Bbob_chen·yesterday

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

458
Zzhu_zong·2 days ago

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

457
NnikicOPMod·2 days ago

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

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

447
Sswoole_lee·2 days ago

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

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

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

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

418
Zzhu_zong·just nowedited

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.

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

505
Rran_bo·2 days ago

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

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

320
Nnikic·2 hours ago

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

311
Cchen_dev·2 days ago

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

467
Rrase·2 days ago

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

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

101
Zzhu_zong·28 minutes ago

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

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

253
Ddev_zhou·2 days agoedited

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

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

225
Ddev_zhou·2 days ago

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

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

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

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

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

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

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

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

6
Oops_wang·2 days agoedited

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

14
Sslow_query·yesterday

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

177
Nnikic·2 hours ago

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

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

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

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

377
Zzhu_zong·12 minutes ago

One counter-example: below alertmanager-en 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
Ddev_zhou·2 days ago

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

5
Kkite·2 days ago

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

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

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

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

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

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

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

406
Llinlin·2 days ago

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

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

164
Oops_wang·2 days ago

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

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

156
Sswoole_lee·2 hours ago

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

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

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

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

3
Llinlin·2 days ago

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

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

185
Llinlin·2 days agoedited

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

16
Zzhu_zong·2 days ago

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

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

117
Ddev_zhou·2 days ago

One counter-example: below alertmanager-en 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
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.

156
Zzhu_zong·2 days ago

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

117
Hhuang_ke·12 minutes ago

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

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

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

88
Ddev_zhou·2 days ago

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

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

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

510
Wwinter·28 minutes agoedited

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

461
Llinlin·just now

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

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

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

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

2
Cchen_dev·2 days ago

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

517
Nnikic·yesterday

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

66
Zzhou_yi·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
Lli_mingOP·2 hours ago

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

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

79
Rran_bo·just now

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

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

77
Sslow_query·2 days ago

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

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

69
Hhuang_ke·2 days ago

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

150
Ttang_hao·28 minutes ago

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

401
NnikicMod·2 days ago

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

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

47
Rran_bo·2 days ago

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

139
Hhuang_ke·2 days ago

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

127
Ttang_hao·2 days ago

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

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

62
Oops_wang·2 days ago

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

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

59
Sswoole_lee·2 days ago

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

53
Bbob_chen·2 days ago

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

51
Zzhou_yi·5 hours ago

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

31
Zzhou_yi·2 days ago

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

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

28
Mmike_xu·2 days agoedited

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

16
Wwinter·2 days ago

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

163
Ddev_zhou·2 days ago

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

11
Zzhu_zong·2 days ago

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

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

9
Cchen_dev·2 days ago

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

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

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

4
Cchen_devMod·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
Llinlin·2 days agoedited

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

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

3
Ttang_hao·yesterday

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

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

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

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

1
NnikicMod·3 minutes ago

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

264
Sslow_query·2 days ago

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

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

39
Sslow_query·2 hours 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.

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

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

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

2
Llinlin·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

This is the post detail page /en/c/alertmanager-en/post/p11. 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 →