SWC · Interviews · Two weeks with swc-interview: what feels right and what drives me up the wall

1.1K
SWr/swc-interview·posted by ran_bo·6 hours agoTranslation

Two weeks with swc-interview: what feels right and what drives me up the wall

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

We also fixed monitoring along the way: replaced average-based alerts with percentiles and split them per endpoint. False alerts dropped by about seventy percent and the on-call rotation visibly cheered up.

Performance44%
Maintainability28%
Ecosystem and community17%
Hiring difficulty11%

1953 votes total

444 comments

444 comments

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

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

512
Oops_wangOP·2 days ago

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

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

497
Zzhou_yiOP·5 hours ago

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

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

486
Bbob_chen·3 minutes ago

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

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

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

417
Aalice_dev·2 days ago

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

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

316
RraseOP·2 days ago

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

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

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

302
Ttang_hao·2 days ago

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

297
Rrase·2 days ago

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

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

199
Zzhou_yiMod·just now

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

171
Wwinter·2 days ago

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

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

169
Mmike_xu·2 days agoedited

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

148
NnikicOP·2 days ago

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

103
Zzhou_yiOP·2 days ago

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

92
RraseOP·1 hour ago

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

68
Lli_ming·28 minutes agoedited

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

125
Llinlin·28 minutes ago

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

152
NnikicMod·3 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.

123
Oops_wang·12 minutes ago

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

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

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

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

46
Kkite·5 hours agoedited

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

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

89
Sswoole_leeMod·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.

444
Sslow_query·2 days ago

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

129
Sswoole_lee·yesterday

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

3
Nnikic·2 days ago

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

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

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

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

286
Wwinter·2 days ago

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

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

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

65
Lli_ming·2 days agoedited

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

45
Bbob_chen·2 days agoedited

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

34
Ddev_zhou·just now

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

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

30
Ddev_zhou·1 hour ago

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

2
Rrase·2 hours agoedited

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

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

25
Rrase·2 days ago

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

502
Zzhou_yi·yesterday

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

13
Rran_bo·2 hours agoLevel 6

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

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

215
Kkite·just now

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.

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

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

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

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

7
Hhuang_ke·1 hour 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
Wwinter·2 days agoLevel 6

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

2
Zzhu_zong·2 days agoedited

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

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

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

30
Wwinter·5 hours ago

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

248
Ttang_hao·2 days ago

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

81
Ddev_zhou·2 days ago

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

405
Hhuang_ke·2 days agoedited

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

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

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

1
Nnikic·2 days ago

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

27
Rran_bo·28 minutes ago

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

24
Bbob_chen·yesterdayedited

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.

22
Llinlin·2 days ago

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

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

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

13
Aalice_dev·2 days ago

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

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

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

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

56
Ttang_haoOP·2 days ago

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

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

40
Kkernel_panic·2 days 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.

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

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

152
Ttang_haoMod·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
KkiteOP·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.

14
Oops_wang·2 days ago

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

3
RraseMod·2 hours 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.

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

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

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

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

1
Zzhu_zong·2 days ago

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

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

34
Ddev_zhou·2 hours ago

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

116
Bbob_chen·2 days ago

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

394
Nnikic·2 days agoedited

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

229
Bbob_chen·2 days ago

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

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

1
Hhuang_keMod·2 days ago

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

33
Mmike_xuMod·5 hours agoedited

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

279
Rran_bo·2 days ago

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

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

364
Aalice_dev·2 days agoLevel 6

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

370
Ttang_hao·2 days agoLevel 6

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

205
Oops_wang·2 days ago

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

41
Wwinter·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
Ttang_hao·28 minutes ago

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

216
Sslow_query·3 minutes ago

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

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

83
WwinterMod·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.

82
Sswoole_lee·1 hour ago

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

17
RraseOP·2 days agoLevel 6

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

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

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

12
Kkernel_panicMod·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
Zzhou_yi·2 days ago

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

1

This is the post detail page /en/c/swc-interview/post/p3. 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 →