Linux Community · Ten linux anti-patterns — how many are you guilty of?

1.7K
LIr/linux·posted by alice_dev·3 hours agoTranslation

Ten linux anti-patterns — how many are you guilty of?

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

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.

Ddeveloper.mozilla.orgExternal link · opens in a new tab
975 comments

975 comments

· first 120 loaded
M
Mmike_xuOP·2 days ago

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

472
Ddev_zhou·2 days ago

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

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

483
Aalice_dev·2 days ago

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

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

438
Rran_bo·yesterday

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

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

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

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

238
Oops_wang·2 days ago

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

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

375
Zzhu_zong·2 days ago

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

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

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

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

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

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

253
Cchen_dev·yesterdayedited

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.

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

51
Ddev_zhou·3 minutes ago

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

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

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

264
Llinlin·yesterday

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.

497
Aalice_dev·2 days ago

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

405
Ttang_haoMod·just now

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

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

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

274
Hhuang_ke·2 days agoeditedLevel 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.

206
Bbob_chen·12 minutes agoedited

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

490
Zzhu_zong·5 hours 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.

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

303
WwinterOP·just nowedited

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.

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

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

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

28
RraseOP·2 days ago

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

38
Aalice_devOP·12 minutes ago

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

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

22
Cchen_dev·2 days ago

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

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

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

362
Bbob_chenOP·2 hours ago

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

106
Kkernel_panic·yesterday

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

216
Bbob_chen·2 days agoedited

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

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

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

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

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

82
Hhuang_ke·2 days agoLevel 6

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

370
Sswoole_lee·2 days ago

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

81
Aalice_dev·2 days agoeditedLevel 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.

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

125
Llinlin·2 days agoLevel 6

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

11
Rrase·2 days ago

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

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

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

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

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

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

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

266
Nnikic·2 days ago

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

211
Sslow_query·2 hours agoedited

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

193
Ttang_hao·28 minutes ago

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

192
Hhuang_ke·2 days ago

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

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

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

205
Wwinter·2 days ago

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

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

132
Kkernel_panic·just now

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

114
Oops_wangOP·2 days ago

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

99
LlinlinOP·2 days ago

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

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

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

100
Ttang_hao·2 days ago

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

112
Ddev_zhou·yesterday

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

194
LlinlinOP·2 days ago

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

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

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

97
Rrase·28 minutes ago

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

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

401
Lli_ming·28 minutes agoedited

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

353
Wwinter·2 days ago

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

287
Nnikic·just now

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

165
Zzhou_yi·just now

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

73
Aalice_dev·2 days ago

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

147
Kkernel_panic·12 minutes ago

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

259
Kkite·2 days ago

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

52
Cchen_devOP·2 days ago

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

5
Zzhu_zong·2 days ago

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

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

4
Kkite·2 days ago

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

441
Cchen_dev·2 days ago

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

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

1
Mmike_xu·2 days ago

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

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

485
Rran_boOP·28 minutes ago

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

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

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

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

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

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

17
Ddev_zhouOP·2 days ago

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

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

446
Wwinter·2 days ago

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

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

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

17
Wwinter·2 days ago

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

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

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

13
Sslow_query·2 days ago

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

60
Ttang_hao·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
Hhuang_ke·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.

14
Zzhu_zong·2 days ago

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

43
Lli_ming·2 days ago

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

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

13
Rran_bo·yesterdayedited

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

8
Cchen_dev·3 minutes ago

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

1
Rrase·3 minutes ago

One counter-example: below linux 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
Kkernel_panic·yesterday

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/linux/post/p9. 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 →