Replication · Interviews · Why this replication-interview pattern gets slow in production: a source-level explanation

17
REr/replication-interview·posted by ran_bo·32 minutes agoInternals

Why this replication-interview pattern gets slow in production: a source-level explanation

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

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.

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

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.

6 comments

6 comments

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

348
Zzhu_zong·12 minutes 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.

428
Rran_bo·3 minutes ago

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

112
Ttang_hao·28 minutes ago

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

26
Kkernel_panicMod·just now

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

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

This is the post detail page /en/c/replication-interview/post/p6. 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 →