Capacitor · Ops · I built a small tool with capacitor-ops — code is open, feedback welcome

1.2K
CAr/capacitor-ops·posted by ran_bo·3 hours agoExperience

I built a small tool with capacitor-ops — code is open, feedback welcome

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

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.

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

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.

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

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.

142 comments

142 comments

· first 120 loaded
M
Mmike_xuOP·2 days ago

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

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

72
Kkernel_panic·2 days ago

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

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

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

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

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

513
Cchen_devOPMod·2 days ago

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

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

11
Llinlin·2 days ago

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

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

483
Ddev_zhou·1 hour ago

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

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

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

472
Mmike_xu·2 hours ago

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

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

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

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

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

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

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

329
Wwinter·2 days ago

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

53
Rran_bo·2 days ago

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

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

323
Zzhou_yi·yesterday

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

295
Zzhu_zong·yesterday

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

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

513
Rrase·2 days ago

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

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

259
Wwinter·2 days agoedited

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

164
Rran_bo·2 days ago

One counter-example: below capacitor-ops 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
Hhuang_ke·2 days ago

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

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

220
Zzhu_zong·2 days ago

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

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

205
Ddev_zhou·3 minutes ago

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

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

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

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

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

160
Ttang_hao·yesterday

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.

138
Nnikic·2 days ago

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

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

202
Kkernel_panic·2 days ago

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

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

76
Kkernel_panic·12 minutes ago

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

127
Ttang_hao·28 minutes agoedited

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

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

509
Cchen_dev·2 hours ago

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

324
Bbob_chen·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
Cchen_dev·12 minutes ago

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

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

224
Rran_bo·2 days agoLevel 6

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

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

228
Lli_ming·2 days ago

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

419
Kkernel_panicMod·3 minutes ago

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

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

13
Oops_wangOP·1 hour ago

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

211
Sslow_queryMod·2 days ago

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

251
Sswoole_lee·just now

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

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

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

305
Rrase·2 days agoLevel 6

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

32
Kkernel_panic·2 hours ago

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

114
Rran_bo·2 days ago

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

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

367
Ddev_zhou·2 days agoedited

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

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

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

86
Lli_ming·yesterday

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

503
Kkite·2 days ago

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

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

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

76
Llinlin·3 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.

65
Mmike_xu·2 days agoedited

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

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

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

59
Llinlin·2 days ago

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

53
Ttang_hao·12 minutes ago

One counter-example: below capacitor-ops 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
Ttang_hao·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.

362
Rrase·2 days ago

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

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

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

40
Bbob_chen·yesterdayedited

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

31
Ttang_hao·2 days ago

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

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

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

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

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

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

1
Zzhou_yi·2 days ago

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

17
Llinlin·2 days ago

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

15
Oops_wangMod·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
Sswoole_lee·2 days ago

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

10
Mmike_xu·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
Kkernel_panic·just nowedited

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.

175
Zzhou_yi·2 days ago

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

41
Kkernel_panicOP·2 days agoedited

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

422
WwinterMod·yesterday

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.

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

102
Bbob_chen·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
Sswoole_lee·2 days ago

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

181
Cchen_dev·2 days agoedited

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

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

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

8
Nnikic·2 days ago

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

20
Llinlin·yesterday

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.

5
Llinlin·2 days ago

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

4
Zzhu_zong·2 days ago

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

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

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

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

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

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

1
Zzhou_yi·2 days agoedited

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

5
Zzhu_zong·2 days ago

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

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

5

This is the post detail page /en/c/capacitor-ops/post/p8. 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 →