NEWUse coupon code SMX20 to get 20% OFF your first billing cycle on any game server or VPS!Explore Store

VPS HOSTING

VPS Hosting for WebSocket Applications

Host WebSocket applications (chat, live dashboards, notifications, collaboration, multiplayer) on a VPS: Nginx proxying, connection limits, heartbeats, scaling across processes with Redis pub/sub, sticky sessions, reconnection, security and sizing by concurrent connections.

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?

WebSocketsServer-Sent Events (SSE)
DirectionTwo-wayServer to client only
ProtocolUpgrade from HTTPPlain HTTP streaming
ReconnectionImplement in client (libraries help)Built into browsers
Good forChat, collaboration, gamesNotifications, 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=65535 in its systemd unit) and Nginx's worker_rlimit_nofile and worker_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_hash or 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 Origin header 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

ApplicationSuggested plan
Notifications or live dashboards, thousands of mostly idle connections2 vCores / 8 GB
Chat or collaboration with steady message flow4 vCores / 16 GB, several processes + Redis
High-frequency updates or large broadcasts8 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.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vPro XS (AMD EPYC)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹420/moWebsites, small APIs, bots, staging and VPN serversOrder
SMX vPro S (AMD EPYC)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹560/moWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
SMX vPro M (AMD EPYC)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹840/moProduction databases, high-traffic sites, multi-container appsOrder
SMX vPro L (AMD EPYC)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹1,120/moLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

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.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vCore XS (Intel Xeon)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹270/moBusiness websites, small apps, scheduled jobs and botsOrder
SMX vCore S (Intel Xeon)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
SMX vCore M (Intel Xeon)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
SMX vCore L (Intel Xeon)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,248/monthHigh-memory workloads and consolidated production serversCheck 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?
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.

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.

Was this article helpful?

Your feedback helps us continuously improve ServoMix guides.

Share this article

Know someone who may find this guide useful?

VPS Hosting for WebSocket and Real-Time Applications | ServoMix