Skip to content

System Architecture Overview

This document describes the overall architecture of Go-Live, a WebRTC SFU server built with Go and Pion WebRTC.

Architecture Diagram

Component Dependency Graph

Request Processing Chain

Core Concepts

Room

The Room is the core abstraction of the SFU. Each room:

  • Has at most one Publisher
  • Can have multiple Subscribers
  • Has independent Track Fanout logic
  • Can have its own authentication token

Track Fanout

When a publisher pushes media tracks, the system creates a Track Fanout:

  • Read RTP packets from the publisher's PeerConnection
  • Copy and distribute to all subscribers
  • Optionally write to recording files

PeerConnection

Each WebRTC connection:

  • Publisher: Receives media tracks
  • Subscriber: Sends media tracks
  • ICE negotiation completed through WHIP/WHEP protocols

Module Responsibilities

ModuleResponsibility
cmd/serverApplication entry point, service initialization
internal/configEnvironment variable parsing and defaults
internal/apiHTTP request handling, routing, middleware
internal/sfuWebRTC SFU core logic
internal/metricsPrometheus metrics exposure
internal/uploaderS3/MinIO file upload
internal/otelOpenTelemetry tracer initialization

Key Design Decisions

1. Single Publisher per Room

Simplifies the SFU logic and ensures predictable stream quality. Multiple publishers would require stream selection or mixing.

2. In-Memory Room State

Rooms are stored in memory for simplicity and performance. For multi-instance deployment, external storage (Redis/Database) would be needed.

3. RTP Forwarding without Transcoding

The SFU forwards RTP packets directly without decoding/encoding, minimizing latency and CPU usage.

4. Recording at SFU Level

Recording happens at the TrackFanout level, capturing the exact RTP packets being distributed to subscribers.

Performance Characteristics

MetricValue
Latency< 100ms (same region)
Concurrent Subscribers1000+ per room
Memory (idle)< 50MB
CPU EfficiencySingle core handles 500+ concurrent

Next Steps

Released under the MIT License.