Upgrade to Pro — share decks privately, control downloads, hide ads and more …

nginx.conf 15 - globo.com's live video platform...

nginx.conf 15 - globo.com's live video platform for fifa world cup 14

In this talk, we will describe globo.com's live video stream architecture, which was used to broadcast events such as the FIFA World Cup (with peak of 500K concurrent users), Brazilian election debates (27 simultaneous streams) and BBB (10 cameras streaming 24/7 for 3 months) .
Nginx is one of the main components of our platform, as we use it for content distribution, caching, authentication, and dynamic content. Besides our architecture, we will also discuss the Nginx and Operational System tuning that was required for a 19Gbps throughput in each node, the open source Cassandra driver for Nginx that we developed, and our recent efforts to migrate to nginx-rtmp.

this was presented by leandro moreira and juarez bochi at nginx.conf in 09/23/15

Avatar for Leandro Moreira

Leandro Moreira

September 23, 2015

More Decks by Leandro Moreira

Other Decks in Technology

Transcript

  1. an amazing teamwork Leandro Moreira other teams Daniel Martins Flávio

    Ribeiro Juarez Bochi Hugo Roque Robson Soares Rafael Borsani Bernardo Camilo Lucas Mundim Juan Almeida more people
  2. Agenda (4+ years of work) 2010 Architecture for FIFA World

    Cup 10 2012 Mobile support 2013 HLS adoption 2014 DVR 2014 Waiting room 2014 FIFA World Cup results 2015 Recap & Next steps
  3. {2010} in the beginning encoder h264+aac rtmp tcp h264+aac rtmp

    tcp flash player firewall 1935 1º 2º 3º 4º RTMP
  4. {2012} how does HLS work? seg1.ts seg2.ts seg3.ts seg4.ts 240p.m3u8

    480p.m3u8 720p.m3u8 seg1.ts seg2.ts seg3.ts seg4.ts seg1.ts seg2.ts seg3.ts seg4.ts 1 - GET /variant.m3u8 (text) 2 - GET /720p.m3u8 (text) 240p.m3u8 variant.m3u8 480p.m3u8 720p.m3u8 3 - GET /seg3.ts (video) 4 - GET /seg4.ts (video) 5 - GET /720p.m3u8 (text) 6 - GET /seg5.ts (video) 7 - GET /seg6.ts (video) 8 - ... http http seg3.ts seg4.ts seg5.ts seg6.ts seg3.ts seg4.ts seg5.ts seg6.ts seg3.ts seg4.ts seg5.ts seg6.ts
  5. {2012} first hls solution encoder h264+aac rtmp tcp h264+aac http

    tcp flash player 2º 3º 5º 4º android ios 1º HTTP
  6. {2012} generation and distribution rtmp video playlists files location ~

    /hls { root "/vol/hls/"; } dest = "/vol/hls"; http BE FE segmenter
  7. {2012} first solution architecture BE FE LB SE LB LB

    auth & cache mostly cache hls generation upstream upstream http
  8. {2013} instrumentation Graphite • status code • request t. •

    cache hit • cpu usage • memory • buffer rate • bitrate time-series data graph api http enqueue dequeue metric x t snmp metric x t agents
  9. {2014} caching configuration don’t forget to: proxy_cache_use_stale updating 011011100 110011101

    101001011 011100111 1000 video0.ts video0.ts expired UPDATING FE BE proxy_cache_lock
  10. {2014} OS fine tuning 19Gpbs maxconn: 70k, cpu affinity 15Gpbs

    maxconn: 40k, cpu affinity 12Gpbs maxconn: 25k, irqbalance packet loss 4Gbps, no fine tuning *each machine has 2 NIC bonded (10GB each one)
  11. {2014} farm size FE: 80 nodes 24 cores 64 GB

    1TB 10 Gbps 10 Gbps BE: 6 nodes SE: 2 nodes
  12. {2014} what is DVR for hls? /720p.m3u8 #EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3

    #EXT-X-MEDIA-SEQUENCE:1 #EXTINF:5, seg1.ts #EXTINF:5, seg2.ts #EXTINF:5, seg3.ts /720p.m3u8 #EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:1 #EXTINF:5, seg1.ts #EXTINF:5, seg2.ts #EXTINF:5, seg3.ts #EXTINF:5, seg4.ts #EXTINF:5, seg5.ts #EXTINF:5, seg6.ts #EXTINF:5, seg7.ts #EXTINF:5, seg8.ts #EXTINF:5, seg9.ts #EXTINF:5, seg10.ts
  13. ingest {2014} reviewing current solution frontend encoder h264+aac rtmp tcp

    h264+aac http tcp flash player 2º 3º 5º 4º android ios 1º
  14. {2014} dvr challenges :: failover didn’t have a failover option

    for DVR #EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:10 #EXTINF:5, seg10.ts #EXTINF:5, seg11.ts #EXTINF:5, seg12.ts #EXTINF:5, seg13.ts #EXTINF:5, seg14.ts #EXTINF:5, seg15.ts #EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:1 #EXTINF:5, seg1.ts
  15. {2014} dvr challenges :: storage 2h * 60m * 60s

    / 5s * 4.5mb ~= 6.4GB } 1.6MB 1.1MB 0.8MB 0.5MB 0.3MB 0.1MB 4.5MB per 5s 2 games + 4 other streams ~= 38.4GB 02:00:00 00:00:00
  16. {2014} redis as a datastore ingest embed-script: fetch and serve

    hls frontend daemon: mon file change and save hls
  17. {2014} from redis to cassandra ingest embed-script: fetch and serve

    hls frontend daemon: mon file change and save hls
  18. {2014} multihoming (anycast) ISPx ISPy ISPk SP BGP announcement 186.192.81.0/24

    ISPx ISPy ISPk RJ 186.192.81.2 BGP announcement 186.192.81.0/24 PoP PoP
  19. • > 500k simult. users (peak 1 game) • ~=

    125.000 video req/s (peak 1 game) • > 640 Gbps (peak 1 game) FIFA 2014 World Cup Brazil data
  20. FIFA 2014 World Cup Brazil data • ~= 1600 watched

    years (sum all) • > 40M video views (sum all) • ~= avg 6 Gbps, max 19 Gbps
  21. • ~= cpu usage max 10% (per node, FE) •

    ~= avg bitrate 480 Kbps (crowded) • ~= avg bitrate 1864 Kbps (less crowded) FIFA 2014 World Cup Brazil data
  22. • video streaming: ◦ delivery and caching ◦ geolocation (geofencing)

    ◦ authorization / authentication • microservices ◦ playlist generation ◦ waiting room ◦ streams per account locking system Nginx usage
  23. is amazing Lua was made in Brazil :) TDD with

    busted easier to develop performance near C (lang)
  24. OSS from this history m3u8 parser cassandra driver clappr evostream

    api live_thumb nginx-audio-track-module BemTV iprange
  25. summary and future 2010 FIFA 2012 BBB 2014 FIFA Elections

    • hls • http • flash • rtmp • hls • http • dvr 2016 Olympic Games • dash ??? • ingest ??? • 4k ???