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

OPENREC.tv におけるライブ動画およびメッセージ配信基盤の全貌 / 20170601_...

OPENREC.tv におけるライブ動画およびメッセージ配信基盤の全貌 / 20170601_aws_devday_tokyo_openrec

2017/6/1 14:20 ~ 15:00 プリンスホール
[CyberZ] OPENREC.tvにおけるライブ動画およびメッセージ配信基盤のリプレース全貌
http://www.awssummit.tokyo/devday/?id=type#D3T8-3

Taro Hirose

June 01, 2017
Tweet

More Decks by Taro Hirose

Other Decks in Technology

Transcript

  1. Today’s Contents ຊηογϣϯΛ௨ͯ͡ʮϥΠϒʯʹٻΊΒΕΔΞʔΩςΫςΟϯά Λ͝঺հ͠·͢ ▸ OPENREC.tv ͱ͸ ▸ ಈը഑৴ͷجຊ ▸

    ಈը഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ νϟοτͷجຊ ▸ ϦΞϧλΠϜϝοηʔδ഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ αʔϏεͷ੒௕ΛՃ଎ͤ͞ΔͨΊʹ
  2. whoami ኍ੉ ଠ࿠ / Taro Hirose ▸ OPENREC.tv / CyberZ,

    Inc. ▸ Backend Engineer ▸ id: @uorat ▸ http://uorat.hatenablog.com
  3. Today’s Contents ຊηογϣϯΛ௨ͯ͡ʮϥΠϒʯʹٻΊΒΕΔΞʔΩςΫςΟϯά Λ͝঺հ͠·͢ ▸ OPENREC.tv ͱ͸ ▸ ಈը഑৴ͷجຊ ▸

    ಈը഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ νϟοτͷجຊ ▸ ϦΞϧλΠϜϝοηʔδ഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ αʔϏεͷ੒௕ΛՃ଎ͤ͞ΔͨΊʹ
  4. Today’s Contents ຊηογϣϯΛ௨ͯ͡ʮϥΠϒʯʹٻΊΒΕΔΞʔΩςΫςΟϯά Λ͝঺հ͠·͢ ▸ OPENREC.tv ͱ͸ ▸ ಈը഑৴ͷجຊ ▸

    ಈը഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ νϟοτͷجຊ ▸ ϦΞϧλΠϜϝοηʔδ഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ αʔϏεͷ੒௕ΛՃ଎ͤ͞ΔͨΊʹ
  5. Today’s Contents ຊηογϣϯΛ௨ͯ͡ʮϥΠϒʯʹٻΊΒΕΔΞʔΩςΫςΟϯά Λ͝঺հ͠·͢ ▸ OPENREC.tv ͱ͸ ▸ ಈը഑৴ͷجຊ ▸

    ಈը഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ νϟοτͷجຊ ▸ ϦΞϧλΠϜϝοηʔδ഑৴ج൫ͷΞʔΩςΫνϟͱมભ ▸ αʔϏεͷ੒௕ΛՃ଎ͤ͞ΔͨΊʹ Live Streaming Real-Time
 Messaging
  6. ಈը഑৴ େ͖͘ 2 छͷ༻్͕͋Δ ▸ ΦϯσϚϯυ഑৴ ▸ ࢹௌऀ͕ ݟ͍ͨ࣌ ʹಈըΛࢹௌ͢Δ͜ͱ͕Ͱ͖Δ഑৴ํ๏

    ( abbr. VOD ) ▸ On-Demand = ʮཁٻʹԠͯ͡ʯ ▸ ૣૹΓ΍ר͖໭͠ͳͲͷ࠶ੜ੍ޚ͕Մೳ ▸ e.g. ౤ߘಈըɺΞʔΧΠϒಈը / λΠϜγϑτ ▸ ϥΠϒ഑৴ ▸ ϦΞϧλΠϜ ʹ഑৴͞Ε͍ͯΔಈըΛࢹௌ͢Δ͜ͱ͕Ͱ͖Δ഑৴ํ๏ ▸ ϦΞϧλΠϜࢹௌͳͷͰɺجຊతʹө૾ͷ࠶ੜ੍ޚ͸ߦ͑ͳ͍͜ͱ͕ଟ͍
  7. ಈը഑৴ ഑৴ํࣜ΋େ͖͘ 2 छ͋Δ ▸ Progressive Download ▸ Ұͭͷ·ͱ·ͬͨϝσΟΞσʔλΛμ΢ϯϩʔυͤ͞Δํࣜ ▸

    ϓϨΠϠʔ͸μ΢ϯϩʔυͰ͖ͨͱ͜Ζ͔Β࠶ੜ͢Δ ▸ γϯϓϧ͕ͩ՝୊͋Γ ▸ ϥΠϒ഑৴ඇରԠ ▸ ϝσΟΞϑΝΠϧͦͷ΋ͷΛ௚઀μ΢ϯϩʔυͤ͞ΔͨΊίϯςϯπอޢͷ؍఺Ͱ೉͋Γ ▸ Streaming ▸ ϝσΟΞσʔλΛࡉ͔͘෼ׂͯ͠ɺॱ࣍సૹ / μ΢ϯϩʔυͤ͞Δํࣜ ▸ Progressive Download ͱࣅͨΑ͏ʹɺμ΢ϯϩʔυͱฒߦͯ͠࠶ੜ͢Δ ▸ ࢹௌதʹσʔλ͕ੜ੒͞Εଓ͚ΔϥΠϒ഑৴ʹରԠՄೳ ▸ ໪࿦ΦϯσϚϯυ഑৴΋Մೳ
  8. ಈը഑৴ ഑৴ํࣜ΋େ͖͘ 2 छ͋Δ ▸ Progressive Download ▸ Ұͭͷ·ͱ·ͬͨϝσΟΞσʔλΛμ΢ϯϩʔυͤ͞Δํࣜ ▸

    ϓϨΠϠʔ͸μ΢ϯϩʔυͰ͖ͨͱ͜Ζ͔Β࠶ੜ͢Δ ▸ γϯϓϧ͕ͩ՝୊͋Γ ▸ ϥΠϒ഑৴ඇରԠ ▸ ϝσΟΞϑΝΠϧͦͷ΋ͷΛ௚઀μ΢ϯϩʔυͤ͞ΔͨΊίϯςϯπอޢͷ؍఺Ͱ೉͋Γ ▸ Streaming ▸ ϝσΟΞσʔλΛࡉ͔͘෼ׂͯ͠ɺॱ࣍సૹ / μ΢ϯϩʔυͤ͞Δํࣜ ▸ Progressive Download ͱࣅͨΑ͏ʹɺμ΢ϯϩʔυͱฒߦͯ͠࠶ੜ͢Δ ▸ ࢹௌதʹσʔλ͕ੜ੒͞Εଓ͚ΔϥΠϒ഑৴ʹରԠՄೳ ▸ ໪࿦ΦϯσϚϯυ഑৴΋Մೳ VOD / LIVE ͍ͣΕ΋ Streaming ഑৴͕τϨϯυ
  9. Live Streaming: Broadcaster Side RTMP w/ H.264/AAC ͷ૊Έ߹Θ͕ͤओྲྀ ▸ RTMP

    = Real-Time Messaging Protocol ▸ ࣋ଓ઀ଓܕϓϩτίϧ ▸ ಈըɾԻ੠σʔλΛ෼ׂͯ͠సૹ ▸ Τϯίʔυ ▸ ΫϥΠΞϯτଆͰө૾ & Ի੠σʔλΛѹॖ ▸ ө૾ & Ի੠σʔλͷѹॖํࣜ͸༷ʑ͋Δ ▸ ಈըίʔσοΫ: H.264/MPEG-4 AVC, H.265/HEVC, … ▸ Ի੠ίʔσοΫ: MP3, AAC, WMA, …
  10. Live Streaming: Broadcaster Side Α͘࢖ΘΕΔ഑৴ιϑτ΢ΣΞ ▸ RTMP = Real-Time Messaging

    Protocol ▸ ࣋ଓ઀ଓܕϓϩτίϧ ▸ ಈըɾԻ੠σʔλΛ෼ׂͯ͠సૹ ▸ Τϯίʔυ ▸ ΫϥΠΞϯτଆͰө૾ & Ի੠σʔλΛѹॖ ▸ ө૾ & Ի੠σʔλͷѹॖํࣜ͸༷ʑ͋Δ ▸ ಈըίʔσοΫ: H.264/MPEG-4 AVC, H.265/HEVC, … ▸ Ի੠ίʔσοΫ: MP3, AAC, WMA, … OBS Wirecast
  11. Live Streaming: Viewer Side HTTP ετϦʔϛϯάܕ͕ओྲྀ ▸ ετϦʔϛϯάܕ ▸ ઐ༻ϓϨΠϠʔ΍ϓϥάΠϯ͕ඞཁͱͳΔ

    ▸ RTMP w/ Adobe Flash ▸ RTSP/RTP w/ Windows Media, ReadMedia, QuickTime …etc ▸ MMS w/ Windows Media ▸ େྔϢʔβʔ΁ͷ഑৴ʹ͸େྔͷ Edge Server ͕ඞཁͱͳΔ ▸ HTTP ετϦʔϛϯάܕ ▸ ෼ׂ͞ΕͨܰྔͳϝσΟΞϑΝΠϧΛ HTTP Ͱ഑৴ ▸ ϒϥ΢β / σόΠεඪ४Ͱ࠶ੜՄೳʢͳ͜ͱ͕ଟ͍ʣ ▸ HLS ▸ MPEG-DASH ▸ HDS ▸ Smooth Streaming ▸ Ұൠతͳ Caching ٕज़ΛԠ༻Մೳ ▸ ݴ͍׵͑Ε͹ͨͩͷ HTTP ϑΝΠϧμ΢ϯϩʔυ
  12. Live Streaming: Viewer Side HTTP ετϦʔϛϯάܕ͕ओྲྀ ▸ ετϦʔϛϯάܕ ▸ ઐ༻ϓϨΠϠʔ΍ϓϥάΠϯ͕ඞཁͱͳΔ

    ▸ RTMP w/ Adobe Flash ▸ RTSP/RTP w/ Windows Media, ReadMedia, QuickTime …etc ▸ MMS w/ Windows Media ▸ େྔϢʔβʔ΁ͷ഑৴ʹ͸େྔͷ Edge Server ͕ඞཁͱͳΔ ▸ HTTP ετϦʔϛϯάܕ ▸ ෼ׂ͞ΕͨܰྔͳϝσΟΞϑΝΠϧΛ HTTP Ͱ഑৴ ▸ ϒϥ΢β / σόΠεඪ४Ͱ࠶ੜՄೳʢͳ͜ͱ͕ଟ͍ʣ ▸ HLS ▸ MPEG-DASH ▸ HDS ▸ Smooth Streaming ▸ Ұൠతͳ Caching ٕज़ΛԠ༻Մೳ ▸ ݴ͍׵͑Ε͹ͨͩͷ HTTP ϑΝΠϧμ΢ϯϩʔυ Amazon CloudFront
  13. Media Server Transcoding Live Streaming: Transcoding Middleware for Live Transcoding

    1080p 720p 360p 1080p 720p 360p 1080p 720p 360p HLS MPEG-DASH Adobe Media Server LIVE Smooth Streaming
  14. Time-Shifting Live Streaming >> Stop >> Archiving Broadcaster Media Server

    (Ingest / Transcode) Viewer CDN media file (e.g. mp4) transcode
  15. Time-Shifting Live Streaming >> Stop >> Archived = VOD Broadcaster

    Media Server (Ingest / Transcode) Viewer CDN media file (e.g. mp4) http(s) http
  16. ಈը഑৴ͷجຊݪଇ ʮ͓͕͔͔ۚΔʯ ▸ Processing ▸ τϥϯείʔσΟϯάʹཁ͢Δύϫϑϧͳ Processing Resource ▸ Memory

    ▸ τϥϯείʔσΟϯά࣌ͷ Buffer ▸ ഑৴ Caching ▸ Network ▸ ςΩετσʔλͱൺ΂ͯαΠζͷେ͖͍ϝσΟΞσʔλ ▸ ෆಛఆଟ਺ͷࢹௌऀ ▸ Storage ▸ ςΩετσʔλͱൺ΂ͯαΠζͷେ͖͍ϝσΟΞσʔλͷӬଓԽ
  17. Case: OPENREC.tv OPENREC.tv ͷϥΠϒ഑৴ͷཁ݅ ▸ ߴը࣭ɾ௿஗Ԇ ▸ ϢʔβʔυϦϒϯͷ഑৴ ▸ ಉ࣌഑৴਺΋഑৴࣌ؒ΋഑৴ऀ࣍ୈ

    ▸ ू٬ྗ΋഑৴ऀ࣍ୈ ▸ ∴ ෛՙ͕ಡΈͮΒ͍ ▸ ಉ࣌ࢹௌऀ਺ ແ੍ݶ ▸ ͍ΘΏΔ “࿮” ͸ແ͍ ▸ શϢʔβʔ౳͘͠ϥΠϒࢹௌͰ͖Δ͜ͱ ▸ શϥΠϒ഑৴ ΞʔΧΠϒ ▸ ͍ΘΏΔ “Time Shifting”, VODԽ ▸ ΞʔΧΠϒಈըΛެ։͢Δ͔Ͳ͏͔͸഑৴ऀͷࣗ༝
  18. Case: OPENREC.tv Architecture: Wowza on EC2 (c4, g2), CloudFront, S3,

    ElasticTranscoder Aurora LIVE API https LIVE CORE Broadcastrer ELB EC2 RDS EIP Wowza on EC2 CloudFront Distribution EIP Wowza on EC2 CloudFront Distribution rtmp Broadcastrer rtmp Viewer HLS (https) LIVE ARCHIVE CloudFront Distribution S3 bucket PutObjects Broadcastrer VOD PutObjects CloudFront Distribution S3 bucket ElasticTranscoder
  19. Case: OPENREC.tv Processing Layer Aurora LIVE API https LIVE CORE

    Broadcastrer ELB EC2 RDS EIP Wowza on EC2 CloudFront Distribution EIP Wowza on EC2 CloudFront Distribution rtmp Broadcastrer rtmp Viewer HLS (https) LIVE ARCHIVE CloudFront Distribution S3 bucket PutObjects Broadcastrer VOD PutObjects CloudFront Distribution S3 bucket ElasticTranscoder ▸ GPU Acceleration ▸ w/ g2 instance ▸ ಉ࣌഑৴਺ʹԠ֦ͨ͡ுॖୀ੍ޚ ▸ w/ EC2 API
  20. Case: OPENREC.tv CPU ࢖༻཰ ͕ 50 ʙ 70% ఔ౓ʹ཈͑ΒΕΔΑ͏ʹ഑৴Λ෼ࢄ Aurora

    LIVE API https LIVE CORE Broadcastrer ELB EC2 RDS EIP Wowza on EC2 CloudFront Distribution EIP Wowza on EC2 CloudFront Distribution rtmp Broadcastrer rtmp Viewer HLS (https) LIVE ARCHIVE CloudFront Distribution S3 bucket PutObjects Broadcastrer VOD PutObjects CloudFront Distribution S3 bucket ElasticTranscoder ▸ GPU Acceleration ▸ w/ g2 instance ▸ ಉ࣌഑৴਺ʹԠ֦ͨ͡ுॖୀ ੍ޚ ▸ w/ EC2 API
  21. Case: OPENREC.tv Network Layer Aurora LIVE API https LIVE CORE

    Broadcastrer ELB EC2 RDS EIP Wowza on EC2 CloudFront Distribution EIP Wowza on EC2 CloudFront Distribution rtmp Broadcastrer rtmp Viewer HLS (https) LIVE ARCHIVE CloudFront Distribution S3 bucket PutObjects Broadcastrer VOD PutObjects CloudFront Distribution S3 bucket ElasticTranscoder All transfer in AWS ▸ CDN Caching ʹΑΔ Origin ΁ͷ Request ݮ ▸ CDN Edge - Origin ؒͷ Latency ▸ Origin → CDN ؒͷ σʔλసૹඅ༻ ▸ CDN σʔλసૹඅ༻ͷ Volume Discount
  22. 2014 - 2015 ϓϨΠಈը࿥ը SDK ࣌୅ ▸ εϚϗಛԽͷϓϨΠಈըڞ༗αʔϏε ▸ iOS

    / Android ͔Β ࿥ը / ฤू / ౤ߘ ▸ ࠾༻ ▸ ౰࣌ͷ؊ͷ SDK ։ൃʹ஫ྗ
  23. 2015 - 2016 ಈը౤ߘ → LIVE ഑৴΁ ▸ খ࢝͘͞ΊΔ ▸

    ϦʔυλΠϜ࡟ݮͷͨΊ Zencoder Live Λ׆༻ ▸ େ͖͘ҭͯΔ ▸ 2016 ೥ʹೖΔͱ LIVE ʹ஫ྗ ▸ ߴը࣭ɾ௿஗Ԇɾ௿අ༻ʹ޲͖߹͏ LIVE
  24. 1st Replace in 2016 Mid Replace Transcoder Aurora LIVE API

    https LIVE CORE Broadcastrer ELB EC2 RDS EIP Wowza on EC2 CloudFront Distribution EIP Wowza on EC2 CloudFront Distribution rtmp Broadcastrer rtmp Viewer HLS (https) LIVE ARCHIVE CloudFront Distribution S3 bucket PutObjects Broadcastrer VOD PutObjects CloudFront Distribution S3 bucket ElasticTranscoder
  25. 2016 Mid - Later ΞʔΧΠϒػೳͷ՝୊ײ ▸ VODԽʹཁ͢ΔϦʔυλΠϜ ▸ ϥΠϒऴྃޙʹύοέʔδϯά͞Εͨ mp4

    Λ ETS Ͱ ࠶ Transcode ͯ͠ S3 ʹӬଓԽ ▸ ഑৴͕24࣌ؒʹ΋ͳΔͱ໨΋౰ͯΒΕͳ͍ ▸ Elastic Transcoder ͷඅ༻૿ ▸ ΞʔΧΠϒର৅͸ શϥΠϒ഑৴ ▸ ެ։/ඇެ։͸ ഑৴ऀͷݖར ▸ ྉۚ͸ ಈը਺ × ഑৴࣌ؒ ͷֻ͚߹Θͤ
  26. 2nd Replace in 2016 Later Extract by Wowza MPEG-TS Ingestion

    Listner API Broadcaster Media Server (Ingest / Transcode) Viewer CDN http(s) On Memory Extract plugin rtmp http
  27. 2nd Replace in 2016 Later Extract by Wowza MPEG-TS Ingestion

    Listner API ▸ Wowza Streaming Engine v4.5.0 or later ▸ ϥΠϒ഑৴தϝϞϦ্ʹ͋Δ HLS Λநग़ ▸ ଈ࣌ΞʔΧΠϒԽΛ࣮ݱ ▸ ΞʔΧΠϒԽͷͨΊͷ࠶ Transcoding අ ༻Λେ෯࡟ݮ ▸ Elastic Transcoder ͸౤ߘಈը΍ɺෆ҆ఆͳϥΠϒಈ ըͷม׵ʹҾ͖ଓ͖ར༻
  28. 2017 Early ن໛ͷ֦େ ▸ ಉ࣌ϥΠϒ഑৴਺ ૿Ճ ▸ 2016 Mid: ʙ

    ਺े ▸ 2017 Mid: ʙ ਺ඦ ▸ ͜Εʹ൐͍ αʔό਺΋૿Ճ ▸ ϩʔϦϯά σϓϩΠ / ϝϯςφϯεͷ൥Θ͠͞ ▸ ϥΠϒ഑৴Λड͚෇͚ͨ Wowza αʔόΛϥΠϒऴྃ·Ͱམͱͤͳ͍ ▸ ഑৴ऀ͔Βͷ઀ଓ͸࣋ଓ઀ଓ RTMP ▸ ϢʔβʔओಋͷϥΠϒ഑৴͸ऴ͕ྃ࣌ؒಡΊͳ͍ LIVE CORE EIP Wowza on EC2 CloudFront Distribution EIP Wowza on EC2 CloudFront Distribution
  29. Next 3rd Replace Wowza αʔόΛشൃԽ Amazon ECR (Container Registory) Developer

    ECS Cluster Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container)
  30. Next 3rd Replace Expire >> Drain >> Stop Container Amazon

    ECR (Container Registory) Developer ECS Cluster Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container)
  31. Next 3rd Replace Expire >> Drain >> Stop Container Amazon

    ECR (Container Registory) Developer ECS Cluster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container)
  32. Next 3rd Replace Expire >> Drain >> Stop Container Amazon

    ECR (Container Registory) Developer ECS Cluster Container Instance Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container)
  33. Next 3rd Replace ഑৴਺ʹԠͯ͡ Container ͔Β Instance ͔Β EIP/DNS Record

    ·Ͱ AutoScale Amazon ECR (Container Registory) Developer ECS Cluster RunTask Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Container Instance
  34. Next 3rd Replace ϦϦʔε࡞ۀ͸ `docker image push` ͷΈ Amazon ECR

    (Container Registory) Developer docker image push ECS Cluster Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Container Instance
  35. Next 3rd Replace ͋ͱ͸৽Πϝʔδ͕উखʹਁಁ͢ΔͷΛ଴͚ͭͩ Amazon ECR (Container Registory) Developer docker

    image push ECS Cluster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) RunTask
  36. Next 3rd Replace Container Scheduler ▸ EC2/ECS Auto Scaling ͸૬ੑ͕ѱ͍

    ▸ RTMP = ৗ࣌઀ଓ ▸ ෛՙ͕௿ͯ͘΋഑৴͍ͯ͠Ε͹ॖୀͰ͖ͳ͍ ▸ “഑৴ঢ়گ” ͱ͍͏ಠࣗࢦඪʹج͍ͮͯ εέʔϧͤ͞Δεέδϡʔϥʔ͕ඞཁ
  37. Container Scheduler 1. ▸ Container Scheduler for Amazon ECS ▸

    re:Invent 2016 Ͱެ։͞Εͨ golang ੡ OSS ▸ ECS Cluster ༻ͷΧελϜεέδϡʔϥΛ࣮૷Մೳ ▸ ECS Cluster ͷΠϕϯτݕ஌ ▸ ECS Cluster ͷঢ়ଶ௥੻ ▸ ΧελϜεέδϡʔϥʔͷ࣮ߦ ▸ REST API ͷఏڙ
  38. Container Scheduler 2. Amazon ECS Event Stream + Lambda ▸

    Amazon ECS ͷλεΫͱίϯςφΠϯελϯεͷঢ়ଶߋ৽Λ hook ʹ Lambda function Λ࣮ߦ Amazon ECS CloudWatch Events Lambda Event Stream Event
  39. Next 3rd Replace 3. CloudWatch Events (scheduled/1min) + Lambda +

    API ECS Cluster Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Container Instance Aurora LIVE API ELB EC2 RDS CloudWatch Events scheduled 1 minute ec2::RunInstances ecs::RunTask ecs::StopTask ec2::StopInstances …
  40. Next 3rd Replace 3. CloudWatch Events (scheduled/1min) + Lambda +

    API ECS Cluster Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Broadcaster Container Instance Task (Container) Container Instance Aurora LIVE API ELB EC2 RDS CloudWatch Events scheduled 1 minute ec2::RunInstances ecs::RunTask ecs::StopTask ec2::StopInstances … Coming soon…
  41. OPENREC.tv ʹ͓͚Δ Chat Offline - Online ؒͷۭؒڞ༗ ▸ ձ৔ͷྟ৔ײΛ Online

    Ͱٙࣅମݧ ▸ e.g. e-sports Πϕϯτ RAGE ▸ Communication ▸ ഑৴ऀ - ࢹௌऀ ؒ ▸ ࢹௌऀ - ࢹௌऀ ؒ
  42. OPENREC.tv ͷνϟοτͷཁ݅ ϦΞϧλΠϜϝοηʔδ഑৴ج൫ ▸ ϦΞϧλΠϜੑ ▸ Online - Offline ؒͷྟ৔ײͷڞ༗

    ▸ ഑৴ऀ - ࢹௌऀ, ࢹௌऀ - ࢹௌऀ ؒͷॏཁͳର࿩खஈ ▸ ߴ֦ுੑ ▸ ಉ࣌ࢹௌऀ਺૿ʹ௥ैͰ͖ΔεέʔϥϏϦςΟ ▸ ໷ؒʹूத͢ΔϥΠϒ഑৴
  43. OPENREC’s Chat in 2015 1st Architecture: Node.js (WebSocket) + Redis

    (Pub/Sub) + API (ELB / EC2) Chat API https WebSocket Cluster ELB EC2 RDS EIP Node.js on EC2 EIP Node.js on EC2 ElastiCache for Redis (Pub/Sub) wss wss Viewer
  44. Chat API https WebSocket Cluster ELB EC2 RDS EIP Node.js

    on EC2 EIP Node.js on EC2 ElastiCache for Redis (Pub/Sub) wss wss Viewer OPENREC’s Chat in 2015 1st Architecture: Node.js (WebSocket) + Redis (Pub/Sub) + API (ELB / EC2) ▸ WebSocket ઀ଓΛࣗ࡞ API Ͱ෼ࢄ ▸ ELB (Classic) ͕ WebSocket ඇରԠͷͨΊ
  45. Chat API https WebSocket Cluster ELB EC2 RDS EIP Node.js

    on EC2 EIP Node.js on EC2 ElastiCache for Redis (Pub/Sub) wss wss Viewer OPENREC’s Chat in 2015 1st Architecture: Node.js (WebSocket) + Redis (Pub/Sub) + API (ELB / EC2) ▸ API ͔Βฦ͞ΕΔ endpoint ʹ WebSocket ઀ଓཱ֬ ▸ Message Hub ʹ ElastiCache for Redis Λ࠾༻
  46. OPENREC’s Chat After 1 year … Chat API https WebSocket

    Cluster ELB EC2 RDS EIP Node.js on EC2 EIP Node.js on EC2 ElastiCache for Redis (Pub/Sub) wss wss Viewer ൥Θ͕͠͞෾ग़ ▸ Not AutoScaling ▸ EIP + DNS record ▸ SSL αʔό ূ໌ॻߋ৽ Redis Cluster Λ෼ࢄ͍ͤͨ͞ ▸ Pub/Sub ૿
  47. OPENREC’s Chat Replaced Architecture Chat API https WebSocket Cluster ELB

    (CLB) EC2 RDS ELB (ALB) wss Viewer Aurora Node.js Cluster w/ AutoScaling ElastiCache for Redis (Pub/Sub) Target Group Node.js Cluster w/ AutoScaling ElastiCache for Redis (Pub/Sub) Target Group
  48. OPENREC’s Chat Replaced Architecture Chat API https WebSocket Cluster ELB

    (CLB) EC2 RDS ELB (ALB) wss Viewer Aurora Node.js Cluster w/ AutoScaling ElastiCache for Redis (Pub/Sub) Target Group Node.js Cluster w/ AutoScaling ElastiCache for Redis (Pub/Sub) Target Group ▸ Contents Based Routing Λ׆༻ͨ͠ Sharding ▸ wss ઀ଓऴ୺ʹΑΔӡ༻ ෛՙݮ
  49. OPENREC’s Chat Replaced Architecture Chat API https WebSocket Cluster ELB

    (CLB) EC2 RDS ELB (ALB) wss Viewer Aurora Node.js Cluster w/ AutoScaling ElastiCache for Redis (Pub/Sub) Target Group Node.js Cluster w/ AutoScaling ElastiCache for Redis (Pub/Sub) Target Group ▸ AutoScaling ׆༻ʹΑΔӡ༻ෛՙݮ ▸ Middleware Version up ▸ Node.js ▸ Socket.IO
  50. Point of WebSocket Application w/ AutoScaling Scaling ʹ͓͍ͯز͔ͭͷ஫ҙ͕ඞཁ ▸ ૣΊʹεέʔϧΞ΢τͤ͞Δ

    ▸ WebSocket = ࣋ଓ઀ଓܕϓϩτίϧ ▸ ෛՙ͕ภΓ͗͢ͳ͍Α͏ʹૣΊʹεέʔϧΞ΢ τͤ͞Δͱྑ͍ ▸ ॏཁͳࢦඪ ▸ ಉ࣌઀ଓ਺ ▸ ϝοηʔδྲྀྔʢPub/Sub ස౓ʣ ▸ ϝοηʔδαΠζ
  51. Point of WebSocket Application w/ AutoScaling Scaling Policy ▸ γϯϓϧʹ

    CPU Utilization ͕͓͢͢Ί ▸ ᮢ஋Λݫ͠Ίʹ ૣΊʹ Scale out ▸ Increase ͸හײʹ Decrease ͸؇͘ ▸ ϐʔΫଳ΍Πϕϯτ͕ಡΊΔ৔߹͸ Scheduled Policy ͕༗ޮ
  52. Caution of ALB w/ WebSocket ▸ ༧ظͤ͵࠶઀ଓʹඋ͑Δ ▸ ALB ಺෦ϊʔυ͕

    Scale up / out ͢ΔλΠϛϯάͰҰ੪੾அͱ࠶઀ଓ͕૸Δ ▸ onConnect, onDisconnect ͷίʔϧόοΫॲཧ͸ྲྀྔ੍ޚ͓ͯ͘͠ͱྑ͍ ▸ Stickness ༗ޮԽ ( Socket.IO ͷ৔߹) ▸ Handshake ॲཧ ʙ Upgrade ·Ͱͷ xhr-polling ௨৴࣌ʹඞཁ ▸ client ʹΑͬͯ͸ Upgrade ࣌ʹ Cookie ͕౉Βͣ Stickness ͕ޮ͔ͳ͍ࣄ͕͋Δ ▸ socket.io-client-swift, socket.io-client-java Ͱ֬ೝ ▸ جຊ Stickness Λ༗ޮԽ͠ɺϥΠϒϥϦʹԠͯ͡ forceWebSocket ͯ͠ճආ͢Δ
  53. Requests to ALB ▸ Sticky Session ͷ Custom Cookie ࢦఆ

    ▸ CLB Ͱ͸Մೳ ▸ ALB ಺෦ͷεέʔϦϯάͷಈ࡞ΛγϡϛϨʔγϣϯ͍ͨ͠ ▸ ಺෦ϊʔυͷ Scale up / out / in ͕ൃੜͨ͠৔߹ͷɺΞϓϦέʔγϣϯ૚ʹ༩͑ΔӨڹ֬ೝ ▸ Leastconn Balancing Rule ▸ ࠷΋઀ଓ਺ͷগͳ͍όοΫΤϯυʹ༏ઌతʹ Balancing ͍ͨ͠ ▸ ಛʹ WebSocket ͷΑ͏ͳৗ࣌઀ଓܕ௨৴ͷෛՙΛۉ౳෼ࢄ͍ͨ͠
  54. RUNNING LEAN ελʔτΞοϓʹ͓͚Δ3ͭͷεςʔδ ՝୊ / ղܾ ϑΟοτ ੡඼ / ࢢ৔

    ϑΟοτ ֦େ ूதɿݕূʹΑΔֶश ࣮ݧɿϐϘοτ ूதɿ੒௕ ࣮ݧɿ࠷దԽ
  55. RUNNING LEAN ֶशʹඞཁͳ ࠷΋ඞཁͳ͜ͱΛ΍Δ ՝୊ / ղܾ ϑΟοτ ੡඼ /

    ࢢ৔ ϑΟοτ ֦େ ूதɿݕূʹΑΔֶश ࣮ݧɿϐϘοτ ूதɿ੒௕ ࣮ݧɿ࠷దԽ ▸ ήʔϜϓϩϞʔγϣϯͷ໰୊ͱޮՌ޲্ͱ͍͏໋୊ ▸ ϓϨΠಈըڞ༗ͱ͍͏ݕূ ▸ εϚϗಛԽ / SaaS ׆༻ / SDK ूத
  56. RUNNING LEAN ֶशʹඞཁͳ ࠷΋ඞཁͳ͜ͱΛ΍Δ ՝୊ / ղܾ ϑΟοτ ੡඼ /

    ࢢ৔ ϑΟοτ ֦େ ूதɿݕূʹΑΔֶश ࣮ݧɿϐϘοτ ूதɿ੒௕ ࣮ݧɿ࠷దԽ ▸ LIVE ഑৴ʹϐϘοτ ▸ SaaS ׆༻, 2 week Chat࣮૷, UI/UXूத
  57. RUNNING LEAN Grow larger, Small Start ՝୊ / ղܾ ϑΟοτ

    ੡඼ / ࢢ৔ ϑΟοτ ֦େ ूதɿݕূʹΑΔֶश ࣮ݧɿϐϘοτ ूதɿ੒௕ ࣮ݧɿ࠷దԽ ▸ Ϣʔβʔٸ૿ ▸ LIVE & CHAT ج൫ͷ࠷దԽ
  58. Why rebuild 4 times? “The Perfect is often the enemy

    of the good” Ϗδωε໨ඪΛୡ੒͢ΔͨΊͷ ޮ཰తͳಓےΛඳ͘͜ͱ