Editor · Reading list · War story: editor-books timezone handling almost cost us a full day of billing

1.5K
EDr/editor-books·posted by linlin·yesterdayInternals

War story: editor-books timezone handling almost cost us a full day of billing

It took me two weeks of on-and-off digging and plenty of wrong turns. Writing the process down as it happened so the next person spends less time.

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

Bblog.vuejs.orgExternal link · opens in a new tab
363 comments

363 comments

· first 120 loaded
M
Kkite·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.

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

471
Mmike_xu·3 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.

452
Mmike_xu·3 minutes 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.

448
Lli_ming·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".

8
Aalice_dev·2 days agoedited

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

413
Rrase·2 days ago

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

354
Kkite·2 days ago

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

32
Nnikic·2 days agoedited

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.

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

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

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

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

265
Sslow_query·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.

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

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

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

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

249
Oops_wang·2 days ago

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

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

132
Bbob_chen·2 days ago

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

229
Ttang_hao·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".

222
Rrase·12 minutes ago

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

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

179
Ddev_zhou·2 days ago

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

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

148
Llinlin·2 days ago

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

131
Zzhou_yiOP·2 days ago

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

60
Mmike_xu·2 days ago

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

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

115
NnikicMod·2 hours ago

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

109
Aalice_dev·2 days agoedited

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

105
Wwinter·yesterday

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

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

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

355
Sslow_queryOP·12 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.

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

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

59
Sslow_query·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.

57
Oops_wang·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".

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

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

39
Nnikic·2 days ago

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

44
Mmike_xu·2 hours 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.

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

31
Oops_wang·just nowedited

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

15
Lli_ming·5 hours 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.

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

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

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

73
Zzhou_yi·2 days ago

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

125
Mmike_xuMod·2 days ago

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

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

10
Rrase·28 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.

8
Ttang_hao·3 minutes ago

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

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

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

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

311
Rran_bo·2 days agoLevel 6

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.

462
Mmike_xuMod·2 days agoLevel 6

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

261
Zzhou_yiOP·2 days agoLevel 6

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

131
Oops_wang·just noweditedLevel 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.

23
Bbob_chen·2 days agoedited

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.

63
Bbob_chen·2 hours 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.

46
Oops_wang·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".

129
Lli_ming·12 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".

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

250
Zzhu_zong·2 days agoLevel 6

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.

25
Zzhu_zong·yesterday

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.

263
Rrase·2 days agoLevel 6

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.

396
Zzhu_zong·2 days agoLevel 6

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

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

6
Wwinter·yesterday

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

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

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

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

9
Kkernel_panic·just nowedited

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.

206
Cchen_devOP·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.

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

59
Rran_bo·2 days agoLevel 6

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.

276
Rran_bo·2 days agoLevel 6

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

72
Ddev_zhou·3 minutes agoLevel 6

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

2
Zzhu_zong·2 hours ago

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

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

97
Ddev_zhouOP·28 minutes ago

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

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

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

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

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

226
Bbob_chen·2 days ago

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

6
Kkernel_panic·12 minutes ago

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

96
Rran_bo·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
Aalice_dev·2 days ago

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

140
Mmike_xu·1 hour agoeditedLevel 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.

517
Rran_bo·2 days agoLevel 6

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

43
Hhuang_ke·2 days agoedited

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.

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

2
Ttang_hao·12 minutes ago

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

139
Sslow_query·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.

233
Rrase·2 days ago

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

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

277
Rran_bo·2 days agoLevel 6

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.

40
Bbob_chen·2 days agoLevel 6

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

1
Rrase·3 minutes ago

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

115
Llinlin·2 days ago

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

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

150
Sslow_query·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.

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

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

344
RraseOP·yesterday

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.

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

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

163
Sswoole_lee·2 days agoLevel 6

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.

216
Sswoole_lee·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".

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

199
Hhuang_ke·just nowedited

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.

75
Llinlin·2 days ago

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

237
Sslow_query·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
Rrase·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.

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

1

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