A production-ready Django-based WebSocket service with zero-downtime blue/green Docker Compose deployment, observability, and health checks.
-
Blue/Green Deployment via Docker Compose (nginx reverse proxy with
app_blueandapp_greenservices) -
WebSocket Endpoint at
/ws/chat/powered by Uvicorn + Django Channels -
Observability with Prometheus metrics (
/metrics) and Grafana dashboards -
Health Checks:
/healthz(liveness) and/readyz(readiness) -
Automation Scripts:
scripts/promote.sh: Flip traffic from blue to greenscripts/monitor.sh: Tail logs for errors and print top‑5 Prometheus counters every 10 sscripts/ws_test.js: k6 load test script for WebSocket performance
- Docker >= 27.0.0
- Docker Compose >= 2.29.0
git clone git@github.com:prxssh/prod-websocket-service && cd prod-websocket-serviceThis command first spins up the required prerequisites for the application (Grafana, dashboards, k6, nginx) and then starts both app_blue and app_green services.
docker-compose --env-file dev.env -f docker/compose.yml up -d- WebSocket:
ws://localhost:80/ws/chat/?session=<uid> - Liveness:
http://localhost:80/healthz - Readiness:
http://localhost:80/readyz - Metrics:
http://localhost:80/metrics - Grafana:
http://localhost:3000(default credentialsadmin/admin)
To flip traffic from the current color to the standby color:
./scripts/promote.shThis script will:
- Build and start the next color stack
- Run smoke tests against
/healthz - Update nginx to route traffic
- Tear down the old color stack
Tail real-time logs for errors and see top‑5 Prometheus counters:
./scripts/monitor.shBy default, Docker Compose will run the k6 load test automatically when the application starts, writing results to k6-results/ (or you can view them via the k6 container logs).
To run the load test manually, execute:
k6 run scripts/ws_test.js- See DESIGN.md for concurrency and deployment rationale
- See OBSERVABILITY.md for Prometheus/Grafana setup
