Skip to content

[Architecture] The Subprocess-based Agent Loop causes poor performance and memory bottlenecks in server-side/high-concurrency scenarios #372

Description

@junneyang

1. Spawning a new subprocess for every new session

The current architectural design of claude-agent-sdk-typescript suffers from severe concurrency and performance bottlenecks. Specifically, the SDK spawns a new isolated subprocess for every single new session. While this tightly coupled Agent Loop architecture might be reasonable for standalone CLI tools, it is disastrous for server-side applications.

2. Claude Agent SDK vs LangChain DeepAgent

Image

Runaway Resource Exhaustion:
As concurrency scales from 10 to 40, the Claude SDK's CPU usage skyrockets from 27% to 99%, with memory spiking directly to 86%. In stark contrast, the DeepAgent architecture (which completely avoids the subprocess overhead) maintains a mere 15% CPU usage and a rock-solid 8% memory footprint. This proves that the Claude SDK's compute and memory resources are entirely cannibalized by meaningless process management.

Deadlocked Throughput Bottleneck:
Upon reaching a concurrency of 40, the Claude SDK's extreme system load causes its QPM (Queries Per Minute) to completely stall at a mere 28.8, while the P95 latency degrades to an unacceptable 103 seconds.

Extremely Low Concurrency Ceiling:
The data clearly demonstrates that at a mere 40 concurrent requests, the Claude SDK entirely drains all resources of a 4C8G server, rendering it completely unresponsive and unable to provide service beyond that point. Meanwhile, a well-designed architecture effortlessly handles up to 100 concurrent requests with plenty of headroom (utilizing only 37% CPU).

Hoping for an official resolution, as this currently makes the SDK unusable in production server environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions