Architecting for 20 Million Concurrent Viewers: Inside JioCinema's IPL Live Streaming Infrastructure

Arpit Bhayani

Arpit Bhayani

May 17, 2024 • 12 min read

Play

Architecting for 20 Million Concurrent Viewers: Inside JioCinema’s IPL Live Streaming Infrastructure

Live-streaming the Indian Premier League (IPL) presents one of the most punishing distributed systems challenges in modern engineering. With over 20 million concurrent connections and peak events consuming up to 75% of India’s available internet bandwidth, conventional cloud design patterns fail.

When millions of users flood an application within seconds—such as when a star batsman walks onto the pitch—reactive auto-scaling collapses, client-side retry storms can trigger self-inflicted Distributed Denial of Service (DDoS), and standard database architectures saturate instantly.

This guide breaks down the engineering strategies, failure-mode isolation, caching tiers, and war-room lessons employed by JioCinema to reliably broadcast live sports at hyper-scale.


The Lifecycle of a Match Day: Operational Cadence

Handling an event of IPL scale is as much an operational discipline as it is an architectural one. A typical tournament spans 74 matches across several weeks, requiring an operational model that transitions from hands-on war rooms to automated baseline operations.

Match Schedule (7:30 PM Start)

├── T - 2 Hours: War Room Assembly
│   ├── Cloud Providers, CDN Partners, Payment Gateways on a unified bridge
│   ├── Pre-scale Compute (Kubernetes pods) & DB capacity
│   └── System-wide Metrics Review & Health Greenlight

├── T to T + 3.5 Hours: Live Match Execution
│   ├── "Touch-Me-Not" Policy (Zero manual interventions during play)
│   └── Dynamic Edge Steering (Multi-CDN optimization)

└── T + 3.5 Hours: Controlled Post-Match Teardown
    ├── Laddered Scale-Down (5M / 2M decrements)
    └── Post-Mortem & Debrief for Continuous System Tuning

The “Touch-Me-Not” Rule

During the 3.5-hour match window, a strict Touch-Me-Not policy is enforced. Under live match load, changing configurations or pushing non-critical patches carries unacceptable risk. If a system is stable, it remains untouched even if certain compute nodes are temporarily over-provisioned. Financial optimization yields entirely to platform stability during active streaming.


The Failure of Cloud Auto-Scaling at Extreme Scale

A common cloud misconception is that auto-scaling groups (ASGs) or Horizontal Pod Autoscalers (HPA) easily handle any arbitrary traffic surge. In live sports, reactive auto-scaling fails.

Why Auto-Scaling Breaks

  1. Lag Time vs. Match Dynamics: Live sporting spikes are nearly vertical (“hockey-stick” spikes). When a match-defining moment occurs, millions of viewers launch the stream within a 60-second window. Cloud instance spin-up, container pulling, application initialization, and database connection pool establishment can take anywhere from 5 to 45 minutes.
  2. Cloud Provider Limits: Provisioning thousands of high-memory or compute-heavy nodes on-demand frequently exhausts regional availability zones within cloud providers.
  3. Database Topology Constraints: Scaling database clusters (e.g., adding read replicas or sharding) is stateful, data-intensive, and cannot be executed safely on-the-fly under heavy load.

The Mathematical Alternative: Back-of-the-Envelope Pre-Scaling

Rather than scaling reactively, backend systems are pre-provisioned hours ahead of time using empirical baseline calculations.

Total Expected Origin Load = (Target Concurrency × Expected RPS per Client) × (1 - CDN Cache Hit Ratio)

To determine required infrastructure:

  1. Pod Baseline: Benchmark a single Kubernetes pod under isolated load to identify its safe operating threshold (typically 60% CPU/Memory utilization to leave a 40% headroom buffer).
  2. API Fan-Out Ratio: Calculate how many downstream database reads are triggered by one frontend API hit (e.g., 1 API call3 DB queries1\text{ API call} \rightarrow 3\text{ DB queries}).
  3. CDN Absorption: Assume a minimum acceptable cache offload (e.g., 90%\ge 90\%) to determine the residual requests that will hit the origin.
  4. Pre-Allocation: Provision sufficient database read capacity and stateless compute nodes across multiple availability zones prior to the war room sign-off.

Controlled Ladder Scale-Down

When the match concludes, millions of users do not drop instantly; many stay to watch post-match analysis or browse VOD (Video On Demand) catalogs.

Directly dropping compute capacity from a 20-million-user baseline to standard operating levels causes instant cascade failures on remaining nodes. JioCinema scales down using ladder decrements (e.g., stepping down from a 20M profile, to 15M, to 10M, to 5M). Kubernetes liveness and readiness probes, coupled with graceful HTTP request draining, ensure in-flight sessions terminate cleanly before pods are terminated.


Front-End Architecture: Graceful Degradation and Traffic Control

Client applications (Android, iOS, Android TV, Web) represent the front line of system defense. A naive client can easily bring down a resilient backend.

