PWA · Interviews · Those easily-missed type details in pwa-interview

2.2K
PWr/pwa-interview·posted by nikic·6 hours agoInternals

Those easily-missed type details in pwa-interview

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.

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

Keep it and wait for an official fix44%
Switch to a third-party option now28%
Fork and maintain it ourselves17%
Write an adapter layer and wait11%

3779 votes total

383 comments

383 comments

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

490
Lli_ming·2 days ago

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

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

27
Lli_ming·1 hour ago

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

457
Ddev_zhou·12 minutes agoedited

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

45
Cchen_dev·2 days ago

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

45
Rrase·2 days agoedited

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

413
RraseMod·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.

410
KkiteMod·28 minutes ago

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

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

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

382
Kkernel_panicMod·2 days ago

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

140
Mmike_xu·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
Bbob_chenOP·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.

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

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

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

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

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

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

339
WwinterOP·2 days agoedited

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

275
Rrase·2 days ago

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

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

12
Lli_mingMod·2 days ago

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

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

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

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

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

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

311
Zzhou_yi·2 days ago

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

304
Sswoole_leeOP·2 days ago

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

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

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

87
Wwinter·2 days ago

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

291
Rran_bo·2 days ago

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

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

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

274
Bbob_chen·2 days ago

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

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

258
Hhuang_ke·12 minutes ago

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

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

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

96
Kkernel_panic·2 days ago

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

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

72
Wwinter·2 days agoedited

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

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

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

231
Cchen_devOP·2 days ago

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

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

215
Zzhou_yi·just now

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

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

192
Hhuang_ke·2 days ago

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

179
Lli_ming·3 minutes ago

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

173
Rrase·28 minutes ago

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

81
Oops_wang·2 days ago

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

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

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

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

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

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

161
Mmike_xu·5 hours ago

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

8
Rrase·2 days ago

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

67
Bbob_chen·2 days agoedited

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

55
Aalice_dev·2 days ago

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

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

73
Sswoole_lee·2 days agoLevel 6

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

257
Zzhou_yi·2 days ago

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

9
Kkite·2 days ago

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

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

152
KkiteMod·12 minutes agoedited

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

143
Kkite·2 days ago

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

4
Cchen_dev·2 days ago

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

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

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

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

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

103
Rrase·2 days ago

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

6
Aalice_dev·3 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.

99
Hhuang_ke·yesterday

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

87
Zzhou_yi·28 minutes ago

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

56
Zzhou_yi·2 days ago

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

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

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

238
Cchen_dev·12 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.

19
Zzhou_yiMod·2 days ago

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

19
Llinlin·5 hours agoedited

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

1
Zzhu_zong·2 days ago

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

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

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

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

125
Cchen_dev·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

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.

169
Lli_ming·2 days ago

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

126
Ddev_zhou·2 days ago

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

164
Zzhou_yi·2 days ago

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

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

18
Lli_ming·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
Rran_bo·28 minutes ago

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

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

31
Kkernel_panic·28 minutes ago

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

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

1
Aalice_devOP·12 minutes agoedited

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

70
Bbob_chen·2 days ago

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

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

321
Wwinter·2 days ago

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

15
Nnikic·28 minutes ago

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

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

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

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

352
Kkernel_panic·2 days ago

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

1
Aalice_dev·2 days agoedited

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

27
Zzhu_zong·12 minutes ago

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

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

44
Kkernel_panic·just now

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

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

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

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

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

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

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

1

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