Alipay Mini Program Community · Help: alipay-miniprogram fails to start intermittently in containers, logs inside

1.1K
AMr/alipay-miniprogram·posted by alice_dev·3 days agoOpen sourcePinned

Help: alipay-miniprogram fails to start intermittently in containers, logs inside

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.

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

266 comments

· first 120 loaded
M
Bbob_chen·2 days ago

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

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

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

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

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

433
Hhuang_ke·2 days ago

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

256
Ddev_zhou·2 days agoedited

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

426
RraseOP·just now

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

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

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

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

354
Kkernel_panic·2 days ago

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

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

323
Kkernel_panicMod·2 days ago

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

155
Kkernel_panicMod·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.

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

9
Nnikic·2 days ago

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

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

315
KkiteMod·5 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.

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

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

296
Bbob_chen·1 hour 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.

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

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

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

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

134
RraseMod·2 days ago

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

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

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

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

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

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

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

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

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

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

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

188
Cchen_dev·2 days ago

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

292
Mmike_xu·yesterday

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

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

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

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

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

121
Llinlin·28 minutes ago

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

48
Zzhou_yi·2 hours ago

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

393
Hhuang_ke·2 days 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.

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

247
Kkernel_panic·just now

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

236
Llinlin·2 days agoedited

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

224
Mmike_xu·2 days ago

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

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

220
Hhuang_ke·2 days agoedited

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

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

185
Rran_bo·1 hour ago

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

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

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

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

1
Zzhou_yi·2 days ago

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

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

200
Kkernel_panic·2 days ago

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

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

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

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

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

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

111
Rrase·2 days ago

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

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

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

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

140
Oops_wang·2 days ago

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

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

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

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

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

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

106
Aalice_dev·2 hours 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.

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

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

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

50
Zzhu_zong·2 hours 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.

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

159
Oops_wangOP·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".

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

348
Rrase·2 days ago

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

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

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

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

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

444
Ddev_zhou·1 hour ago

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

237
Oops_wangOP·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
Mmike_xu·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.

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

89
Rran_boMod·2 days ago

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

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

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

234
Llinlin·28 minutes agoedited

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

12
Kkite·2 days agoedited

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 alipay-miniprogram source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

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

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

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

22
Cchen_devMod·just now

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

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

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

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

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

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

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

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

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

26
Aalice_dev·2 days ago

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

2
Kkite·3 minutes 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
Zzhu_zong·12 minutes ago

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

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

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

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

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

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

1

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