Back to Blog
team@tinypod.app

WebSocket Applications: Real-Time Self-Hosted Apps

WebSockets enable real-time features: chat, notifications, live updates. Here's how to deploy WebSocket apps on self-hosted infrastructure.

websocketsreal-timeinfrastructure

What Are WebSockets?


HTTP is request-response: client asks, server answers. WebSockets open a persistent, bidirectional connection. Server can push data to the client anytime.


Use Cases


  • Chat applications (Mattermost, Rocket.Chat)
  • Live notifications
  • Collaborative editing (real-time document editing)
  • Live dashboards (monitoring, analytics)
  • Multiplayer games
  • Live streaming chat

  • Reverse Proxy Configuration


    WebSockets require special reverse proxy configuration.


    Caddy

    Caddy handles WebSockets automatically. No special configuration needed. This is one of many reasons Caddy is ideal for self-hosting.


    Nginx

    You need explicit WebSocket upgrade headers:

    location /ws {

    proxy_pass http://app:3000;

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection "upgrade";

    }


    Cloudflare

    Enable WebSockets in your Cloudflare dashboard. Free plan supports WebSockets but with a 100-second idle timeout.


    Common Problems


    Connection Drops

    Load balancers and proxies often have idle timeouts. If no data is sent for 60 seconds, the connection drops. Solution: implement ping/pong heartbeats.


    Sticky Sessions

    If you have multiple app instances behind a load balancer, WebSocket connections must stick to the same instance. Use IP hash or cookie-based session affinity.


    Memory Usage

    Each WebSocket connection consumes server memory. A server with 1 GB RAM can typically handle 10,000-50,000 concurrent connections depending on the application.


    SSL/TLS

    Use wss:// (WebSocket Secure) in production. Your reverse proxy handles SSL termination — the app itself can use plain ws:// internally.


    Self-Hosted Real-Time Apps


  • Mattermost: Team chat with WebSocket-based real-time messaging
  • Rocket.Chat: Full-featured chat platform
  • Etherpad: Real-time collaborative text editing
  • Excalidraw: Collaborative whiteboarding

  • All work great on TinyPod. Caddy handles WebSocket proxying automatically.