iOS · Open source · Building an internal platform with ios-opensource from scratch: architecture and decision log

818
IOr/ios-opensource·posted by mike_xu·6 hours agoPostmortem

Building an internal platform with ios-opensource from scratch: architecture and decision log

Short version: ios-opensource needs almost no tuning at small and medium scale — the point where it starts to hurt is much further out than most people assume. Full measurements below.

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.

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

304 comments

· first 120 loaded
M
Kkite·2 days ago

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

507
Kkite·2 days ago

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

505
Zzhu_zong·2 days ago

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

502
Rran_bo·2 days ago

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

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

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

15
Kkernel_panic·2 days agoedited

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

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

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

404
Ttang_hao·2 days ago

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

381
Rrase·3 minutes ago

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

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

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

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

258
Kkernel_panic·2 days ago

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

247
Nnikic·2 days ago

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

98
Zzhu_zong·2 days ago

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

225
Kkite·2 days ago

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

223
Rran_bo·2 days ago

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

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

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

159
Sswoole_leeOP·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.

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

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

118
Bbob_chen·2 days ago

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

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

405
Kkernel_panicOP·2 days ago

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

2
Rrase·2 days ago

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

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

151
NnikicOP·2 days ago

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

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

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

96
Sslow_query·2 days ago

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

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

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

23
Rran_bo·12 minutes ago

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

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

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

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

48
Nnikic·2 days ago

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

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

213
Kkernel_panic·2 days ago

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

4
Llinlin·2 days ago

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

3
Cchen_dev·2 days ago

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

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

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

75
NnikicMod·2 days ago

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

63
Kkernel_panicOP·3 minutes ago

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

1
Llinlin·yesterday

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.

231
Hhuang_ke·2 hours ago

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

397
Sswoole_lee·2 hours ago

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

422
Kkite·5 hours 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
Rrase·2 days ago

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

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

172
Llinlin·2 days ago

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

1
Llinlin·2 days ago

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

84
LlinlinOP·2 days ago

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

1
Zzhu_zong·2 days ago

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

413
Ttang_hao·yesterday

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

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

114
Rrase·2 hours ago

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

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

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

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

33
Hhuang_ke·2 days agoLevel 6

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

63
Sswoole_lee·2 days ago

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

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

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

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

177
Mmike_xu·2 days ago

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

60
Rran_bo·3 minutes ago

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

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

43
Ttang_hao·2 days ago

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

41
Zzhu_zongOP·2 days ago

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

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

39
Aalice_dev·1 hour ago

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

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

18
Mmike_xu·3 minutes ago

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

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

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

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

8
Ddev_zhou·2 days ago

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

503
Ddev_zhou·2 hours ago

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

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

352
Sslow_queryOP·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.

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

82
Kkernel_panic·just now

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

63
Kkernel_panic·2 days ago

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

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

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

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

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

502
Mmike_xuMod·yesterday

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

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

77
Wwinter·2 days ago

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

263
Hhuang_keOP·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
Sslow_query·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
Kkite·2 days ago

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

6
Hhuang_ke·2 days ago

One counter-example: below ios-opensource 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·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.

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

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

1
KkiteMod·2 days ago

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

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

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

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

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

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

90
Wwinter·2 days ago

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

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

150
Cchen_devMod·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.

62
Wwinter·2 days agoeditedLevel 6

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

298
Sswoole_leeOP·2 days ago

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

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

329
Cchen_dev·2 days ago

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

1
Sslow_query·2 days ago

One counter-example: below ios-opensource 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
Wwinter·2 days ago

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

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

1
Rrase·2 days ago

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

1

This is the post detail page /en/c/ios-opensource/post/p7. 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 →