tmux · Advanced · After reading the tmux-pro core source I finally understand the trade-offs

2.3K
TMr/tmux-pro·posted by alice_dev·2 hours agoHelp

After reading the tmux-pro core source I finally understand the trade-offs

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.

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.

Image placeholder · object storage in production
POST /api/uploads → CDN origin pull
325 comments

325 comments

· first 120 loaded
M
Lli_ming·2 days ago

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

496
Zzhu_zong·2 days ago

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

488
Hhuang_ke·2 days ago

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

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

382
Lli_ming·2 days ago

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

217
Nnikic·28 minutes ago

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

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

134
Hhuang_ke·2 days ago

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

439
Zzhou_yi·2 days ago

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

400
Bbob_chen·2 days agoedited

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

396
Wwinter·2 days ago

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

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

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

338
RraseOP·12 minutes ago

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

264
Lli_ming·5 hours ago

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

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

318
Bbob_chen·2 days ago

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

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

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

301
Ddev_zhou·just now

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

280
Sswoole_lee·2 days ago

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

417
Wwinter·1 hour ago

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

1
Zzhou_yi·yesterday

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.

72
Zzhu_zong·2 days ago

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

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

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

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

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

183
Sswoole_lee·just now

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

180
NnikicOPMod·2 days ago

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

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

383
Sslow_query·2 days ago

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

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

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

148
Kkernel_panic·2 days agoedited

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

133
Sslow_query·2 days ago

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

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

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

210
Nnikic·2 days agoedited

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

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

4
Cchen_dev·2 days ago

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

454
Kkernel_panic·2 days ago

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

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

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

448
Zzhu_zong·2 days ago

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

102
Mmike_xuOPMod·2 days ago

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

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

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

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

103
WwinterOP·3 minutes ago

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

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

5
Llinlin·2 days ago

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

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

1
Llinlin·just now

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.

3
Bbob_chenOP·5 hours ago

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

168
Kkite·2 days ago

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

149
Zzhu_zongOP·12 minutes ago

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

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

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

49
Cchen_dev·12 minutes agoLevel 6

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

449
Oops_wangOP·yesterdayLevel 6

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

274
Kkernel_panic·2 days agoLevel 6

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

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

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

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

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

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

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

53
Sswoole_lee·2 days ago

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

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

53
Zzhu_zong·2 days agoLevel 6

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

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

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

39
Lli_ming·2 days agoedited

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

35
Kkernel_panicOP·12 minutes agoLevel 6

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

460
Ttang_hao·2 days agoedited

One counter-example: below tmux-pro 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
Kkite·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.

336
Nnikic·yesterdayLevel 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.

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

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

61
Bbob_chen·5 hours ago

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

52
Zzhu_zongOP·5 hours ago

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

23
Llinlin·2 days ago

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

248
Oops_wang·2 days ago

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

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

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

32
Rrase·2 days ago

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

31
Zzhu_zong·28 minutes ago

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

27
WwinterMod·2 days ago

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

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

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

16
Wwinter·5 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.

197
Oops_wang·2 days ago

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

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

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

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

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

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

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

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

7
Nnikic·2 days ago

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

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

9
Rran_bo·2 days ago

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

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

4
Bbob_chen·2 days ago

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

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

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

2
Hhuang_ke·2 days ago

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

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

2
Ddev_zhou·just now

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

163
Nnikic·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
Zzhu_zongOP·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.

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

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

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

55
Kkernel_panicMod·2 days ago

One counter-example: below tmux-pro 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
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.

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

1
Zzhu_zong·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
Ttang_hao·2 days ago

One counter-example: below tmux-pro 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/tmux-pro/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 →