Products

Anthropic 用 Rust 重写 Messages API,单请求 CPU 降低约 70%

Why we picked it

Anthropic 的 API 流量两年涨了 1800 倍,Python 扛不住,换 Rust 后单请求 CPU 省 70%。有意思的是初稿一周就靠 Claude 写完,卡住团队的反而是证明行为完全等价。做后端、关心 Python 性能瓶颈的人该看看这个案例。

Anthropic 将 Messages API 从 Python 重写为 Rust,每个请求的 CPU 消耗降低约 70%。重写的直接动因是流量规模:自 2024 年初以来,Anthropic 的 API 流量增长约 1,800 倍,Python 解释器在如此量级下成为瓶颈。这一数字由 Anthropic 相关成员公开披露。

Body

技术层面,重写过程借助了 Claude:模型在一周左右完成第一版 Rust 代码草稿。真正的难点不在写代码,而在验证——团队需要证明 Rust 版本在行为上与原 Python 实现完全一致,语义等价性验证花的时间超过编码本身。

对依赖 API 的开发者而言,这次重写是基础设施层优化,接口行为保持不变,不需要改动客户端代码。它也展示了 AI 辅助重写的现实路径:生成初稿很快,但保证等价性仍需大量人工验证。

Original · rohanpaul_ai

Anthropic rebuilt its Messages API in Rust, and each request now uses about 70% less CPU.

Python slowed every request, and API traffic has grown roughly 1,800 times since early 2024.

Claude wrote a first draft in about a week, but proving it behaved exactly like Python was harder.

Industry Coordinates & Source Verification

This report is categorized under AITOP's "Products" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Anthropic, Rust, Claude, API.

Source attribution: curated from rohanpaul_ai (@rohanpaul_ai).