Rust vs Zig vs Go Performance
This YouTube video benchmarks Rust, Zig, and Go for HTTP application performance using a simple API endpoint. Key findings include:
-
Methodology: The benchmark uses a production-like Kubernetes cluster with large EC2 instances, focusing on four “golden signals”: latency (P99 percentile), throughput (requests per second), saturation (CPU and memory usage), and errors (availability). A simple API endpoint returning a hardcoded response was used for consistent testing.
-
Idle State: Rust showed significantly lower memory usage in the idle state compared to Zig and Go.
-
Throughput: Zig consistently outperformed Rust and Go in terms of requests per second (RPS), reaching approximately 118,000 RPS. Rust achieved around 113,000 RPS, while Go peaked at roughly 70,000 RPS before being repeatedly killed by Kubernetes due to exceeding memory limits.
-
Latency: Rust and Zig exhibited similar low latency, significantly lower than Go’s latency, which increased considerably under load.
-
Resource Usage: Go demonstrated higher CPU usage from the start and frequently hit its memory limits, leading to crashes and restarts. Rust and Zig showed comparable memory usage under high load, with Rust slightly exceeding Zig’s usage towards the end of the test.
-
Errors/Availability: Go experienced the most errors and availability drops due to memory exhaustion. Rust also showed some availability decreases at higher request rates due to timeouts.
-
Overall: Zig showed the best overall performance in this benchmark, surpassing both Rust and Go in throughput while maintaining low latency. Rust performed well but was slightly outperformed by Zig. Go struggled with memory management and consequently had lower throughput and higher latency. The author invites viewers to suggest improvements to the benchmark design or contribute via pull requests.