Agent · Architecture · Interview notes: how I answered a question about the agent-design concurrency model

2.4K
AGr/agent-design·posted by linlin·32 minutes agoTooling

Interview notes: how I answered a question about the agent-design concurrency model

Most agent-design articles stop at "how to use it" and never cover "when not to use it". This is an attempt at the second half.

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.

Worth noting: the official docs do cover this, just in a very inconspicuous spot. I only found it reading the source comments, where the author explains the reasoning — roughly "so that it degrades into predictable behaviour in extreme cases".

Sstackoverflow.comExternal link · opens in a new tab
251 comments

251 comments

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

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

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

475
Sslow_queryMod·2 days ago

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

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

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

428
Mmike_xu·2 days ago

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

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

369
Kkernel_panic·2 days ago

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

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

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

357
WwinterOP·2 hours ago

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

262
Ttang_hao·3 minutes ago

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

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

250
Sswoole_lee·2 days ago

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

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

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

111
Oops_wang·2 days ago

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

500
Mmike_xu·2 days ago

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

412
Wwinter·2 days ago

One counter-example: below agent-design 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
Zzhu_zong·2 days agoLevel 6

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

265
Zzhou_yi·2 days agoedited

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

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

326
Zzhou_yi·yesterdayLevel 6

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

390
Rrase·5 hours ago

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

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

29
Sslow_query·2 days ago

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

63
Mmike_xu·just nowLevel 6

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

94
Hhuang_keOP·3 minutes ago

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

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

58
Ttang_hao·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
Ddev_zhou·5 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.

168
Llinlin·2 days ago

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

41
Sslow_query·2 days ago

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

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

155
Mmike_xu·28 minutes ago

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

213
Lli_ming·12 minutes ago

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

283
Zzhu_zong·2 days ago

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

256
Zzhu_zongOP·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.

73
Cchen_dev·2 days ago

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

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

128
Nnikic·2 days ago

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

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

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

286
Kkite·2 days ago

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

6
Aalice_devOP·2 days ago

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

201
KkiteMod·2 days ago

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

1
Llinlin·5 hours ago

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

278
Oops_wang·just now

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.

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

432
Bbob_chen·2 days ago

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

9
Oops_wang·2 days ago

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

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

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

511
Cchen_dev·5 hours 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.

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

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

262
Llinlin·28 minutes ago

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

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

251
Sswoole_lee·2 days ago

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

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

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

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

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

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

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

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

105
Sslow_query·2 days ago

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

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

1
Cchen_dev·2 days ago

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

92
Zzhou_yiOP·2 days ago

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

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

72
Aalice_devOPMod·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.

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

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

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

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

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

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

63
Cchen_dev·28 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.

59
Mmike_xu·2 days ago

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

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

502
Kkernel_panic·3 minutes ago

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

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

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

55
Aalice_devMod·2 days ago

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

54
Sswoole_lee·just nowedited

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.

53
Zzhou_yi·2 days ago

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

47
Sswoole_lee·3 minutes ago

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

44
Kkite·1 hour ago

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

463
Kkernel_panic·2 days ago

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

189
Sslow_query·2 days ago

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

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

82
Hhuang_ke·2 days ago

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

295
Sslow_queryOP·2 days ago

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

22
Ddev_zhou·2 days 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.

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

41
Kkernel_panic·2 days agoedited

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

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

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

1
Zzhu_zong·2 days ago

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

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

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

33
Bbob_chen·1 hour ago

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

152
Kkite·2 days ago

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

39
Sswoole_lee·2 days ago

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

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

21
Aalice_dev·2 days ago

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

18
Cchen_dev·2 days ago

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

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

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

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

108
Rrase·5 hours ago

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

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

6
Nnikic·2 days ago

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

5
Zzhu_zong·2 days ago

One counter-example: below agent-design 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
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.

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

1

This is the post detail page /en/c/agent-design/post/p12. 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 →