Editor · Reading list · After reading the editor-books core source I finally understand the trade-offs

2.3K
EDr/editor-books·posted by ran_bo·3 days agoAnnouncement

After reading the editor-books core source I finally understand the trade-offs

Short version: editor-books needs almost no tuning at small and medium scale — the point where it starts to hurt is much further out than most people assume. Full measurements below.

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

# 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

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.

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.

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.

1066 comments

1066 comments

· first 120 loaded
M
Wwinter·3 minutes 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.

512
Lli_ming·just now

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

315
Aalice_dev·3 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.

355
Bbob_chen·2 days 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".

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

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

21
Ttang_hao·2 days ago

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

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

190
Sswoole_leeOP·2 days 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.

64
Rrase·2 days ago

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

419
Zzhu_zong·2 days agoedited

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

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

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

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

3
Bbob_chen·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
Rran_bo·just now

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.

2
Sslow_query·5 hours ago

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

499
Rrase·2 days ago

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

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

247
Aalice_dev·2 hours 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.

159
Rrase·2 days 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.

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

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

440
Kkernel_panicMod·2 days 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".

421
Nnikic·yesterday

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.

235
Rran_bo·2 days 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.

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

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

318
Cchen_dev·2 days 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.

401
Kkernel_panic·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
Ttang_hao·2 days 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.

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

73
Bbob_chenMod·2 days ago

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

298
Hhuang_ke·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.

373
Rrase·2 days ago

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

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

360
Aalice_devOP·2 days ago

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

237
Ttang_hao·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.

292
Lli_ming·2 days agoedited

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

255
Sslow_query·5 hours ago

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

244
Hhuang_keOP·2 days 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.

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

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

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

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

199
Cchen_devOP·12 minutes ago

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

134
Nnikic·3 minutes agoedited

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

113
Sslow_queryOP·3 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.

186
Rrase·yesterday

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

5
Kkernel_panic·yesterdayedited

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

239
Ttang_hao·2 days ago

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

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

6
Wwinter·just now

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

184
Zzhu_zong·2 days 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.

176
Ddev_zhou·2 days ago

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

149
Nnikic·1 hour ago

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

140
Ttang_hao·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.

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

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

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

97
Sswoole_leeOP·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.

25
Kkite·2 days ago

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

18
Llinlin·just now

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.

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

154
Ddev_zhou·2 days ago

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

71
Rrase·2 days 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.

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

84
Rran_bo·just now

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

439
Rran_boMod·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.

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

71
Lli_ming·28 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.

67
Bbob_chenMod·5 hours 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.

58
Nnikic·2 days ago

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

67
NnikicMod·2 days 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.

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

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

63
Zzhu_zong·1 hour ago

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

58
Kkite·2 days agoLevel 6

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

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

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

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

52
Rrase·2 days 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.

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

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

45
Zzhu_zong·2 days 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".

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

254
Ttang_hao·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.

195
Ddev_zhou·2 days 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".

35
Bbob_chen·2 days ago

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

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

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

515
Sswoole_leeOP·1 hour ago

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

272
Sslow_query·28 minutes ago

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

22
Rran_boOP·2 days ago

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

3
Oops_wang·yesterdayLevel 6

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.

40
Kkernel_panic·2 days ago

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

1
Llinlin·12 minutes ago

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

36
Llinlin·2 days ago

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

33
Wwinter·2 days 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.

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

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

114
Lli_ming·2 days ago

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

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

32
Aalice_dev·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
Rrase·2 days ago

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

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

12
Ddev_zhou·2 days 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.

166
Sswoole_lee·2 days ago

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

191
Llinlin·1 hour 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.

11
Hhuang_ke·2 days agoedited

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.

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

7
Sswoole_leeMod·just now

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

84
Hhuang_ke·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.

22
Kkernel_panic·5 hours ago

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

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

264
Ddev_zhou·2 days 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.

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

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

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

1
Rran_bo·2 days 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.

1

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