Spacing Guild
API Gateway de alta performance
Spacing Guild es el API Gateway del cluster y el único punto de entrada público. Construido con Axum y Tower, logra 480K req/s en un solo core usando zero-copy request forwarding.
Características
- ✦480K req/s en un solo core
- ✦Zero-copy forwarding — el body del request nunca se copia en memoria
- ✦Rate limiting distribuido sincronizado vía Spice
- ✦Circuit breaker con estados: closed → open → half-open
- ✦mTLS automático entre gateway y servicios backend
- ✦Hot reload de rutas sin downtime
- ✦Retry automático con backoff exponencial
Configuración de rutas
toml
# /etc/dune/gateway.toml
[server]
bind = "0.0.0.0:8080"
workers = 4 # número de threads
[[routes]]
path = "/api/patients/*"
service = "patient-api"
methods = ["GET", "POST", "PUT"]
rate_limit = "1000/min"
timeout = "30s"
[[routes]]
path = "/api/labs/*"
service = "lab-svc"
rate_limit = "500/min"
[[routes]]
path = "/api/auth/*"
service = "bene-gesserit"
methods = ["POST"]
rate_limit = "100/min"
[circuit_breaker]
threshold = 5 # fallas consecutivas para abrir
timeout = "30s" # tiempo en estado open
half_open_max = 3 # requests en half-openCLI
bash
# Ver rutas activas
dune gateway routes
# ROUTE SERVICE METHOD RATE LIMIT
# /api/patients/* patient-svc * 1000/min
# /api/labs/* lab-svc * 500/min
# /api/auth/* bene-gesserit POST 100/min
# Estadísticas en tiempo real
dune gateway stats
# Total requests: 1,247,891
# Avg latency: 0.3ms
# P99 latency: 1.2ms
# Active conns: 342
# Circuit open: 0
# Reload de configuración
dune gateway reload
# ✦ Configuration reloaded (3 routes)