websocket-design

Design WebSocket architecture with connection management, message protocols, scaling, and fallback strategies.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill websocket-design-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: websocket-design
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/08-api-integration/websocket-design
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill websocket-design-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ws, socket.io, @socket.io/redis-adapter, redis, socket.io-client, prom-client.

What problem does it solve? Building real-time bidirectional communication systems requires solving connection lifecycle management, multi-server message synchronization, reconnection handling, and security — problems that basic Socket.IO tutorials do not address. ## Core Features & Use Cases - Protocol Selection Guidance: Compares native WebSocket, Socket.IO, and GraphQL subscriptions across browser support, reconnection, and fallback behavior. - Production Server Patterns: Provides Node.js implementations with JWT authentication middleware, room-based broadcasting, Redis adapter for horizontal scaling, and rate limiting. - Client & Reliability Patterns: Includes React hook integration, exponential backoff reconnection, message queuing, and Prometheus metrics for connections, latency, and throughput. - Use Case: Design a chat system supporting 100k concurrent connections across multiple servers, using the Redis adapter to sync messages and heartbeat pings to detect dead connections. ## Quick Start Design a WebSocket architecture for a real-time chat application with 100k concurrent users, including authentication, scaling, and reconnection strategy.

Frequently Asked Questions about websocket-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I scale Socket.IO across multiple servers?

Use the @socket.io/redis-adapter package with Redis pub/sub to synchronize messages across server instances. Clients connected to different servers receive broadcasts because events are published through shared Redis channels per room or user.

Socket.IO vs native WebSocket: which should I use?

Socket.IO provides automatic reconnection, long-polling fallback for older browsers, and built-in rooms and namespaces. Native WebSocket is simpler with lower overhead but requires manual reconnection and offers no fallback for unsupported browsers.

How do I authenticate WebSocket connections with JWT?

Pass the token in socket.handshake.auth and verify it in Socket.IO middleware using io.use() before allowing the connection. Reject invalid tokens by calling next() with an error, and attach the user ID to the socket for later authorization checks.

How do I handle WebSocket reconnection without losing messages?

Enable reconnection with exponential backoff (reconnectionDelay, reconnectionDelayMax) and on reconnect, resubscribe to rooms and request missed messages using a sync event with the last received timestamp. Queue outgoing messages client-side while disconnected.

What metrics should I monitor for WebSocket servers?

Track active connections with a gauge, message throughput with a counter labeled by type, and message latency with a histogram (p50, p95, p99). Also monitor reconnection rate and error rate to detect instability or abuse.