柜台服务:我们如何在Rust中重写它
The Integrity Data Platform (IDP) team decided to rewrite one of our heavy Queries Per Second (QPS) Golang microservices in Rust. It resulted in 70% infrastructure savings at a similar performance, but was not without its pitfalls. This article will elaborate on:
Integrity Data Platform (IDP) 团队决定将我们的一项高负载每秒查询 (QPS) Golang 微服务重写为 Rust。这导致在相似性能下节省了 70% 的基础设施成本,但并非没有陷阱。本文将详细阐述:
- How we picked what to rewrite in Rust.
- 我们如何选择在Rust中重写的内容。
- Approach taken to tackle the rewrite.
- 为应对重写而采取的方法。
- The pitfalls and speed bumps along the way.
- 沿途的陷阱和障碍。
- Was it worthwhile?
- 这值得吗?
Introduction
介绍
Grab is predominantly based on a microservice architecture, with the vast majority of microservices being hosted in a monorepo and written in Golang. It has served the company well so far, as the “simplicity” of Golang allows developers to ramp up and iterate quickly.
Grab 主要基于微服务架构,绝大多数微服务托管在一个单一代码库中,并使用 Golang 编写。到目前为止,这为公司提供了良好的支持,因为 Golang 的“简单性”使开发人员能够快速上手和迭代。
However, Rust has seen some gradual adoption across the company. Starting with a few minor CLIs, which then progressed to notable success with a Rust-based reverse proxy in Catwalk for model serving. Additionally, a growing community of Rust enthusiasts within the organisation has expressed interest in advocating for and expanding the adoption of Rust more proactively.
然而,Rust 在公司内部逐渐被采纳。从一些小的 CLI 开始,随后在 Catwalk 中取得了基于 Rust 的反向代理的显著成功。此外,组织内日益增长的 Rust 爱好者社区也表示有兴趣更积极地倡导和扩展 Rust 的采用。
After achieving success with several projects on the ML platform and addressing concerns about Rust’s ability to handle traffic at scale, the next logical step was to assess the Return on Investment (ROI) of rewriting a Golang microservice in Rust.
在ML平台上成功完成多个项目并解决了关于Rust处理大规模流量能力的担忧后,下一步的逻辑是评估将Golang微服务重写为Rust的投资回报率(ROI)。
Background
背景
Rust has the reputation of being highly efficient yet poses a steep learning curve. Rust is often touted to perform close to C, doing away with garbage collection while remaining memory safe through strict compile checks and the borrow checker. It is loved by developers for ...