Polars · Beginners · Interview notes: how I answered a question about the polars-newbie concurrency model

1.7K
POr/polars-newbie·posted by rase·32 minutes agoJobs

Interview notes: how I answered a question about the polars-newbie concurrency model

Most polars-newbie articles stop at "how to use it" and never cover "when not to use it". This is an attempt at the second half.

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

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

913 comments

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

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

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

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

138
Rrase·12 minutes ago

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

105
Aalice_dev·2 days ago

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

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

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

467
Ttang_hao·2 days ago

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

173
WwinterOP·just now

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

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

458
Zzhou_yi·12 minutes ago

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

457
Mmike_xu·3 minutes 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.

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

386
Zzhou_yi·2 days ago

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

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

397
Rran_bo·2 days ago

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

379
Wwinter·28 minutes 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.

361
Ttang_hao·28 minutes ago

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

508
Kkite·2 days ago

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

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

163
Rran_boOP·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.

55
Kkite·2 days agoedited

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

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

412
Wwinter·2 days ago

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

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

360
LlinlinMod·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.

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

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

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

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

1
Kkernel_panic·12 minutes ago

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

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

20
Zzhu_zong·2 days ago

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

112
Mmike_xu·2 days agoedited

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

86
Wwinter·just now

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.

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

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

266
Kkernel_panic·yesterdayedited

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

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

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

271
Lli_ming·2 days ago

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

276
Sswoole_lee·2 days agoLevel 6

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

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

22
Sswoole_lee·28 minutes ago

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

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

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

172
Lli_ming·just nowLevel 6

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

82
Hhuang_ke·2 days agoLevel 6

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

19
Kkernel_panicOP·yesterday

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.

443
Nnikic·2 days agoLevel 6

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

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

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

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

119
Hhuang_ke·2 days agoLevel 6

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

118
KkiteMod·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.

35
Kkite·2 days agoLevel 6

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

286
Zzhu_zongOP·5 hours ago

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

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

283
Rrase·2 days ago

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

374
Zzhou_yi·2 days ago

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

277
Zzhou_yi·12 minutes ago

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

274
Mmike_xu·1 hour ago

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

262
Sswoole_leeOP·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.

201
Aalice_dev·2 days ago

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

249
Llinlin·yesterday

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

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

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

195
Cchen_dev·2 days ago

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

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

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

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

110
Hhuang_ke·12 minutes ago

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

167
Lli_mingMod·28 minutes ago

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

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

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

51
Aalice_dev·2 days ago

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

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

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

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

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

76
Kkite·28 minutes ago

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

85
RraseMod·2 days ago

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

84
WwinterOP·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
Cchen_dev·just now

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

55
Lli_ming·2 days agoedited

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

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

42
Hhuang_ke·2 days ago

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

24
Kkernel_panic·2 days ago

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

17
LlinlinMod·5 hours ago

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

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

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

271
Llinlin·2 days ago

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

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

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

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

2
Llinlin·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
Bbob_chen·2 days agoedited

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

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

4
NnikicMod·12 minutes ago

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

1
Sswoole_lee·yesterday

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

73
Oops_wang·28 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.

275
Aalice_dev·2 days ago

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

325
Nnikic·2 days ago

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

333
Zzhou_yi·2 days agoLevel 6

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

1
Ttang_haoMod·28 minutes ago

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

276
Sswoole_lee·2 days ago

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

211
Rran_bo·2 days ago

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

403
Kkernel_panic·2 days ago

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

150
Mmike_xu·2 days agoedited

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

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

245
Rrase·2 days ago

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

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

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

1
Bbob_chen·2 hours agoedited

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

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

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

28
Nnikic·2 days agoedited

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

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

1

This is the post detail page /en/c/polars-newbie/post/p8. 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 →