Alipay Mini Program Community · Newbie question: how should a alipay-miniprogram config file be organised?

709
AMr/alipay-miniprogram·posted by rase·3 days agoTooling

Newbie question: how should a alipay-miniprogram config file be organised?

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.

The first thing was to collapse the variables. We were changing config and upgrading the version at the same time, and afterwards nobody could say which change caused what. We rolled back to moving one variable at a time, re-ran three times, and only then did the curve settle. Tedious, but not skippable.

Image placeholder · object storage in production
POST /api/uploads → CDN origin pull
347 comments

347 comments

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

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

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

303
Cchen_dev·2 days ago

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

507
Nnikic·2 days ago

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

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

483
Kkernel_panic·2 days ago

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

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

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

149
Ttang_hao·yesterday

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.

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

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

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

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

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

242
Llinlin·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".

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

342
Oops_wang·2 days ago

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

261
Ttang_hao·yesterday

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

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

294
Ttang_hao·yesterdayedited

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.

275
Hhuang_ke·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".

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

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

42
Wwinter·2 days ago

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

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

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

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

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

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

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

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

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

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

235
Lli_mingOP·2 days ago

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

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

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

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

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

263
Hhuang_keOP·5 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.

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

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

192
RraseOP·2 days ago

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

91
Rrase·2 days ago

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

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

183
Aalice_dev·just nowedited

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

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

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

397
Llinlin·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".

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

218
Bbob_chen·2 hours ago

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

100
Aalice_dev·12 minutes ago

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

219
Sslow_query·28 minutes ago

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

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

373
Mmike_xu·12 minutes agoLevel 6

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

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

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

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

10
Zzhou_yi·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
Zzhu_zong·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.

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

434
Sswoole_lee·2 days ago

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

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

128
Oops_wang·2 days ago

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

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

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

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

29
KkiteMod·2 days ago

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

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

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

72
Rran_boOPMod·3 minutes ago

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

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

418
Hhuang_ke·2 days ago

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

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

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

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.

36
Zzhu_zong·5 hours agoedited

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

33
Oops_wang·2 days ago

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

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

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

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

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

6
Oops_wang·2 days ago

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

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

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

230
Zzhu_zong·28 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
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.

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

2
Llinlin·2 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".

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

67
Kkernel_panic·2 hours ago

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

1
Sswoole_lee·just now

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

349
Kkite·2 hours 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.

444
Ttang_haoMod·1 hour 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.

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

197
Wwinter·2 days ago

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

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

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

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

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

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

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

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

14
Mmike_xu·2 days ago

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

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

1
Sslow_query·2 days agoedited

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

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

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

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

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

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

417
Aalice_devOP·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.

28
Rrase·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".

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

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

4
Lli_ming·2 days agoLevel 6

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

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

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

1
Zzhou_yi·3 minutes ago

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

1

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