Real-time features such as chat, live dashboards, notifications, collaborative editing, order tracking and multiplayer games keep a connection open between browser and server so updates arrive instantly. That changes hosting in a few important ways: connections last minutes or hours, proxies must pass them through correctly, and scaling across processes needs a shared message layer.
WebSockets or Server-Sent Events?
| WebSockets | Server-Sent Events (SSE) | |
|---|---|---|
| Direction | Two-way | Server to client only |
| Protocol | Upgrade from HTTP | Plain HTTP streaming |
| Reconnection | Implement in client (libraries help) | Built into browsers |
| Good for | Chat, collaboration, games | Notifications, live feeds, dashboards |
If clients only receive updates and send occasional normal HTTP requests, SSE is simpler and works through more proxies.
Nginx Configuration
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
server_name app.example.com;
location /ws/ {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}
The default proxy read timeout (60 seconds) closes quiet connections; raise it, and also send heartbeats so idle connections stay alive through other intermediaries. For SSE, disable proxy buffering for the stream location (proxy_buffering off;).
Connection Limits
- Raise the service's open-file limit (
LimitNOFILE=65535in its systemd unit) and Nginx'sworker_rlimit_nofileandworker_connections. - Each connection uses memory in your application; measure it under load and multiply by your peak.
- Nginx holds two sockets per proxied connection (client and upstream).
Heartbeats and Reconnection
Networks drop connections silently, especially on mobile. Send ping/pong frames every 20–30 seconds and close connections that stop responding. Clients should reconnect with exponential backoff and jitter, then resynchronise missed state (for example by requesting messages since the last received ID). Avoid thundering herds after a server restart by spreading reconnects.
Scaling Across Processes and Servers
A single Node.js process uses one core. With several processes or servers, a message for a user may need to reach a connection held by another process:
- Pub/sub layer: Redis pub/sub or streams (Socket.IO's Redis adapter) broadcast messages to all processes (see our Redis guide).
- Sticky sessions: some libraries' fallback transports require a client to reach the same process; use
ip_hashor cookie-based stickiness in the load balancer (see our load balancing guide). - Stateless handlers: keep durable state in the database, not only in process memory.
Deploys Without Disconnect Storms
Restarting a process drops its connections. Drain gracefully: stop accepting new connections, tell clients to reconnect after a randomised delay, then exit. With several processes behind Nginx, restart them one at a time so others absorb reconnects (see our long-running applications guide).
Security
- Use
wss://(TLS) only. - Authenticate during the handshake (cookie session or a short-lived token), and re-check authorisation for each channel or room a client joins.
- Validate the
Originheader to prevent cross-site WebSocket hijacking. - Rate-limit messages per connection and cap message size.
- Never trust client messages; validate everything server-side.
Monitoring
Track open connections, connects and disconnects per minute, message rates, event-loop lag and memory per process. A sudden rise in reconnects often signals a network or server problem before users complain.
Sizing
| Application | Suggested plan |
|---|---|
| Notifications or live dashboards, thousands of mostly idle connections | 2 vCores / 8 GB |
| Chat or collaboration with steady message flow | 4 vCores / 16 GB, several processes + Redis |
| High-frequency updates or large broadcasts | 8 vCores / 32 GB or several servers |
See our concurrency guide for estimating load.
Common Mistakes
- Default 60-second proxy timeouts closing quiet connections.
- No heartbeats, so dead connections pile up.
- Multiple processes without a pub/sub layer, so some users miss messages.
- Authorising only at connect time and not per room.
- All clients reconnecting at the same instant after a deploy.
In Short
Proxy upgrades correctly with long timeouts, raise connection limits, use heartbeats and smart reconnection, share messages through Redis when scaling, and secure every handshake and channel.
Example: Live Order Dashboard
A delivery company shows live order and rider status to dispatchers. A Node.js service on a 4 vCore / 16 GB VPS runs four processes behind Nginx, sharing updates through Redis pub/sub. Dispatchers' browsers hold WebSocket connections with 25-second heartbeats; when a deploy restarts a process, clients reconnect after a random delay of a few seconds and fetch any updates they missed.
Next Steps
Decide whether you need two-way WebSockets or one-way SSE, configure Nginx and limits, add heartbeats and reconnection, and load test with your expected number of simultaneous connections. Document the setup in a short runbook covering where data lives, how integrations run, how to restore from backup and whom to contact, so the system stays dependable even when the person who configured it is unavailable or has moved on to another role. Review the setup every quarter with the people who use it, because needs change as the business grows, and small adjustments made early are far cheaper than large changes made under pressure. Before go-live, run a short pilot with a small group of real users and a realistic volume of data, collect their feedback on speed, reliability and everyday tasks, and fix what they report, because early fixes cost far less than changes made after everyone depends on the system.
ServoMix Plans for This Workload
Idle WebSocket connections are cheap; message rates and work per message drive CPU. 2 vCores / 8 GB holds thousands of mostly idle connections; busy real-time apps with frequent broadcasts need 4–8 vCores.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| SMX vPro XS (AMD EPYC) | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹420/mo | Websites, small APIs, bots, staging and VPN servers | Order |
| SMX vPro S (AMD EPYC) | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹560/mo | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| SMX vPro M (AMD EPYC) | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹840/mo | Production databases, high-traffic sites, multi-container apps | Order |
| SMX vPro L (AMD EPYC) | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹1,120/mo | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| SMX vCore XS (Intel Xeon) | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹270/mo | Business websites, small apps, scheduled jobs and bots | Order |
| SMX vCore S (Intel Xeon) | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| SMX vCore M (Intel Xeon) | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| SMX vCore L (Intel Xeon) | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,248/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the ServoMix store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Frequently Asked Questions
How do I proxy WebSockets through Nginx?
Why do my WebSocket connections drop after a minute?
How many WebSocket connections can a VPS hold?
How do I scale WebSockets across processes?
Should I use server-sent events instead?
How do I deploy without disconnecting everyone at once?
How do I secure WebSockets?
What should clients do when disconnected?
What should I monitor?
Which plan suits a real-time app?
Related Guides
- AMD EPYC VPS for Concurrent User Workloads
- How to Deploy Redis on a VPS for Application Caching
- How to Set Up a Load Balancer Across Multiple VPS Servers with Nginx
- AMD EPYC VPS for React and Node.js Projects
- AMD EPYC VPS for Long-Running Applications
- Free Standard VPS Trial — Test Before You Buy | ServoMix
- Free Offshore VPS Trial — Test Before You Buy | ServoMix
- Offshore VPS in India — Deploy Instantly (2026)
Frequently Asked Questions
How do I proxy WebSockets through Nginx?
Use proxy_http_version 1.1 with Upgrade and Connection headers, and raise proxy_read_timeout well above 60 seconds.
Why do my WebSocket connections drop after a minute?
Usually the proxy's default read timeout. Raise it and send heartbeats so idle connections stay alive.
How many WebSocket connections can a VPS hold?
Thousands of mostly idle connections on a small server, if file limits are raised; message rate and work per message drive CPU needs.
How do I scale WebSockets across processes?
Share messages through Redis pub/sub or a broker and use sticky sessions where your library requires them.
Should I use server-sent events instead?
For one-way updates such as notifications and live feeds, SSE is simpler and reconnects automatically.
How do I deploy without disconnecting everyone at once?
Drain connections gracefully, ask clients to reconnect after randomised delays, and restart processes one at a time.
How do I secure WebSockets?
Use wss, authenticate at the handshake, authorise each room, check the Origin header, and rate-limit and validate messages.
What should clients do when disconnected?
Reconnect with exponential backoff and jitter, then fetch any missed state.
What should I monitor?
Open connections, connect and disconnect rates, message rates, event-loop lag and memory per process.
Which plan suits a real-time app?
2 vCores / 8 GB for notifications and dashboards; 4–8 vCores for chat, collaboration or high-frequency updates.
Your feedback helps us continuously improve ServoMix guides.
Know someone who may find this guide useful?
