Linux Community · I upgraded our production linux and hit these 11 landmines

358
LIr/linux·posted by ran_bo·2 days agoAnnouncement

I upgraded our production linux and hit these 11 landmines

Some background first. Our setup is linux plus three downstream services, seven figures of daily requests, peaking around nine in the evening.

// Minimal reproduction: you must use a real long-tail distribution here.
// Uniform load-test traffic will never trigger this.
func (s *Server) handle(ctx context.Context) error {
    conn, err := s.pool.Acquire(ctx)
    if err != nil {
        return fmt.Errorf("acquire: %w", err)
    }
    defer conn.Release()

    return s.do(ctx, conn)
}

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

Worth noting: the official docs do cover this, just in a very inconspicuous spot. I only found it reading the source comments, where the author explains the reasoning — roughly "so that it degrades into predictable behaviour in extreme cases".

137 comments

137 comments

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

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

515
Nnikic·2 days ago

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

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

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

360
Lli_ming·2 days ago

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

359
Kkernel_panic·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".

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

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

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

318
Cchen_dev·2 days ago

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

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

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

10
Zzhu_zong·2 days ago

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

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

118
Lli_ming·2 days ago

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

489
Hhuang_keOP·2 days agoLevel 6

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

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

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

60
Sswoole_lee·2 days agoLevel 6

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

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

448
Sswoole_lee·5 hours ago

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

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

264
Llinlin·5 hours agoLevel 6

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

514
Zzhu_zong·2 days agoLevel 6

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.

403
Zzhu_zong·12 minutes agoLevel 6

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

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

107
Kkite·2 days agoeditedLevel 6

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.

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

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

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

440
Nnikic·28 minutes 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.

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

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

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

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

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

153
Llinlin·2 days agoLevel 6

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

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

7
Mmike_xu·2 days ago

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

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

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

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

20
Cchen_dev·yesterday

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.

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

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

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

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

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

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

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

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

66
Kkernel_panic·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
Hhuang_ke·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.

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

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

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

11
Ttang_hao·2 days ago

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

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

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

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

420
Zzhou_yi·yesterday

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

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

242
Rran_boMod·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.

240
Bbob_chen·2 days agoedited

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

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

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

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

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

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

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

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

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

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

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

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

114
Mmike_xu·2 days ago

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

112
Kkite·2 days ago

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

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

69
Rran_bo·2 days agoedited

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

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

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

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

249
Sslow_queryOP·2 days agoedited

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

295
KkiteOP·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.

61
Aalice_dev·2 days agoLevel 6

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

22
Kkite·2 days agoLevel 6

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

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

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

73
Aalice_dev·2 days ago

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

152
Nnikic·2 days ago

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

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

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

70
Rrase·yesterday

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

61
Rran_bo·yesterday

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

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

66
KkiteOP·2 days ago

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

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

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

428
Bbob_chen·12 minutes ago

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

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

31
Lli_ming·1 hour agoedited

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

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

71
Zzhou_yi·12 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.

403
Nnikic·2 days ago

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

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

77
Sslow_queryMod·28 minutes 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.

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

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

5
Wwinter·2 days ago

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

26
Zzhou_yi·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".

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

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

15
Cchen_dev·2 days ago

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

15
Zzhou_yi·just now

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

5
Rrase·3 minutes ago

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

3
Rran_bo·1 hour 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.

3
Wwinter·2 days agoedited

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

1

This is the post detail page /en/c/linux/post/p6. 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 →