Real-Time Web Client Scaling and WebSocket Resilience Plan
Formulate an architectural resilience and horizontal scaling plan for mission-critical real-time web applications.
Use this template when high-concurrency web clients require resilient bi-directional streaming under tight latency budgets. It details connection lifecycle management, edge fan-out, and fallback protocols.
Role: Staff Web Systems Engineer specializing in real-time communication protocols and distributed web clients.
Context
- Target service: {{realtime_service_name}}
- Peak concurrent connection target: {{peak_concurrent_connections}}
- Primary streaming transport: {{primary_transport_protocol}}
- Backing message broker: {{message_broker_engine}}
- Target client platforms: {{client_sdk_targets}}
- Maximum latency budget: {{max_latency_budget_ms}}
Task
Author a production-grade resilience and scaling plan for {{realtime_service_name}} that guarantees sub-{{max_latency_budget_ms}} message delivery under {{peak_concurrent_connections}} active sessions across all {{client_sdk_targets}}.
Method
- Evaluate connection handshake overhead and TLS termination topology for {{primary_transport_protocol}}.
- Design horizontal socket server clustering backed by pub/sub channels in {{message_broker_engine}}.
- Define client-side reconnection backoff, jitter algorithms, and missed message catch-up protocols.
- Establish transport fallback hierarchy (such as Server-Sent Events or long-polling) for restrictive networks.
- Specify heartbeat intervals, zombie connection pruning, and idle session memory footprints.
- Architect edge routing and stickiness rules across load balancers to distribute load evenly.
- Model load degradation states to shed non-essential real-time payloads during broker spikes.
Constraints
- MUST keep end-to-end client message latency under {{max_latency_budget_ms}} at peak load.
- MUST NOT permit reconnect storms (thundering herds) during edge node restarts.
- Edge load balancing must support graceful socket drain without dropping active transactions.
- Fallback transports must guarantee at-least-once message delivery.
Output format
Deliver the plan using the following named sections:
- Connection Topology and Broker Architecture (cluster design and routing rules)
- Client Resilience and Transport Fallback Flow (reconnection algorithms for {{client_sdk_targets}})
- Concurrency Benchmarks and Capacity Model (scaling math for {{peak_concurrent_connections}})
- Fault Injection and Incident Runbooks (3 key outage scenarios with step-by-step mitigations) Limit response to 800 to 1300 words.
Self-review
- Confirm jittered reconnection logic eliminates thundering herd risks on {{client_sdk_targets}}.
- Check that broker throughput calculations support {{peak_concurrent_connections}} without message drops.
- Validate that latency thresholds meet the {{max_latency_budget_ms}} requirement across all network paths.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.