Alipay Mini Program Community · Those easily-missed type details in alipay-miniprogram

737
AMr/alipay-miniprogram·posted by linlin·3 hours agoOpen source

Those easily-missed type details in alipay-miniprogram

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.

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.

Keep it and wait for an official fix44%
Switch to a third-party option now28%
Fork and maintain it ourselves17%
Write an adapter layer and wait11%

1253 votes total

205 comments

205 comments

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

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

498
Oops_wang·2 days ago

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

457
Mmike_xu·28 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.

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

293
Lli_ming·2 days ago

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

345
Rran_bo·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".

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

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

446
Sswoole_lee·2 days ago

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

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

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

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

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

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

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

80
Nnikic·just now

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.

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

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

192
Bbob_chen·12 minutes ago

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

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

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

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

387
Sswoole_lee·2 days agoLevel 6

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

91
Llinlin·2 days ago

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

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

1
Rrase·2 days ago

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

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

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

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

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

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

503
KkiteOP·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.

12
Llinlin·2 days ago

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

323
Rran_bo·12 minutes agoedited

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

31
Bbob_chen·3 minutes agoedited

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

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

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

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

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

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

19
Kkite·2 days ago

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

141
Rran_bo·5 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.

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

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

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

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

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

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

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

290
Kkernel_panic·yesterday

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

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

294
Ddev_zhou·2 days ago

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

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

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

27
Hhuang_ke·2 days ago

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

115
Sslow_queryOP·2 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.

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

179
Sslow_query·2 days ago

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

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

134
Sslow_query·yesterday

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

131
Rran_boOP·2 days ago

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

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

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

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

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

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

49
Hhuang_ke·2 days ago

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

27
Aalice_dev·5 hours ago

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

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

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

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

36
Ttang_hao·just nowedited

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

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

324
Sslow_query·1 hour ago

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

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

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

4
Cchen_dev·2 days ago

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

50
Cchen_dev·just now

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.

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

161
Sslow_query·2 days ago

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

30
Ttang_hao·2 days ago

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

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

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

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

26
Ddev_zhou·1 hour agoedited

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

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

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

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

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

399
Oops_wang·2 days agoeditedLevel 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.

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

40
Rrase·2 days ago

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

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

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

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

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

208
Rrase·2 hours 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.

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

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

8
Rran_bo·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".

8
Rran_bo·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".

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

321
Zzhu_zong·1 hour ago

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

4
Ttang_hao·2 days ago

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

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

1
Llinlin·yesterday

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.

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

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

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

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

140
RraseMod·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
Ddev_zhou·2 days ago

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

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

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

1
Bbob_chenMod·yesterdayedited

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

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

1

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