Editor · Reading list · Postmortem: how we exhausted the connection pool in editor-books

15
EDr/editor-books·posted by slow_query·just nowJobs

Postmortem: how we exhausted the connection pool in editor-books

Most editor-books 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.

Documentation first44%
Source code first28%
Just ask someone17%
Run a demo and learn by error11%

26 votes total

9 comments

9 comments

M
Mmike_xuMod·just now

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

307
Lli_mingOP·12 minutes ago

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

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

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

120
Zzhou_yi·12 minutes 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.

320
Rran_bo·3 minutes ago

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

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

64
Llinlin·3 minutes ago

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

45
Nnikic·28 minutes ago

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

1

This is the post detail page /en/c/editor-books/post/p9. 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 →