Older documentation. Start with the current guides.

Hosting Go Micro Services

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.

Current Hosting Options

Single VPS or Bare Metal

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
├── micro@users.service
├── micro@posts.service
├── micro@web.service
└── mdns for discovery

Multiple Servers

Run 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

Containers and Kubernetes

Package 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:

Platform as a Service (PaaS)

Deploy to managed platforms like Railway, Render, or Fly.io. Each service runs as a separate application.

What a Hosting Platform Needs

A purpose-built platform for go-micro services would integrate with the framework’s core abstractions rather than treating services as generic containers.

Service Discovery

The platform must run or integrate with a supported registry so services find each other automatically.

EnvironmentRecommended Registry
Single hostmDNS (default, zero config)
Multi-host / cloudConsul, Etcd, or NATS
KubernetesKubernetes registry plugin

RPC and Messaging

Services communicate over RPC (request/response) and asynchronous messaging (pub/sub). The platform must allow direct service-to-service communication on the configured transport.

Configuration Management

Each service loads configuration from environment variables, files, or remote sources. The platform should provide:

Data Storage

go-micro’s store interface supports multiple backends. The platform should provide or connect to durable storage.

Health Checks and Observability

The platform should monitor service health and provide visibility into behavior.

See Observability for details on logs, metrics, and traces.

Security

Scaling

Ideal Platform Architecture

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) │  │
    │  └──────────┘  └───────┘  └──────────────┘  │
    └─────────────────────────────────────────────┘

Platform Capabilities

  1. Deploy — Push binaries or container images; the platform registers them with the registry
  2. Discover — Built-in registry so services find each other without manual configuration
  3. Route — Gateway for external traffic; direct RPC for internal traffic
  4. Scale — Add or remove instances; the registry and selector handle rebalancing
  5. Configure — Environment variables, secrets, and dynamic config per service
  6. Observe — Centralized logs, metrics dashboards, and trace visualization
  7. Secure — Automatic TLS, service identity, and network policies

Deployment Workflow

Developer                        Platform
────────                        ────────
micro build           ─────▶   Receive binary/image
micro deploy prod     ─────▶   Place on compute
                               Register with discovery
                               Start health checks
                               Route traffic

Choosing a Hosting Strategy

FactorSingle VPSMulti-ServerKubernetesPaaS
ComplexityLowMediumHighLow
CostLowMediumHighVariable
ScalingManualManualAutomaticAutomatic
Service discoverymDNSConsul/Etcd/NATSPlugin or ConsulExternal
Ops overheadMinimalModerateSignificantMinimal
Best forPrototypes, small appsGrowing teamsLarge-scale productionQuick launches

Getting Started

  1. Start simple — Deploy to a single server with micro deploy and mDNS
  2. Add a registry — When you need multiple servers, switch to Consul or Etcd
  3. Containerize — When you need reproducible environments, add Docker
  4. Orchestrate — When you need auto-scaling and self-healing, move to Kubernetes or a PaaS