This document outlines what hosting looks like for go-micro services, the options available today, and what an ideal hosting platform would provide.
## Overview
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](deployment.html).
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.
- Deploy with `micro deploy` to each target server
- Use a central registry (Consul, Etcd, or NATS) for cross-host discovery
- Place a load balancer or API gateway in front of public-facing services
### 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:**
```dockerfile
FROMgolang:1.21-alpineASbuild
WORKDIR/app
COPY . .
RUN go build -o service ./cmd/service
FROMalpine:3.19
COPY --from=build /app/service /service
ENTRYPOINT["/service"]
```
**Kubernetes considerations:**
- Use the Kubernetes registry plugin or run Consul/Etcd as a StatefulSet
- ConfigMaps and Secrets replace environment files
- Kubernetes Services and Ingress handle external traffic
- Horizontal Pod Autoscaler manages scaling
- Liveness and readiness probes map to go-micro health checks
### Platform as a Service (PaaS)
Deploy to managed platforms like Railway, Render, or Fly.io. Each service runs as a separate application.
- Configuration via platform-provided environment variables
- Managed TLS and load balancing out of the box
- Use NATS or a hosted registry for service discovery between apps
- Limited control over networking and co-location
## 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.
| Environment | Recommended Registry |
|---|---|
| Single host | mDNS (default, zero config) |
| Multi-host / cloud | Consul, Etcd, or NATS |
| Kubernetes | Kubernetes 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.
- **Transport:** HTTP (default), gRPC, or NATS
- **Broker:** HTTP event broker (default), NATS, or RabbitMQ
- Internal traffic should stay on a private network
- External traffic flows through a gateway or load balancer
### Configuration Management
Each service loads configuration from environment variables, files, or remote sources. The platform should provide:
- Per-service environment variables or config files
- Secret management with restricted access
- Hot-reload support for dynamic configuration changes
### Data Storage
go-micro's store interface supports multiple backends. The platform should provide or connect to durable storage.
- **Development:** In-memory store (default)
- **Production:** Postgres, MySQL, Redis, or other supported backends
- Persistent volumes or managed database services for stateful data
### Health Checks and Observability
The platform should monitor service health and provide visibility into behavior.
- **Health endpoints** for liveness and readiness
- **Structured logs** collected and searchable
- **Metrics** (request rates, latencies, error rates) scraped or pushed
- **Distributed tracing** across service boundaries