Skip to content

Microservice System

This advanced example shows how multiple go-zero services collaborate using etcd for service discovery.

order-api ──→ order-rpc ──→ MySQL
inventory-rpc ──→ Redis
payment-rpc ──→ MySQL
  • etcd running on localhost:2379
  • MySQL and Redis available

Each service registers itself with etcd:

etc/order-rpc.yaml
Name: order.rpc
ListenOn: 0.0.0.0:8080
Etcd:
Hosts:
- 127.0.0.1:2379
Key: order.rpc
etc/order-api.yaml
OrderRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: order.rpc

Enable Prometheus metrics and Jaeger tracing:

Telemetry:
Name: order-api
Endpoint: http://jaeger:14268/api/traces
Sampler: 1.0
Batcher: jaeger
  • Service discovery via etcd
  • Multi-hop RPC call chains
  • Distributed tracing across services
  • Rate limiting and circuit breaking in action