404human Projects Writing Build logs Learning Books Progress
Rust · Zola
zsh · 404human@dev:~ Tab complete · ↑↓ history · type help

Go vs Rust for backend APIs and background workers

Go vs Rust in production backends: compile times, tail latency, memory bounds, error handling, async pitfalls, and when each language is the pragmatic choice.

Published
Read time
3 min read
Kind
guide
Topics

Choose Go when your top priority is fast onboarding, instant compile times, and straightforward network services where occasional garbage-collector pauses don’t hurt you. Choose Rust when you want strict compile-time invariants (type-level tenant scoping, exhaustive error handling, zero data races), flat predictable tail latency (p99), and tiny memory footprints on small servers.

Every backend service in this workspace—Colophon CMS, Service Monitor, Durable Runner, jsrt, and MiniBTC—is written in Rust (Tokio + Axum). That does not mean Rust beats Go everywhere. Here is where each wins and where each bites.

Go vs Rust for backends at a glance

DimensionGoRust (Tokio + Axum)
Compile timeSeconds (near-instant iteration)Slower clean builds; fast incremental once split into workspace crates
Memory & tail latencyLow GC pauses (usually sub-ms), higher steady-state RSSNo GC; flat p99/p99.9 and minimal RSS on 1–2 GB VPS nodes
Concurrency modelGoroutines + channels (easy to write; data races caught at runtime with -race)async/Tokio (steeper learning curve; data races rejected at compile time)
Error handlingExplicit if err != nil (easy to ignore or miss a zero-value struct)Result<T, E> + exhaustive match (harder to ignore failure states)
Type-level safetySimple type system; nil pointer panics still happen in productionNo null, affine types, newtype tenant wrappers, compile-time SQL checks (sqlx)
Team ramp-upDays for any backend engineerWeeks to become fluent with lifetimes and async traits

Where Rust actually pays for itself in our stack

  1. Encoding security invariants in types. In Service Monitor and Colophon CMS, workspace/tenant IDs are distinct newtypes—you literally cannot pass an unscoped query or swap two IDs by accident.
  2. Honest resource bounds on small droplets. Running multiple SaaS backends on a single shared 2 GB VPS is comfortable in Rust because each compiled binary sits at tens of megabytes of RSS with no GC heap headroom required.
  3. Systems components alongside HTTP. Embedding V8 (deno_core), writing a framed append-only journal (durable-runner), or implementing a P2P blockchain node (minibtc) stays in one language with zero FFI glue.

Where Go still beats Rust

  • Large teams with mixed experience: A junior engineer can read and ship safe Go HTTP handlers in week one.
  • Fast CI and edit-compile-test loops: Go’s compiler speed is still unmatched.
  • Standard-library completeness: Go’s net/http, crypto/*, and encoding/json cover 80% of web services without picking crates.

And remember: Rust does not save you from architectural bugs. Async Rust still has real footguns—like blocking Tokio worker threads, cache races across .await, and hyper’s idle keep-alive timeout.

When to choose which

Choose Go if:

  • You are building CRUD/RPC microservices, CLI tools, or infrastructure glue with a growing team that values simplicity and fast builds.
  • Sub-millisecond GC pauses and slightly larger RAM usage are completely fine.

Choose Rust if:

  • Correctness, memory bounds, and predictable p99 latency under load are core product features.
  • You are building storage engines, runtimes, security-critical proxies, or dense multi-service VPS deployments.

Related reading