M.U.M.N.K8s: reportes en tiempo real sobre Kubernetes
Un sistema distribuido en Google Cloud que recibe miles de reportes por segundo, los pasa por microservicios en Rust y Go, una cola de RabbitMQ y Valkey, y los muestra en Grafana. Lo diseñé, programé y operé de punta a punta para el laboratorio de Sistemas Operativos 1.
- Rol
- Proyecto individual: arquitectura, código e infraestructura
- Curso
- Sistemas Operativos 1, USAC · 2.º semestre 2026
- Infraestructura
- GKE con 3 nodos n1-standard-2 y una VM de Compute Engine
- Stack
- Rust (axum), Go, gRPC, RabbitMQ, Valkey, Grafana, Helm, Locust
El problema
Cada reporte simulado trae un país, los aviones y barcos en operación y una marca de tiempo. El sistema tenía que recibirlos por HTTP en una ruta pública, sostener picos de carga sin perder datos, almacenarlos con estadísticas (máximos, mínimos, modas y rankings por país) y mostrarlos en un dashboard en vivo. Todo con imágenes servidas desde un registro privado y con piezas que escalan solas.
Cómo fluye un reporte
Mueve el control de usuarios para ver cómo reacciona el sistema: el HPA agrega réplicas de rust-api cuando la CPU pasa del 30 %, y con el límite de memoria original (256 MiB) los pods mueren a alta carga, igual que en la primera prueba real.
M.U.M.N.K8s: real-time reports on Kubernetes
A distributed system on Google Cloud that takes in thousands of reports per second, passes them through Rust and Go microservices, a RabbitMQ queue and Valkey, and shows them in Grafana. I designed, built and ran it end to end for the Operating Systems 1 lab.
- Role
- Solo project: architecture, code and infrastructure
- Course
- Operating Systems 1, USAC · 2nd semester 2026
- Infrastructure
- GKE with 3 n1-standard-2 nodes and a Compute Engine VM
- Stack
- Rust (axum), Go, gRPC, RabbitMQ, Valkey, Grafana, Helm, Locust
The problem
Each simulated report carries a country, the aircraft and ships in operation and a timestamp. The system had to take them over HTTP on a public route, absorb load spikes without losing data, store them with statistics (max, min, modes and per-country rankings) and show them on a live dashboard, with every image served from a private registry and the pieces scaling on their own.
How a report flows
Move the users slider to see how the system reacts: the HPA adds rust-api replicas when CPU goes over 30%, and with the original memory limit (256 MiB) the pods die under high load, just like in the first real test.
Modelo calibrado con las pruebas de carga reales del proyecto (no es tráfico en vivo).
Decisiones de diseño
- Gateway API y una API en Rust que escala sola. La entrada pública es un Gateway de GKE con una ruta por flujo. rust-api tiene un HPA de 1 a 3 réplicas con objetivo de 30 % de CPU; en la prueba subió de 1 a 3 réplicas en unos 40 segundos.
- gRPC balanceado desde el cliente. Con un Service normal, la conexión HTTP/2 persistente dejaba a la segunda réplica sin tráfico (0 reportes). Con un Service headless,
round_robinyMaxConnectionAgede 30 s en el servidor, 1 000 peticiones se repartieron 500 y 500. - RabbitMQ con confirmación de publicación. El writer solo da por enviado un reporte cuando el broker lo confirmó, y la cola amortigua los picos: la cola más larga en las pruebas fue de 92 mensajes, y 5 segundos después ya estaba vacía o casi.
- Un Operator propio para Valkey y Grafana. Con Operator SDK (basado en Helm) definí los recursos
ValkeyInstanceyGrafanaInstance. Para probar con 2 réplicas de Valkey bastó cambiarspec.replicasy el operador reconcilió el StatefulSet. - Un registro privado fuera del clúster. Zot corre en una VM de Compute Engine con HTTPS de Let's Encrypt, lectura anónima para que GKE descargue sin secretos y escritura con autenticación. Además de imágenes guarda la configuración de Locust, las reglas de Falco y su plugin como artifacts OCI.
Lo que salió mal (y cómo lo encontré)
En la primera ronda de alta carga, a unas 1 250 peticiones por segundo, entre el 31 % y el 55 % de las respuestas fueron 503 y los tres pods de rust-api terminaron en OOMKilled. La primera hipótesis, demasiadas peticiones en vuelo, no explicaba toda la memoria. Contando las conexiones abiertas en /proc/net/tcp apareció la causa real: el balanceador de Google mantenía unas 8 800 conexiones keep-alive por pod durante 10 minutos, y cada una ocupaba unos 38 KB.
La corrección fue dimensionar el límite de memoria con lo medido (512 MiB, contra un pico de 381 MiB). La siguiente corrida dio 0 fallos a 1 288 peticiones por segundo. La historia completa está en la bitácora.
Resultados
- 1 288 req/ssin fallos en la prueba final, con 3 nodos n1-standard-2
- 1 → 3 réplicasdel HPA en unos 40 segundos al llegar la carga
- 500 / 500reparto de 1 000 llamadas gRPC entre dos réplicas
- ~200 req/stecho del flujo alterno con Dapr por réplica, contra más de 1 275 con gRPC directo
La conclusión que más me llevo: agregar réplicas solo ayuda donde está el cuello de botella. Pasar el writer de 1 a 2 réplicas repartió la carga de forma pareja pero no subió el throughput y costó entre 34 % y 66 % más de CPU.
Pruébalo
El repositorio trae un Docker Compose con el mismo camino de datos, sin necesitar Google Cloud:
git clone https://github.com/akamariano/202101149_LAB_SO1_1S2026
cd 202101149_LAB_SO1_1S2026/Proyecto3
docker compose -f docker-compose.local.yml up --build -d
curl -X POST localhost:8080/grpc-202101149 -H 'Content-Type: application/json' \
-d '{"country":"GTM","warplanes_in_air":42,"warships_in_water":14,"timestamp":"2026-03-12T20:15:30Z"}'
Grafana queda en localhost:3000 (admin / admin). El despliegue completo en GKE está en la guía de instalación del repositorio.
Design decisions
- Gateway API and a Rust API that scales itself. The public entry point is a GKE Gateway with one route per flow. rust-api has an HPA from 1 to 3 replicas targeting 30% CPU; in the test it went from 1 to 3 replicas in about 40 seconds.
- Client-side gRPC load balancing. With a regular Service, the persistent HTTP/2 connection left the second replica with no traffic (0 reports). With a headless Service,
round_robinand a 30 sMaxConnectionAgeon the server, 1,000 requests split 500 and 500. - RabbitMQ with publisher confirms. The writer only counts a report as sent once the broker confirms it, and the queue absorbs spikes: the longest queue during the tests was 92 messages, and 5 seconds later it was empty or nearly so.
- My own Operator for Valkey and Grafana. With Operator SDK (Helm-based) I defined the
ValkeyInstanceandGrafanaInstanceresources. Testing with 2 Valkey replicas only took changingspec.replicas; the operator reconciled the StatefulSet. - A private registry outside the cluster. Zot runs on a Compute Engine VM with Let's Encrypt HTTPS, anonymous reads so GKE can pull without secrets, and authenticated writes. Besides images it stores the Locust config, the Falco rules and its plugin as OCI artifacts.
What went wrong (and how I found it)
In the first high-load round, at about 1,250 requests per second, between 31% and 55% of responses were 503 and all three rust-api pods ended up OOMKilled. The first hypothesis, too many in-flight requests, didn't explain all the memory. Counting open connections in /proc/net/tcp showed the real cause: Google's load balancer kept about 8,800 keep-alive connections per pod for 10 minutes, each taking about 38 KB.
The fix was to size the memory limit from what I measured (512 MiB, against a 381 MiB peak). The next run had 0 failures at 1,288 requests per second. The full story is in the notes.
Results
- 1,288 req/swith zero failures in the final test, on 3 n1-standard-2 nodes
- 1 → 3 replicasfrom the HPA in about 40 seconds once load arrived
- 500 / 500split of 1,000 gRPC calls between two replicas
- ~200 req/sceiling of the alternate Dapr flow per replica, against over 1,275 with direct gRPC
The lesson I keep: adding replicas only helps where the bottleneck is. Going from 1 to 2 writer replicas split the load evenly but didn't raise throughput, and it cost between 34% and 66% more CPU.
Try it
The repository includes a Docker Compose file with the same data path, no Google Cloud needed:
git clone https://github.com/akamariano/202101149_LAB_SO1_1S2026
cd 202101149_LAB_SO1_1S2026/Proyecto3
docker compose -f docker-compose.local.yml up --build -d
curl -X POST localhost:8080/grpc-202101149 -H 'Content-Type: application/json' \
-d '{"country":"GTM","warplanes_in_air":42,"warships_in_water":14,"timestamp":"2026-03-12T20:15:30Z"}'
Grafana runs on localhost:3000 (admin / admin). The full GKE deployment is in the repository's installation guide.