This article discusses Anthropic's architectural shift from a Python monolith to Rust for its critical Claude API, driven by performance and CPU footprint concerns. It also highlights their innovative use of AI agents for code review, on-call incident triage, and new engineer onboarding, showcasing how AI is reshaping software engineering practices and system operations.
Read original on The Pragmatic EngineerAnthropic initially developed its Claude API as a Python monolith, which handled authentication, tokenization, billing, safety checks, and interactions with the GPU stack. This choice was pragmatic for a research-heavy company with a small team proficient in Python. However, as the API scaled, the CPU footprint of the Python monolith became a significant bottleneck. Despite optimization efforts within Python, the performance overhead remained substantial, especially in a context of global CPU shortages. This led to the strategic decision to rewrite the critical API serving all Claude tokens from Python to Rust, echoing a similar migration path observed at OpenAI.
The migration to Rust was completed in approximately five months, even without a team of Rust experts. A key architectural decision for ensuring correctness and minimizing risk was employing a shadowing strategy. The new Rust API ran in parallel, processing production traffic and comparing its responses against the existing Python API. This allowed for iterative development and verification until responses were identical, acting as a "perfect test harness" without requiring strict human code reviews for every line of AI-generated Rust code.
Shadowing for Safe Migrations
Shadowing is a powerful technique for rewriting critical services. By running the new service alongside the old one and comparing outputs, you can validate functionality and performance under real-world traffic without impacting users, significantly reducing deployment risk during large-scale refactorings or language migrations.
Despite the advancements in AI, fundamental principles like two-pizza teams (5-8 people) remain crucial for managing complex systems and effective on-call rotations. This highlights the enduring importance of human-centric team structures alongside advanced automation. The company emphasizes project impact (e.g., CPU savings, latency reduction, incident avoidance) over time-to-completion for promotions, adapting evaluation metrics to the accelerated pace of AI-assisted development. This signals a shift in what defines engineering value in an AI-augmented environment.