Workflow Tools

Build a reproducible low-cost cloud relay with restream.io that preserves sub-second chat and donation sync

Build a reproducible low-cost cloud relay with restream.io that preserves sub-second chat and donation sync

I recently needed a reproducible, low-cost way to relay a single live encode to multiple platforms while keeping chat and third‑party alerts (donations, cheers, tips) effectively in sync with sub‑second or near‑real‑time responsiveness. Commercial multistream services solve video distribution easily, but once you add chat aggregation and overlay alerts, latency and inconsistency creep in — viewers on one platform can see a tip before people watching elsewhere, or the streamer sees a donation on their stream delay‑shifted by several seconds. I built a practical cloud relay pattern around Restream.io plus a tiny, cheap server-side component that keeps alerts in sync with chat aggregation. The result is reproducible, inexpensive, and works with standard tools like OBS, StreamElements/Streamlabs, and browser sources.

Why use a cloud relay and what I cared about

A cloud relay centralizes one incoming live feed and fans it out to many platforms. That lets you:

  • send a single, well‑sized bitrate to the cloud and avoid multiple encodes;
  • offload connection variability to the relay (platform reconnections, restarts);
  • manage destinations centrally (add/remove channels without changing your encoder).
  • But the tradeoff is latency introduced by the relay and by each destination platform. My requirements were:

  • keep end‑to‑end video latency low enough for live interaction;
  • preserve sub‑second or near‑real donation/alert sync between chat/overlays and the streamer's view;
  • be reproducible (documented steps and minimal infra) and low cost (preferably <= $10–$15/month additional).
  • High‑level architecture I use

    Here’s the architecture I recommend and use myself:

  • Local encoder (OBS) -> Restream.io ingest (RTMP/RTMPS or SRT)
  • Restream -> multiple platforms (Twitch, YouTube, Facebook, etc.)
  • Chat aggregation: Restream Chat or platform chat clients aggregated to a browser source in OBS
  • Alerts/donations: payment providers (StreamElements/Streamlabs/Donorbox/etc.) deliver webhooks directly to a tiny server (Node.js socket.io) running on a cheap VPS or a serverless function. That server immediately pushes event data to a browser source in OBS via WebSocket
  • The key idea: don’t funnel alerts through the video relay. Let the alert system be a separate, low‑latency channel that the overlay browser source subscribes to (via WebSocket). That keeps alerts near‑instant and synchronised with chat seen by the streamer.

    Step‑by‑step setup (practical)

    Follow these steps in order. I’ll include specific OBS settings I rely on and a simple server pattern you can deploy in minutes.

  • Sign up for Restream.io and configure destinations.
  • - Create a Restream account (the free tier works for basic distribution, but paid tiers enable more destinations and some low‑latency options). Add Twitch/YouTube/Facebook or any RTMP targets.

  • Configure OBS to send to Restream.
  • - Output: use Simple or Advanced as you prefer. Key settings I use for multi‑destination reach:

  • Resolution: 720p (1280x720) or 1080p if your bandwidth allows
  • Bitrate: 3500–5000 kbps for 720p/1080p depending on upload capacity
  • Keyframe interval: 2 (important for platform compatibility)
  • Encoder: x264 or NVENC — NVENC offloads CPU if you have an NVIDIA GPU
  • CPU preset: faster/veryfast for predictability
  • - Set OBS to stream to the Restream RTMP URL and stream key provided.

  • Choose ingest protocol. RTMP is simplest; SRT is lower‑latency and more resilient on lossy links.
  • - If your encoder supports SRT, try SRT to Restream (where supported). Otherwise, RTMP/RTMPS is fine. Keep buffer settings minimal on the encoder.

  • Enable Restream chat aggregation.
  • - Use the Restream chat widget either via their desktop app or the web chat in a browser dock. For overlays, add Restream Chat as a browser source if you want aggregated chat visible in your stream. Restream’s aggregation is generally fast (1–3s), but platform‑specific delays still apply.

  • Deploy a tiny alerts relay (Node.js socket.io) — cheapest options: $5/mo VPS or serverless.
  • - Why: when someone donates, many platforms call a webhook. If you have a small server listening to webhooks and then pushing immediately via WebSocket to your overlay browser source, you avoid slow polling or reliance on third‑party desktop apps.

    - Minimal Node pattern (conceptual):

  • Express endpoint receives /webhook POST from StreamElements/Streamlabs/etc.
  • Emit event via socket.io (or ws) to connected overlay clients.
  • Overlay browser source connects to ws://yourserver:PORT and renders alerts instantly.
  • - Deployment: DigitalOcean Droplet $5/month, or use Railway/Vercel for serverless (but persistent WebSocket is easier on a small VPS). I document the tiny Node script and Dockerfile in my repo to make it reproducible.

  • Hook donation providers directly to your webhook endpoint.
  • - In StreamElements/Streamlabs, set the alerts to use webhook delivery or add a custom webhook integration. Configure with your server URL (https://yourrelay.example.com/webhook).

  • Connect your OBS overlay browser source to the relay socket.
  • - Create a browser source with the URL that serves the overlay HTML and connects to your socket server. The overlay only receives events — it doesn’t need to be the source of truth for donations. That keeps alert rendering fast.

    Testing and verification

    Once configured, test thoroughly:

  • Send test tips/donations from each provider and observe the time delta between the streamer’s overlay and the platform chat notifications.
  • Use two separate devices to watch the same platform vs another platform to verify alert ordering and times.
  • Measure network latencies: from encoder to Restream (RTMP handshake), Restream to platform (platform internal buffering), and webhook roundtrip to your server.
  • In my tests with typical residential uplink and Restream, I see:

    PathTypical latency
    Encoder -> Restream1–2s (RTMP), 0.5–1.5s (SRT)
    Restream -> Twitch2–6s (Twitch affects this)
    Webhook -> Overlay via WebSocket<500ms for the relay server on a cheap VPS

    Cost breakdown and reproducibility

    A minimal reproducible stack I use costs roughly:

  • Restream: free to $16+/mo depending on destinations and features
  • VPS (DigitalOcean, Vultr): $5–$6/mo for a small droplet to run Node/socket.io
  • Domain + SSL: ~$1–$3/mo if you use Cloudflare + a cheap domain (Cloudflare provides free SSL)
  • Total: around $6–$25/mo depending on Restream tier. All steps are scriptable: I keep Terraform/Dockerfiles and a deploy script that sets up the Node server, generates a Let’s Encrypt cert, and wires the webhook URL to the providers, so I can reproduce the environment in under 20 minutes.

    Tradeoffs and gotchas

    Some important things I learned and advise watching out for:

  • Platform buffering is unavoidable. Even if your overlay shows a donation instantly, viewers on some platforms will still see it slightly later due to platform buffers.
  • Don’t route donation events through Restream; their video relay isn’t designed to be a real‑time event bus.
  • Use browser sources for overlays — they’re fast, easily updated, and integrate well with WebSockets.
  • SRT is great if your encoder supports it. It reduces packet loss and can shave a second or two off latency.
  • Monitor resource usage on your VPS. Socket.io is lightweight, but misconfigured logs or memory leaks can cause outages. I include simple uptime checks and Docker restart policies in my deploy scripts.
  • If you want, I can share the exact Node.js relay template, the OBS browser source HTML for alerts, and a checklist that lets you deploy the whole stack in a reproducible way (with Dockerfile and DigitalOcean one‑click). Tell me which donation providers you use and whether you prefer SRT or RTMP for ingest, and I’ll tailor the template to your setup.

    You should also check the following news:

    How to set up a two-tier minipaywall for clips that increases conversions without hurting organic reach
    Content Monetization

    How to set up a two-tier minipaywall for clips that increases conversions without hurting organic reach

    I’ve been testing paywalls on short-form clips for years, and one pattern keeps working: a...

    Jul 05 Read more...
    How to build a sub‑200 automated caption pipeline using whisper, ffmpeg and scheduled uploads
    Workflow Tools

    How to build a sub‑200 automated caption pipeline using whisper, ffmpeg and scheduled uploads

    I’m going to walk you through a practical, repeatable pipeline I use to generate captions for...

    Jun 24 Read more...