Introduction
ServiceWeaver is an open-source framework from Google for building distributed applications in Go. It lets developers write modular code using normal Go interfaces and method calls, then handles the transformation into networked microservices at deploy time. The goal is to eliminate the boilerplate of microservice communication while keeping the operational benefits of distributed deployment.
What ServiceWeaver Does
- Lets you define components as Go interfaces that can run in-process or across the network
- Automatically generates RPC stubs and serialization code between components
- Provides built-in service discovery and load balancing
- Supports deployment as a single binary, multi-process, or on Kubernetes via GKE
- Includes an integrated logging, metrics, and tracing pipeline
Architecture Overview
ServiceWeaver uses Go code generation to produce networking code from component interfaces marked with weaver.AutoMarshal. At deploy time, a deployer (single, multi, or GKE) decides how to place components across processes. Components that are co-located call each other directly in memory; remote components communicate via a custom RPC protocol. The framework provides a router for load balancing and a listener abstraction for serving HTTP traffic.
Self-Hosting & Configuration
- Install the weaver CLI via go install
- Configuration is defined in a TOML file specifying component placement and listeners
- The single deployer runs everything in one process for development
- The multi deployer runs components as separate OS processes on a single machine
- The GKE deployer packages components into containers for Google Kubernetes Engine
Key Features
- Write once, deploy as monolith or microservices without code changes
- Automatic serialization via code generation (no manual protobuf definitions)
- Co-located components use direct function calls with zero networking overhead
- Built-in observability: structured logging, OpenTelemetry metrics, and distributed tracing
- Atomic rollouts: deploy new versions with traffic splitting and automatic rollback
Comparison with Similar Tools
- gRPC — requires manual protobuf definitions and service wiring; ServiceWeaver generates this automatically
- Go Kit — microservice toolkit with manual plumbing; ServiceWeaver abstracts the network boundary
- Dapr — sidecar-based runtime for any language; ServiceWeaver is Go-native with tighter integration
- Temporal — durable workflow execution; ServiceWeaver focuses on deployment topology, not workflow orchestration
- Micro — Go microservices framework; ServiceWeaver uniquely supports monolith-to-microservice deployment switching
FAQ
Q: Does ServiceWeaver only work with Go? A: Currently, yes. ServiceWeaver is designed for Go applications. There are no official bindings for other languages.
Q: Can I deploy ServiceWeaver outside of GKE? A: The single and multi deployers run anywhere. Community deployers for generic Kubernetes and other platforms exist, but GKE is the most supported cloud target.
Q: How does ServiceWeaver handle versioning and rollouts? A: ServiceWeaver supports versioned rollouts where old and new versions run simultaneously with configurable traffic splitting, enabling canary deployments and automatic rollback.
Q: Is ServiceWeaver production-ready? A: Google uses it internally. The open-source version is stable for core functionality, though the ecosystem of deployers beyond GKE is still maturing.