Investigations

Kubernetes Chat System

Go November 2024

A real-time distributed chat application using React, Go WebSockets, and RabbitMQ, deployed on Kubernetes.

The third and most complex Kubernetes investigation tackles the hard problem: real-time communication across scaled backend instances. If you have 5 Go WebSocket servers and a user connects to pod 3, how does a message from pod 1 reach them? RabbitMQ.

The React frontend manages WebSocket connections and displays messages, connection status, user counts, and which backend pod you're connected to. The Go backend publishes every incoming message to a RabbitMQ fanout exchange. Every backend instance subscribes, so a message sent to any pod propagates to all of them — and from there to every connected client.

RabbitMQ runs as a StatefulSet because it needs persistent identity and stable storage. The frontend and backend run as regular Deployments that can scale freely. This distinction — stateful vs. stateless workloads — was one of the key lessons.

The automatic reconnection handling was trickier than expected. When a pod dies during a rolling update, connected clients need to gracefully reconnect to a different pod without losing messages. Getting that right taught me more about WebSocket lifecycle management than any tutorial could.

What this project demonstrates

Real-time chat via WebSockets with cross-pod broadcasting
RabbitMQ fanout exchange for pub/sub across backend instances
React frontend with connection status and pod identification
Three-tier Kubernetes: React, Go backend, RabbitMQ StatefulSet
Automatic reconnection handling during rolling updates
Third in a three-part Kubernetes learning series

Technologies

KubernetesReactRabbitMQWebSocketsDistributed Systems

© 2026 Jonathan Leahy · v0.9.1