Fortran · Resources · Interview notes: how I answered a question about the fortran-resources concurrency model

542
FOr/fortran-resources·posted by ops_wang·2 hours agoExperience

Interview notes: how I answered a question about the fortran-resources concurrency model

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.

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.

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.

Ggithub.comExternal link · opens in a new tab
82 comments

82 comments

M
Rran_bo·2 days ago

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

513
Llinlin·just nowedited

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

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

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

499
Oops_wangOP·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.

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

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

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

89
Lli_ming·3 minutes ago

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

519
Bbob_chen·2 days ago

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

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

20
Mmike_xu·yesterday

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

22
Kkernel_panicOP·1 hour agoLevel 6

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

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

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

39
Llinlin·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".

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

4
Mmike_xu·2 hours ago

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

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

342
Zzhou_yi·3 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.

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

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

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

8
Llinlin·yesterday

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

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

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

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

252
Nnikic·1 hour agoedited

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

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

116
Kkernel_panic·5 hours agoedited

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

273
Hhuang_ke·2 days agoedited

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.

414
Mmike_xu·just now

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

183
Llinlin·2 hours agoedited

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

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

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

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

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

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

13
Aalice_devOP·2 days agoLevel 6

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

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

13
Ttang_hao·2 days agoLevel 6

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

1
Kkernel_panic·2 days ago

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

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

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

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

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

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

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

149
Rrase·3 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".

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

87
Llinlin·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".

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

125
Ttang_hao·2 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.

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

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

77
Aalice_dev·just now

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

509
Lli_ming·5 hours ago

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

162
Zzhu_zongOP·2 days ago

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

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

332
NnikicOPMod·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.

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

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

255
Ddev_zhouMod·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.

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

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

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

45
Aalice_dev·28 minutes ago

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

44
Bbob_chen·just now

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.

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

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

20
Ddev_zhou·2 days ago

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

39
Sslow_query·12 minutes ago

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

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

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

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

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

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

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

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

244
Hhuang_ke·just now

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

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

1

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