graph TD
    A[Client App Request] --> B{Feature Classification}
    B -->|P0: Critical Path| C[Video Stream & Ads Engine]
    B -->|P1: High Value| D[Personalized Recommendations]
    B -->|P2: Value-Add| E[Stickers, Chat, Reactions]
    
    D -->|Failure Detected| F[Silent Fallback / Static Catalog]
    E -->|Failure Detected| G[Drop Request / Suppress UI Errors]

Feature Tiering: P0, P1, and P2

To prevent application crashes when downstreams become latent, features are rigorously partitioned:

  • P0 (Absolute Core): Video playback engine and Server-Side Ad Insertion (monetization). Under no circumstances can these fail.
  • P1 (Primary Features): Personalized carousels, regional language homepages, and live stats. If these fail, the client drops back to global static fallbacks.
  • P2 (Secondary Features): Live interactive chat, animated team stickers, and dynamic viewer counters. If these systems degrade, they are disabled entirely without showing user-facing error dialogs.

Eliminating Retry Storms

When an API fails during peak traffic, client developers often implement retry loops. If millions of devices execute naive retries (N×3N \times 3), origin servers already running at capacity face an exponential load multiplier.

Naive Retry:     Request (Fail) ──> Retry 1 (Fail) ──> Retry 2 (Fail)  [Thundering Herd]

Exponential:     Request (Fail) ──[wait 2^1s + rand]──> Retry 1 ──[wait 2^2s + rand]──> Drop

Clients must enforce:

  • Strict Exponential Backoff with Full Jitter: Ensures failed requests scatter evenly across a dynamic time window.
  • Client-Side Circuit Breaking: If a P1/P2 endpoint returns continuous 5xx errors, the client disables subsequent requests locally for that session.
  • Total Suppression of “Something Went Wrong” Dialogs: If a secondary service degrades, the app swallows the error, hides the UI widget, and lets the match stream uninhibited.

Network Simulation and Validation

Prior to tournament deployment, front-end builds undergo chaos simulation using proxy tools like Charles and custom network conditioning suites. Engineers inject artificial network partitions, elevated latency (>2000ms>2000\text{ms}), DNS resolution failures, and simulated 502/503/504 responses across every critical API to verify the app plays video smoothly regardless of peripheral failures.


High-Impact Architecture Strategies

1. Multi-CDN Optimization and Edge Balancing

No single Content Delivery Network (CDN) possesses sufficient edge capacity or point-of-presence (PoP) density to handle entire-country streaming traffic alone. JioCinema employs a Multi-CDN model.

graph LR
    User[Client Application] --> MCO[Multi-CDN Optimizer]
    MCO -->|Telemetry & Health Score| Decision{Dynamic Route}
    Decision -->|Primary Route| CDN_A[CDN Provider A]
    Decision -->|Spillover Route| CDN_B[CDN Provider B]
    Decision -->|Failover Route| CDN_C[CDN Provider C]
    CDN_A --> Origin[Origin Server / Storage]
    CDN_B --> Origin
    CDN_C --> Origin
  • Dynamic CDN Steering: An in-house Multi-CDN Optimizer balances traffic across providers. It continuously evaluates edge health, response latency, and regional network congestion.
  • Micro-Regional Rerouting: If an edge server cluster in a specific state (e.g., Maharashtra) encounters packet loss or capacity limits, the optimizer shifts incoming clients from that geographic cohort to an alternate CDN without disrupting playback.
  • Separation of Stacks: CDNs are isolated by asset type: Video Stack, API Stack, and Image/Static Asset Stack. An issue affecting the image cache cannot compromise video segment delivery.

2. The “Panic Mode” Static Fallback Architecture

When databases reach 100% CPU utilization and cache layers fail, traditional systems show error screens. JioCinema implements an automated Panic Mode.

[Normal Path]
Client ──> Multi-CDN ──> Origin Compute ──> Database Layer

[Panic Mode Activated]
Client ──> Multi-CDN ──> Pre-Warmed Static Object Storage (S3 / Blob Store)
                         └── (Pre-baked JSON snapshots of Home, Catalog & Playback APIs)
  1. Periodic Pre-Baking: Automated background jobs continuously dump clean, valid JSON responses for critical APIs (Catalog, Navigation, Stream Metadata) into high-durability static object stores.
  2. CDN Path Flipping: If origin systems cross critical degradation thresholds, CDNs immediately redirect /catalog and /playback origin routes to the pre-warmed static buckets.
  3. User Experience: Personalized carousels are temporarily replaced with a global static lineup. Crucially, the “Play Match” button remains functional, and video streaming continues completely uninterrupted.

3. Asynchronous Buffering with Apache Kafka

For write-heavy paths—such as user telemetry, telemetry events, and concurrent viewer counting—synchronous execution is strictly prohibited.

  • Partition Planning: Kafka partitions are sized weeks in advance based on strict throughput metrics (GB/sec input vs. consumer group processing rates).
  • Local Fallback Buffering: If Kafka brokers experience latency under peak traffic, API nodes temporarily spool telemetry events to local disk/memory buffers rather than blocking in-flight user threads.
  • Consumer Throttling: Non-critical data consumers (e.g., offline analytics pipelines) are paused during live matches. Processing power is reserved exclusively for real-time consumer groups like concurrent view-count aggregation.

