Chat Room
Real-time messaging that scales, built in Go.
The Problem
Most WebSocket chat examples use Node.js. That works fine at small scale, but Go's concurrency model handles a much higher number of simultaneous connections with lower memory overhead. This project explores what a production-grade real-time server looks like in Go.
The Solution
Each chat room runs as a goroutine. Incoming WebSocket connections are handled concurrently with no shared mutable state between rooms — only the message broker touches Redis. This keeps the server logic simple and the concurrency model easy to reason about.
User Presence
When a user joins or leaves a room, all connected clients receive a presence event immediately. Redis stores the current member list for each room, so a new connection can display who's already in the room before any messages have been exchanged.
Message History
The last 100 messages per room are persisted in Redis and replayed to new connections on join. This means joining a conversation mid-way gives context without requiring a separate database or complex state synchronisation.