Architecture
Clustering

Service Discovery Options

Choose from manual configuration, Consul, etcd, or Kubernetes-native discovery for your cluster topology.

Service Discovery Methods Comparison

Service discovery methods with trade-offs

Discovery Methods

Manual

Static node list in configuration file.

  • • Simple to set up
  • • No external dependencies
  • • Requires restart for changes
  • • Good for: dev, small clusters

Consul

HashiCorp Consul service registry.

  • • Health checking built-in
  • • DNS + HTTP discovery
  • • Key-value for config
  • • Good for: production multi-DC

etcd

CoreOS etcd distributed key-value store.

  • • Strong consistency (Raft)
  • • Watch for changes
  • • Used by Kubernetes
  • • Good for: existing etcd infra

Kubernetes
Recommended

Native K8s service and endpoint discovery.

  • • Headless services
  • • Automatic pod discovery
  • • Label selectors
  • • Good for: K8s deployments

Configuration Examples

Manual

{
  "discovery": {
    "type": "manual",
    "nodes": [
      { "id": "node-1", "host": "10.0.0.1", "port": 9000 },
      { "id": "node-2", "host": "10.0.0.2", "port": 9000 },
      { "id": "node-3", "host": "10.0.0.3", "port": 9000 }
    ]
  }
}

Consul

{
  "discovery": {
    "type": "consul",
    "consul": {
      "address": "consul.service.consul:8500",
      "serviceName": "mlgraph",
      "datacenter": "dc1",
      "token": "consul-acl-token",
      "healthCheck": {
        "interval": "10s",
        "timeout": "5s",
        "deregisterAfter": "1m"
      }
    }
  }
}

Kubernetes

{
  "discovery": {
    "type": "kubernetes",
    "kubernetes": {
      "namespace": "mlgraph",
      "labelSelector": "app=mlgraph,component=node",
      "portName": "grpc",
      "watchTimeout": "30s"
    }
  }
}

# Kubernetes Service (headless)
apiVersion: v1
kind: Service
metadata:
  name: mlgraph-nodes
spec:
  clusterIP: None  # Headless
  selector:
    app: mlgraph
  ports:
    - name: grpc
      port: 9000

Comparison

FeatureManualConsuletcdK8s
Dynamic updatesNoYesYesYes
Health checksNoYesManualYes
External depsNoneConsuletcdK8s API
Best forDevMulti-DCExistingK8s native