Server-Side Ad Insertion (SSAI) at Scale

Monetizing 20 million concurrent streams is fundamentally different from traditional display ads. Standard programmatic ad auctions cannot process 20 million individualized ad requests within the span of a 30-second over-break.

Ad Insertion StrategyMechanismProsCons at 20M Scale
Static Ad InsertionSingle pre-recorded ad burned into the video feedSimple, zero extra infrastructureZero targeting, minimal CPM value
1:1 Dynamic Client Ad Insertion (CSAI)Client requests individual ad via VAST/VMAP when marker is reachedHighly personalizedMassive buffering, broken ABR switches, ad-block vulnerability, crashes origin
Targeted Cohort Server-Side (SSAI)Back-end stitches personalized ads into HLS/DASH manifest per cohortSeamless playback, ad-block resistant, high CPMHigh computing complexity at origin

The Cohort SSAI Mechanism

JioCinema uses Server-Side Ad Insertion (SSAI) powered by viewer cohorts:

Live Camera Feed (Stadium)


Playout System (Human Operator detects Match Director cues "Go to Ads")


SCTE-35 Marker Injection (Splice Point embedded into Video Stream)


Manifest Stitcher Pipeline
      ├── Cohort A (Region: North / Sports Fans)   ──> Stitches Ad Segment A
      ├── Cohort B (Region: South / Tech Enthusiasts) ──> Stitches Ad Segment B
      └── Cohort C (Global Fallback)               ──> Stitches Default Ad


Uniform HLS/DASH Stream Delivered to CDN
  1. Human-in-the-Loop Signaling: Because cricket overs conclude dynamically based on gameplay, match playout operators monitor director cues to insert SCTE-35 digital cue markers into the live broadcast pipeline.
  2. Cohort Segmentation: Rather than personalizing 1:11:1 across 20 million users, viewers are grouped into distinct target cohorts based on geography, viewing profile, and device type.
  3. Manifest Manipulation: Manifest stitchers assemble video chunks such that ad segments match the video codec, bitrate, and Adaptive Bitrate (ABR) ladder of the live cricket stream. Viewers experience zero playback buffering or resolution drops when transitioning between live action and advertisements.

Real-World War Room Case Studies

Incident 1: The 1-Million RPS Sticker Avalanche

  • The Symptom: Days into the IPL season, CDN alerts indicated the Image Delivery Stack had hit 90% CPU capacity, risking an outage across all thumbnail and UI assets.
  • The Cause: A new “Chat Stickers” feature was introduced on the playback screen. When a user opened the player, the client requested up to 50 individual PNG stickers concurrently. With millions entering the stream, this single sub-feature generated 1,000,000 to 10,000,000 RPS purely for static sticker assets.
  • The Mitigation:
    1. Immediate: Extended edge cache Time-To-Live (TTL) to prevent requests from bouncing to the image origin.
    2. Architectural Fix: Converted stickers into Base64-encoded strings bundled inside a single composite JSON payload. The client downloaded all 50 stickers in a single HTTP request, immediately slashing CDN load from millions of RPS down to under 100,000 RPS.

Incident 2: The Silent Regional ISP DNS Blackout

  • The Symptom: Customer support received isolated reports that users in specific apartment complexes and regions could not open the app, even though the internal dashboard was completely green and streaming was healthy.
  • The Cause: A regional Internet Service Provider (ISP) stopped honoring DNS TTLs and failed to flush/refresh authoritative domain records for JioCinema endpoints. To the ISP’s customers, the application appeared dead, while JioCinema’s internal metrics recorded no incoming failure because requests never left the ISP’s network.
  • The Mitigation:
    1. Temporary Workaround: Identified that switching affected devices to public DNS resolvers (e.g., Google DNS 8.8.8.8 or Cloudflare 1.1.1.1) instantly restored access.
    2. In-App SDK Hardening: Integrated a secondary, fallback DNS resolution mechanism directly within the mobile application network layer. If native OS-level DNS resolution fails on the primary domain, the SDK attempts resolution using secure DNS-over-HTTPS (DoH) via public resolvers to establish connection to the streaming edge.

Core Architectural Takeaways

  1. Cache Offload is the Ultimate Metric: At hyper-scale, backend efficiency matters less than cache performance. If CDN offload drops below 90%, backend databases will collapse under load regardless of node counts.
  2. Design for Predictable Traffic Shifts: Traffic moves according to gameplay. When a star enters the game, playback ingestion APIs absorb the shock; when a star gets out, navigation and home catalog APIs absorb the shock as millions return to the app shell.
  3. Fail Silently on Peripheral Features: Never display a disruptive error dialog for an ancillary failure. If chat, stickers, or personalization endpoints break, hide the interface components and protect core video playback.
  4. Pre-Scale Ahead of Time: Treat dynamic auto-scaling as a fallback rather than a primary scaling plan for synchronized live events. Calculate requirements via rigorous back-of-the-envelope modeling and secure compute capacity long before the first ball is bowled.
Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses