Fortran · Resources · War story: fortran-resources timezone handling almost cost us a full day of billing

2.2K
FOr/fortran-resources·posted by li_ming·2 days agoReview

War story: fortran-resources 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.

Order of investigation, by return on effort: 1. Check downstream latency first — usually it is not your problem 2. Then pool hit rate and wait-queue length 3. Only then GC and allocation 4. Suspect the framework last

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.

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.

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.

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

966 comments

966 comments

· first 120 loaded
M
Sslow_query·2 days agoedited

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

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

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

16
Mmike_xu·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
Lli_ming·3 minutes ago

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

447
Zzhu_zong·12 minutes agoedited

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

485
Zzhou_yi·2 days ago

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

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

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

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

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

365
Zzhou_yi·2 days ago

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

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

320
Rrase·2 days ago

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

319
Kkernel_panic·just now

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

293
Ddev_zhou·just now

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

505
Sswoole_lee·3 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.

46
Oops_wang·2 days ago

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

57
Aalice_dev·2 days ago

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

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

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

38
Sswoole_lee·2 days ago

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

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

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

20
Bbob_chen·3 minutes agoedited

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

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

71
Sslow_query·2 days agoedited

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

19
Sswoole_lee·12 minutes ago

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

251
Zzhou_yi·2 days ago

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

213
Sslow_query·2 days ago

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

108
Aalice_dev·2 days ago

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

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

342
Bbob_chen·2 days ago

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

215
Kkite·2 days ago

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

135
Wwinter·2 days ago

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

161
Llinlin·5 hours agoedited

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

280
Lli_ming·2 days ago

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

248
Wwinter·2 days agoedited

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

80
Wwinter·2 days ago

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

230
Bbob_chen·2 days ago

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

223
Zzhou_yiOP·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
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.

222
Bbob_chen·2 days ago

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

220
Aalice_devMod·2 days ago

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

220
Kkernel_panicOPMod·2 days ago

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

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

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

142
Kkernel_panicMod·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
Rrase·2 days ago

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

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

82
Lli_ming·2 days ago

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

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

136
Aalice_dev·2 days ago

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

133
Llinlin·2 days ago

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

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

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

46
Rran_bo·2 days agoedited

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

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

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

89
Wwinter·2 days ago

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

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

51
Ttang_hao·3 minutes ago

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

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

46
Bbob_chenMod·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.

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

12
Rran_bo·12 minutes ago

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

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

11
Zzhou_yi·1 hour ago

One counter-example: below fortran-resources 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
Zzhu_zong·12 minutes ago

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

131
Sslow_query·2 days agoedited

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

166
Oops_wang·2 days agoedited

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

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

6
Sswoole_lee·2 days ago

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

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

392
Ttang_haoOP·just now

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

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

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

97
Ddev_zhou·3 minutes ago

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

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

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

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

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

130
Rran_bo·2 days ago

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

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

385
Rrase·2 days agoLevel 6

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

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

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

64
Llinlin·2 days ago

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

53
Hhuang_ke·2 days agoLevel 6

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

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

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

4
Ddev_zhou·5 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.

23
Lli_ming·2 days ago

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

343
Rran_boOP·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.

99
Zzhu_zong·28 minutes ago

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

57
Oops_wang·2 days agoLevel 6

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

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

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

307
Rran_bo·just nowLevel 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.

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

112
RraseOP·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.

47
Zzhu_zong·2 days ago

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

149
Ddev_zhou·2 days agoLevel 6

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

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

21
Oops_wang·2 days agoeditedLevel 6

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

184
Lli_ming·2 days agoedited

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

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

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

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

214
Lli_ming·2 days ago

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

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

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

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

122
Kkernel_panic·2 days ago

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

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

5
Rrase·2 days ago

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

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

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

45
RraseMod·2 days ago

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

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

1

This is the post detail page /en/c/fortran-resources/post/p10. 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 →