Modding · Reading list · I built a small tool with modding-books — code is open, feedback welcome

1.1K
MOr/modding-books·posted by alice_dev·2 hours agoTutorial

I built a small tool with modding-books — code is open, feedback welcome

Most modding-books 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;

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.

145 comments

145 comments

· first 120 loaded
M
Nnikic·just now

One counter-example: below modding-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.

516
Rrase·just now

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.

248
Llinlin·2 days ago

One counter-example: below modding-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.

134
Bbob_chen·2 days ago

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

298
KkiteOP·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
Nnikic·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.

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

102
Mmike_xu·2 days ago

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

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

135
Mmike_xu·2 days agoLevel 6

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

35
Zzhu_zong·2 days agoLevel 6

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

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

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

40
Llinlin·28 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.

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

35
Kkernel_panic·2 days ago

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

16
Rrase·2 days agoedited

One counter-example: below modding-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.

493
Wwinter·2 days ago

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

482
Bbob_chenOP·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.

421
Aalice_dev·2 days ago

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

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

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

423
Aalice_devOP·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.

359
Sswoole_lee·2 days ago

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

399
Wwinter·28 minutes ago

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

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

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

301
Bbob_chen·2 days ago

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

5
Oops_wang·2 days ago

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

356
Oops_wang·12 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.

346
Llinlin·28 minutes ago

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

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

93
Bbob_chenMod·1 hour agoedited

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

297
Mmike_xu·2 days ago

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

255
Aalice_dev·2 days agoedited

One counter-example: below modding-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.

146
Lli_ming·just now

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.

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

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

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

223
Cchen_devOP·12 minutes ago

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

138
Wwinter·28 minutes ago

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

206
Nnikic·2 days ago

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

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

155
Lli_mingOP·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.

1
Wwinter·5 hours ago

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

21
Ttang_haoMod·2 days agoLevel 6

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.

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

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

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

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

135
Cchen_dev·just now

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.

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

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

210
Mmike_xu·2 days ago

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

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

509
Nnikic·2 days ago

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

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

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

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

53
Zzhu_zong·just now

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

96
NnikicOP·2 days agoedited

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

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

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

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

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

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

238
Hhuang_ke·2 days ago

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

30
Aalice_devOP·2 days ago

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

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

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

49
Sswoole_lee·2 days ago

One counter-example: below modding-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
Kkernel_panic·2 days ago

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

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

196
Hhuang_ke·28 minutes ago

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

49
Hhuang_ke·2 hours 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.

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

44
Bbob_chen·2 hours agoedited

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

120
Ttang_hao·yesterday

One counter-example: below modding-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.

40
Mmike_xu·yesterday

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.

398
Cchen_dev·2 hours ago

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

38
Ddev_zhou·2 days ago

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

36
Oops_wang·12 minutes ago

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

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

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

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

227
Rran_bo·2 days ago

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

252
Ttang_hao·2 days agoLevel 6

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.

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

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

29
Kkite·2 days ago

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

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

275
Nnikic·2 hours ago

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

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

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

282
Mmike_xu·2 days ago

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

255
Hhuang_ke·2 days ago

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

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

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

383
Rran_boOP·2 days ago

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

321
Zzhou_yi·2 hours agoedited

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

49
Kkernel_panic·2 days ago

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

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

384
Rran_bo·2 days ago

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

455
Bbob_chen·2 days ago

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

1
Sswoole_leeMod·2 days agoedited

One counter-example: below modding-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.

14
Wwinter·2 days ago

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

149
Sslow_query·28 minutes ago

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

13
Zzhou_yi·2 days ago

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

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

104
Hhuang_ke·2 days ago

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

8
Bbob_chen·2 days ago

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

6
Bbob_chen·2 days ago

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

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

3
Hhuang_ke·2 days ago

One counter-example: below modding-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.

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

265
Kkernel_panic·2 days ago

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

2
Ddev_zhou·2 days ago

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

1
Kkernel_panicMod·2 days ago

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

1
Mmike_xu·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

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