Alertmanager · English · Six rules for error handling in alertmanager-en that I settled on

2.0K
ALr/alertmanager-en·posted by mike_xu·5 minutes agoJobsPinned

Six rules for error handling in alertmanager-en that I settled on

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

The first thing was to collapse the variables. We were changing config and upgrading the version at the same time, and afterwards nobody could say which change caused what. We rolled back to moving one variable at a time, re-ran three times, and only then did the curve settle. Tedious, but not skippable.

# Load test: do not jump straight to the max concurrency.
# Ramp it up, otherwise you miss the knee.
for c in 50 100 200 400 800; do
  wrk -t8 -c$c -d60s --latency http://127.0.0.1:8080/api/feed
  sleep 20
done

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

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

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.

420 comments

420 comments

· first 120 loaded
M
Aalice_dev·2 days agoedited

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.

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

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

129
Ddev_zhou·2 days ago

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

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

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

236
Ddev_zhouOP·2 days agoLevel 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.

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

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

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

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

277
KkiteOP·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.

416
Hhuang_ke·28 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.

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

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

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

247
Sswoole_lee·2 days ago

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

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

147
Bbob_chen·2 days ago

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

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

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

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

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

442
Sswoole_lee·2 days agoLevel 6

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

425
Cchen_dev·2 days agoeditedLevel 6

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.

178
Mmike_xuOP·2 days agoLevel 6

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

30
Rrase·5 hours agoLevel 6

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

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

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

161
Llinlin·yesterdayLevel 6

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

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

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

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

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

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

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

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

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

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

490
Lli_ming·2 days agoeditedLevel 6

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.

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

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

136
Kkernel_panic·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".

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

299
Kkite·2 days ago

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

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

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

112
Mmike_xu·2 days agoedited

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

15
Cchen_dev·2 days ago

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

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

54
Llinlin·2 days ago

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

54
Ttang_haoOP·28 minutes 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".

3
Oops_wang·2 days ago

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

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

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

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

209
Oops_wangOP·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.

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

170
Rrase·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".

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

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

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

143
Kkernel_panic·2 days ago

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

429
Ttang_hao·2 days ago

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

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

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

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

104
Rrase·2 days ago

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

102
Kkite·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".

136
Wwinter·2 days ago

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

323
Nnikic·2 days ago

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

98
Aalice_dev·2 days ago

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

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

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

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

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

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

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

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

18
Llinlin·2 days ago

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

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

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

59
Bbob_chen·2 days ago

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

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

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

57
Aalice_dev·3 minutes ago

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

56
Aalice_dev·just now

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.

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

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

255
Hhuang_keMod·2 days ago

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

14
Aalice_devMod·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".

12
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
Bbob_chen·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
Cchen_dev·just now

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

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

18
Sswoole_lee·1 hour ago

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

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

160
Sswoole_lee·yesterdayedited

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.

52
Sslow_queryOPMod·2 days ago

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

134
Sswoole_lee·2 days agoedited

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

41
Nnikic·yesterday

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

39
Mmike_xu·2 days ago

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

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

22
Lli_ming·2 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.

20
KkiteMod·5 hours 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".

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

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

15
Cchen_dev·2 days ago

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

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

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

13
Zzhou_yi·2 days ago

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

4
Bbob_chen·5 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.

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

85
Sswoole_lee·2 days ago

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

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

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

335
Sslow_query·2 days agoLevel 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.

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

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

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

1

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