internal/website/docs/hosting.md
This document outlines what hosting looks like for go-micro services, the options available today, and what an ideal hosting platform would provide.
Go Micro services are compiled Go binaries that communicate via RPC and event-driven messaging. Hosting them requires infrastructure that supports service discovery, inter-service communication, persistent storage, and configuration management. Because go-micro uses a pluggable architecture, the hosting environment can range from a single VPS to a fully orchestrated cluster.
The simplest approach. Deploy compiled binaries to a Linux server and manage them with systemd. This is the model described in the Deployment Guide.
Good for: Small teams, early-stage projects, predictable workloads.
Server
├── [email protected]
├── [email protected]
├── [email protected]
└── mdns for discovery
micro deploy to push binaries over SSHRun services across several machines. This requires replacing mDNS with a network-aware registry like Consul or Etcd so services can discover each other across hosts.
# Point all services at a shared registry
MICRO_REGISTRY=consul MICRO_REGISTRY_ADDRESS=consul.internal:8500
micro deploy to each target serverPackage each service as a Docker image and deploy to a Kubernetes cluster or a simpler container runtime like Docker Compose.
Dockerfile example:
FROM golang:1.21-alpine AS build
WORKDIR /app
COPY . .
RUN go build -o service ./cmd/service
FROM alpine:3.19
COPY --from=build /app/service /service
ENTRYPOINT ["/service"]
Kubernetes considerations:
Deploy to managed platforms like Railway, Render, or Fly.io. Each service runs as a separate application.
A purpose-built platform for go-micro services would integrate with the framework's core abstractions rather than treating services as generic containers.
The platform must run or integrate with a supported registry so services find each other automatically.
| Environment | Recommended Registry |
|---|---|
| Single host | mDNS (default, zero config) |
| Multi-host / cloud | Consul, Etcd, or NATS |
| Kubernetes | Kubernetes registry plugin |
Services communicate over RPC (request/response) and asynchronous messaging (pub/sub). The platform must allow direct service-to-service communication on the configured transport.
Each service loads configuration from environment variables, files, or remote sources. The platform should provide:
go-micro's store interface supports multiple backends. The platform should provide or connect to durable storage.
The platform should monitor service health and provide visibility into behavior.
See Observability for details on logs, metrics, and traces.
A hosting platform tailored for go-micro would look like this:
┌──────────────┐
Internet ──────▶│ Gateway │
└──────┬───────┘
│
┌────────────┼────────────┐
│ │ │
┌─────▼────┐ ┌────▼─────┐ ┌───▼──────┐
│ Service A │ │ Service B│ │ Service C │
│ (n inst.) │ │ (n inst.)│ │ (n inst.) │
└─────┬────┘ └────┬─────┘ └───┬──────┘
│ │ │
┌─────────▼────────────▼──────────���─▼─────────┐
│ Private Network │
│ ┌──────────┐ ┌───────┐ ┌──────────────┐ │
│ │ Registry │ │ Broker│ │ Store │ │
│ │(Consul/ │ │(NATS/ │ │(Postgres/ │ │
│ │ Etcd) │ │ Redis)│ │ MySQL/Redis) │ │
│ └──────────┘ └───────┘ └──────────────┘ │
└─────────────────────────────────────────────┘
Developer Platform
──────── ────────
micro build ─────▶ Receive binary/image
micro deploy prod ─────▶ Place on compute
Register with discovery
Start health checks
Route traffic
| Factor | Single VPS | Multi-Server | Kubernetes | PaaS |
|---|---|---|---|---|
| Complexity | Low | Medium | High | Low |
| Cost | Low | Medium | High | Variable |
| Scaling | Manual | Manual | Automatic | Automatic |
| Service discovery | mDNS | Consul/Etcd/NATS | Plugin or Consul | External |
| Ops overhead | Minimal | Moderate | Significant | Minimal |
| Best for | Prototypes, small apps | Growing teams | Large-scale production | Quick launches |
micro deploy and mDNS