Capacitor · Ops · capacitor-ops under load on an 8-core 16GB box — full benchmark scripts included

13
CAr/capacitor-ops·posted by huang_ke·32 minutes agoTutorial

capacitor-ops under load on an 8-core 16GB box — full benchmark scripts included

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.

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

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

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.

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.

5 comments

5 comments

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

424
Ttang_haoMod·just now

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

221
Zzhou_yi·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".

313
KkiteOP·28 minutes agoedited

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.

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

146

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