PWA · Interviews · Discussion: is the pwa-interview ecosystem being replaced by another stack?

1.1K
PWr/pwa-interview·posted by zhou_yi·5 minutes agoExperience

Discussion: is the pwa-interview ecosystem being replaced by another stack?

Short version: pwa-interview needs almost no tuning at small and medium scale — the point where it starts to hurt is much further out than most people assume. Full measurements below.

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

// 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)
}

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 pwa-interview itself but our upstream connection reuse — the load test traffic was too clean and hid the long-tail requests.

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.

One last trap: in container environments remember to adjust the memory-related parameters in step. Otherwise the host limit and the process expectation disagree, and the symptom is intermittent, unreproducible failure.

168 comments

168 comments

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

492
Sslow_queryMod·just now

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.

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

416
Zzhou_yi·1 hour ago

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

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

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

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

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

109
Rrase·2 days agoedited

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

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

40
Lli_ming·3 minutes ago

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

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

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

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

22
Wwinter·12 minutes ago

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

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

35
Mmike_xuOP·2 hours 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.

44
Ddev_zhou·2 days agoLevel 6

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

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

24
Wwinter·2 days agoLevel 6

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

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

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

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

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

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

14
Kkernel_panic·2 days ago

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

12
RraseMod·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
Bbob_chenMod·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.

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

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

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

449
Lli_ming·12 minutes 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
Zzhou_yi·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.

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

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

144
Sslow_query·2 days agoeditedLevel 6

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

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

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

47
Zzhou_yi·3 minutes ago

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

2
Rran_boOP·3 minutes ago

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

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

70
Ddev_zhou·2 hours 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.

198
Nnikic·2 days agoedited

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

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

14
Ttang_hao·2 days agoLevel 6

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

108
Mmike_xu·2 days agoLevel 6

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

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

2
Rran_boMod·2 days agoLevel 6

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

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

128
Mmike_xu·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".

265
WwinterOPMod·2 days agoLevel 6

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

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

2
Nnikic·2 days agoLevel 6

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

105
Sswoole_lee·2 days agoLevel 6

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

37
Llinlin·12 minutes agoLevel 6

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.

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

47
Wwinter·just now

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

445
Zzhou_yi·2 hours 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".

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

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

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

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

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

407
Llinlin·2 days ago

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

390
Bbob_chen·2 days ago

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

388
Aalice_dev·2 days agoedited

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

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

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

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

312
Zzhu_zong·2 days ago

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

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

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

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

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

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

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

1
Oops_wangMod·2 days ago

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

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

254
Bbob_chen·2 hours 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".

241
Sslow_query·2 days agoedited

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

221
Llinlin·2 days ago

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

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

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

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

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

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

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

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

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

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

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

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

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

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

73
Rran_bo·28 minutes ago

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

53
Llinlin·just now

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

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

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

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

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

38
Wwinter·2 days ago

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

34
Zzhu_zong·just nowedited

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

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

502
Rran_boOP·2 days ago

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

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

31
Llinlin·28 minutes ago

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

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

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

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

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

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

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

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

14
Zzhu_zong·3 minutes ago

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

13
Zzhou_yi·28 minutes agoedited

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

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

5
Zzhou_yiMod·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
Rrase·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.

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

1
Mmike_xuMod·2 hours 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/pwa-interview/post/p7. 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 →