# Counter Service: How we rewrote it in Rust

[Grab](https://yomu.fyi/company/grab) · Jia Long Loh · Jun 20, 2025

## Summary

The Integrity Data Platform team rewrote Counter Service, a high-throughput Golang microservice serving event counts for fraud rules and machine learning models, to evaluate the operational return on investment of Rust. Rather than performing a line-by-line translation, engineers approached the service as a black box, reimplementing core application logic from scratch to satisfy established gRPC contracts across Scylla and Redis. The team resolved internal Go tooling dependencies by building custom configuration template parsers using the nom parser combinator and selected targeted open-source crates such as fred.rs and Cadence. Adapting to Rust required navigating cooperative, stackless async execution compared to Go's preemptive concurrency model, alongside managing borrow checker constraints. Ultimately, the rewrite achieved a 70% reduction in infrastructure costs while maintaining comparable service performance.

## Takeaways

- Selecting rewrite candidates with constrained, simple functionality and high query volume maximizes cost savings while minimizing the risk of reintroducing complex edge-case bugs.
- Developers can accelerate early Rust iterations by using explicit clones and Arcs to avoid premature lifetime optimizations, later refining memory allocations using flamegraph profiling.
- Switching from Go to Rust shifts concurrency from runtime-driven preemptive coroutines to cooperative stackless async state machines that require explicit function coloring and await points.

**Tags:** [Go](https://yomu.fyi/topic/go), [Microservices](https://yomu.fyi/topic/microservices), [Migrations](https://yomu.fyi/topic/migration), [Performance](https://yomu.fyi/topic/performance), [Rust](https://yomu.fyi/topic/rust)

[Read original post](https://engineering.grab.com/counter-service-how-we-rewrote-it-in-rust)
