Alipay Mini Program Community · alipay-miniprogram under load on an 8-core 16GB box — full benchmark scripts included

771
AMr/alipay-miniprogram·posted by bob_chen·32 minutes agoReview

alipay-miniprogram under load on an 8-core 16GB box — full benchmark scripts included

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.

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.

Self-host — full control44%
Managed service — less work28%
Hybrid: core self-hosted17%
Not decided yet11%

1311 votes total

123 comments

123 comments

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

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

458
Rrase·2 days agoedited

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

453
Kkite·2 days agoedited

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

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

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

54
Sslow_query·2 days ago

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

372
Rrase·2 days agoedited

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

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

412
Ttang_hao·2 days ago

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

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

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

353
Sswoole_lee·5 hours ago

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

348
Sswoole_lee·2 days ago

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

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

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

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

185
Hhuang_ke·2 days ago

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

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

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

228
Llinlin·12 minutes ago

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

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

236
Wwinter·5 hours agoedited

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

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

1
Ddev_zhou·2 days agoLevel 6

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

58
Hhuang_keOP·2 days ago

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

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

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

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

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

171
Bbob_chen·2 days ago

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

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

210
Lli_ming·2 days agoedited

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

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

147
Oops_wang·12 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.

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

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

110
Bbob_chenOP·2 days ago

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

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

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

108
Ddev_zhouMod·2 days ago

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

106
Ddev_zhou·2 days ago

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

103
Bbob_chenOP·2 days ago

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

15
Kkernel_panicOP·2 days ago

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

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

7
Sslow_queryOP·2 days ago

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

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

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

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

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

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

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

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

14
Ttang_hao·28 minutes ago

One counter-example: below alipay-miniprogram 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
Ddev_zhou·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.

67
Kkite·2 days agoedited

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

76
Bbob_chen·2 days ago

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

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

5
Zzhu_zong·2 days ago

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

35
Ddev_zhou·2 days agoLevel 6

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

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

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

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

8
Kkernel_panic·2 days ago

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

12
Mmike_xu·3 minutes ago

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

26
Sswoole_lee·1 hour ago

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

8
Mmike_xu·2 days ago

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

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

19
LlinlinOP·2 days ago

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

251
Sswoole_lee·28 minutes ago

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

151
Bbob_chen·2 hours ago

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

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

182
Hhuang_ke·2 days agoLevel 6

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

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

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

15
Zzhu_zong·5 hours ago

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

13
Oops_wang·2 days ago

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

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

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.

3
Kkite·12 minutes ago

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

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

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

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

2
Kkernel_panic·2 days ago

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

2
Sslow_query·12 minutes ago

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

1
Rran_bo·12 minutes ago

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

285
Wwinter·just now

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

208
Llinlin·28 minutes agoedited

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

55
Ddev_zhou·1 hour 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.

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

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

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

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

2
Zzhu_zong·2 days ago

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

113
Cchen_dev·2 days ago

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

313
Ttang_hao·2 hours ago

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

4
Rran_bo·just now

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

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

199
WwinterOP·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.

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

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

104
Hhuang_ke·yesterday

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.

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

423
Bbob_chen·3 minutes agoLevel 6

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

1
Cchen_dev·2 days ago

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

506
Llinlin·2 days ago

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

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

221
Llinlin·2 days agoLevel 6

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.

65
Wwinter·3 minutes agoeditedLevel 6

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

42
Rran_bo·2 days agoLevel 6

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

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

42
Zzhou_yi·2 days ago

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

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

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

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

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

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

1

This is the post detail page /en/c/alipay-miniprogram/post/p11. 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 →