Anthropic 成功将其核心 Messages API 从 Python 迁移至 Rust,且整个过程中团队并未配备专职的 Rust 开发人员 1。这一转型主要依托于其自研的大语言模型 Claude,数据显示截至 2026 年 5 月,Claude 已编写了 Anthropic 合并代码库中超过 80% 的内容 1。此次技术重构旨在应对巨大的流量压力,统计表明该 API 的流量在 2024 年初至 2026 年秋季期间增长了约 1800 倍 1。
迁移后的 Rust 版本带来了显著的性能优化,API 每请求的 CPU 使用量降低了约 70%,首词生成的中位时间也缩短了约 20% 1。尽管工程效率提升明显,但确保实时系统中生成代码的正确性构成了主要挑战:初始集成测试虽然通过了约 98%,但在生产环境的影子对比中,仅有约 25% 的输入结果与原有系统匹配 1。
为解决验证难题,Anthropic 构建了一套闭环验证体系,分为基于沙盒的快速内部循环和基于生产流量的慢速外部循环 1。该系统利用“检查点”精确定位差异步骤,并通过“指纹”技术区分不同的 Bug 1。此外,团队引入了记忆循环机制,将工程师审查后的反馈转化为通用规则并存储在 CLAUDE.md 文件中,从而有效防止同类错误重复发生 1。整个迁移过程未导致服务中断,也未冻结功能开发进度 1。
Anthropic successfully migrated its core Messages API from Python to Rust by leveraging its proprietary model, Claude, despite having no dedicated Rust developers on the team 1. The transition was driven by significant scaling challenges, as API traffic grew approximately 1,800 times between early 2024 and autumn 2026 1. This strategic shift resulted in a reduction of about 70% in CPU usage per request for the Rust version of the API 1. Additionally, the median time to generate the first token decreased by roughly 20% following the migration 1.
To ensure stability during the switch, Anthropic implemented a rigorous verification system that prevented service interruptions or freezes in feature development 1. While initial integration tests showed an approximate 98% pass rate, only about 25% of inputs matched results when tested against production traffic 1. To address this discrepancy, the company built a closed-loop validation process using shadow comparisons of live traffic, fingerprinting techniques to distinguish different bugs, and automated agents for fixes 1. The verification framework employs "checkpoints" to pinpoint steps where differences occur and operates through both fast internal loops for sandbox validation and slow external loops for production shadow testing 1. Furthermore, a memory loop mechanism converts engineer review comments into general rules stored in CLAUDE.md to prevent recurring errors 1. As of May 2026, Claude had written more than 80% of the merged code within Anthropic 1.
评论
还没有评论,欢迎留下第一条。