MasterController
Monitoring & Scaling
Observe it, then scale it across many instances.
MasterController is built for production fleets: structured logging, Prometheus-compatible metrics, and Redis-backed coordination for running many instances behind a load balancer.
Structured logging#
Internally the framework logs error-coded, structured events (e.g. MC_ERR_CONTROLLER_EXCEPTION) via Winston, so your aggregator can parse and alert on them.
Prometheus metrics#
Install the optional peer dependency and expose a metrics endpoint your Prometheus scraper can read:
bash
npm install prom-clientmetrics
import { collectMetrics } from 'mastercontroller/monitoring/metrics.js';
// Request counts, latencies, and error rates are exported in Prometheus format.Horizontal scaling with Redis#
Run multiple instances behind a load balancer and share session state, rate-limit counters, and the Socket.IO adapter through Redis:
bash
npm install ioredisscaling
// Sessions, rate limiting, and sockets coordinate through Redis,
// so any instance can serve any request and broadcasts reach all clients. Optional by design
ioredis and prom-client are optional peer dependencies — single-instance apps run great without them, and you add them only when you scale out.