GrabStan HalkaProblem & solution
One Small Step Closer to Containerising Service Binaries
Summary
Engineering teams at Grab initiated a transition to containerized microservices to standardize environments, enhance security, and decouple services from internal runtime tooling. During this migration, developers noticed that statically-linked Go service binaries were reaching bloated sizes over 100 MB. By analyzing the binaries using the open-source tool go-binsize-viz alongside the Go nm toolchain, the team visualized compiled symbols as interactive treemaps. This analysis revealed that 11 MB of unused message format symbols were being pulled in because a generic interface shared a directory with auto-generated streaming code. Restructuring the packages to isolate interfaces from generated code successfully decreased the binary size down to 78 MB.
Context
During Grab's migration to a containerized microservice architecture, engineers noticed that statically-linked Go binaries were unexpectedly bloated to sizes over 100 MB, increasing container image size and deployment overhead.
Approach / What changed
Engineers used the go-binsize-viz utility and Go's nm tool to generate treemap visualizations of binary symbols, pinpointed unused transitive dependencies caused by auto-generated stream message formats sharing a package directory with an interface, and restructured the code to decouple them.
Takeaways
Go imports all symbols defined within an imported directory and its transitive dependencies, rather than only the specifically referenced symbols.
Placing a shared interface in the same directory as auto-generated streaming models caused services to needlessly compile 11 MB of unused message symbols into their binaries.
Restructuring the flat package layout to separate generic interfaces from generated models reduced the target binary size from over 100 MB down to 78 MB.
Source and freshness
- Source
- engineering.grab.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.