Fortran · Resources · Cut our fortran-resources build from 4 minutes to 40 seconds with these 5 changes

949
FOr/fortran-resources·posted by linlin·1 hour agoTooling

Cut our fortran-resources build from 4 minutes to 40 seconds with these 5 changes

Short version: fortran-resources 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.

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.

# 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

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.

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.

465 comments

465 comments

· first 120 loaded
M
Ddev_zhouOPMod·12 minutes 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".

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

321
Sswoole_lee·2 days ago

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

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

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

21
Aalice_dev·2 hours ago

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

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

506
Cchen_dev·2 days agoedited

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

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

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

199
Hhuang_ke·28 minutes ago

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

443
Rrase·just nowedited

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.

387
Nnikic·2 days ago

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

143
Ddev_zhou·2 days ago

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

94
Kkernel_panicOP·2 hours 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.

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

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

26
NnikicOP·just now

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

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

9
Kkernel_panic·2 days ago

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

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

53
Kkernel_panicOP·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.

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

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

8
Nnikic·2 days ago

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

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

4
Cchen_dev·2 days ago

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

161
Zzhou_yi·2 days ago

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

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

428
Rran_bo·2 days ago

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

19
Hhuang_ke·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".

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

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

117
Rran_boOP·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".

366
Sslow_query·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".

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

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

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

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

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

14
Lli_ming·2 days ago

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

336
Sslow_queryOP·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.

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

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

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

124
Kkernel_panic·28 minutes 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.

215
Hhuang_ke·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".

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

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

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

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

282
Zzhu_zong·2 days ago

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

473
Nnikic·2 days ago

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

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

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

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

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

52
Ttang_hao·5 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
Rran_bo·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".

233
NnikicOP·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.

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

62
Ddev_zhouMod·5 hours 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.

167
Ttang_hao·3 minutes ago

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

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

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

50
Ttang_hao·2 days ago

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

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

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

94
Mmike_xu·2 days agoedited

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

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

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

134
Zzhu_zong·2 days ago

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

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

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

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

113
Hhuang_keOP·2 days ago

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

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

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

515
Rrase·2 days ago

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

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

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

42
Ddev_zhouOP·2 days ago

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

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

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

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

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

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

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

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

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

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

168
Sslow_queryOP·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.

381
Nnikic·2 days ago

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

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

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

508
Zzhou_yi·2 days ago

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

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

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

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

257
Zzhu_zong·1 hour ago

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

105
Mmike_xuOP·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".

36
Sslow_query·1 hour agoLevel 6

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.

78
Wwinter·2 days ago

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

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

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

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

18
Bbob_chen·12 minutes ago

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

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

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

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

30
Kkite·2 days ago

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

2
Hhuang_ke·2 days agoedited

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

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

2
Cchen_dev·1 hour 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
Rrase·2 days ago

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

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

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

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

1
Ttang_hao·2 days ago

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

1

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