Vue Community · Two weeks with Vue: what feels right and what drives me up the wall

690
Vr/vue·posted by zhu_zong·5 minutes agoDiscussion

Two weeks with Vue: what feels right and what drives me up the wall

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.

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.

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

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

On trade-offs, my view is this: if nobody on the team owns this area long-term, do not introduce a second mechanism. With two coexistence you first have to work out which one is even in play when things break, and that costs far more than the performance you saved.

250 comments

250 comments

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

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

132
Oops_wang·2 days ago

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

245
Ttang_haoOP·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.

5
Ttang_hao·28 minutes ago

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

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

415
Oops_wang·2 days ago

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

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

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

406
Aalice_devOP·2 days ago

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

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

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

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

255
Cchen_dev·2 days ago

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

241
Ddev_zhou·2 days ago

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

229
Zzhu_zong·2 days ago

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

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

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

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

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

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

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

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

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

177
Hhuang_ke·2 days ago

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

154
Wwinter·2 days agoedited

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

151
Zzhou_yi·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
Bbob_chen·2 days ago

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

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

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

134
Ttang_hao·2 days agoedited

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

131
Oops_wang·2 days ago

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

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

16
Mmike_xuOP·2 days ago

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

52
Wwinter·2 days ago

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

91
Aalice_dev·2 days ago

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

2
Zzhou_yi·2 days ago

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

85
Ttang_hao·2 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.

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

2
Ddev_zhou·2 days ago

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

63
Oops_wang·2 days ago

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

72
Lli_ming·2 days ago

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

11
Rran_boOP·2 days ago

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

1
Sswoole_lee·2 days ago

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

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

40
Rrase·2 days ago

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

39
Rran_bo·3 minutes ago

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

38
Aalice_dev·2 days agoedited

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

234
Rrase·yesterday

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

344
Sslow_query·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
Rran_bo·3 minutes ago

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

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

434
Rran_bo·12 minutes ago

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

95
Sslow_query·2 days agoedited

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

509
Aalice_devMod·2 days agoedited

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

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

136
Sswoole_lee·yesterday

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

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

81
Nnikic·2 days agoLevel 6

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

493
Rran_boOP·12 minutes agoLevel 6

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

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

15
Rran_bo·12 minutes 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.

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

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

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

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

4
LlinlinMod·3 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.

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

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

512
Kkite·2 days agoLevel 6

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

204
Lli_ming·2 days ago

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

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

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

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

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

160
Cchen_dev·2 days agoLevel 6

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

282
Llinlin·yesterdayLevel 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.

181
Bbob_chen·3 minutes agoLevel 6

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

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

10
Kkernel_panic·2 days agoedited

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

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

382
Mmike_xu·2 days ago

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

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

86
Kkite·2 days ago

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

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

3
Rran_bo·2 days agoLevel 6

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

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

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

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

17
Aalice_dev·28 minutes ago

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

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

9
Mmike_xu·2 days ago

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

5
Kkite·2 days ago

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

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

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

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

3
Oops_wangOP·5 hours ago

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

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

1
Hhuang_ke·1 hour ago

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

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

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

4
Aalice_devMod·2 days ago

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

2
Bbob_chen·yesterday

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.

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

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

131
Bbob_chen·12 minutes ago

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

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

278
Zzhou_yi·2 days ago

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

47
Hhuang_ke·2 days agoeditedLevel 6

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

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

335
Lli_ming·just now

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

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

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

55
Rrase·2 days ago

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

26
Cchen_dev·2 days ago

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

1
Kkite·2 days ago

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

179
Ddev_zhou·2 days ago

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

129
Wwinter·yesterday

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

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

1

This is the post detail page /en/c/vue/post/p10. 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 →