音楽の未来 〜スマートスピーカーとAWAがオトモダチになるまで〜 / Smartspeaker_AWA

2016ba6b977a2e6691811fa66d5f4336?s=47 CyberAgent
February 22, 2019

音楽の未来 〜スマートスピーカーとAWAがオトモダチになるまで〜 / Smartspeaker_AWA

サイバーエージェントの技術者(エンジニア・クリエイター)向けカンファレンス『CA BASE CAMP 2019』

音楽の未来 〜スマートスピーカーとAWAがオトモダチになるまで〜
北原 有貴

2016ba6b977a2e6691811fa66d5f4336?s=128

CyberAgent

February 22, 2019
Tweet

Transcript

  1. AWAͱεϚʔτεϐʔΧʔ͕ ΦτϞμνʹͳΔ·Ͱ AWAגࣜձࣾɹ๺ݪ ༗و

  2. ࣗݾ঺հ ๺ݪ༗و ,JUBIBSB:VLJ ʙ 1JHH&OHJOFFS $BTJOP$BGF8PSME  ʙ "8"&OHJOFFS

  3.  ΦτϞμνಉ࢜Α͘஌Γ߹͓͏  ͳͥΦτϞμνʹͳΓ͍ͨͷ͔ʁ  "8"º(PPHMF)PNF͕ΦτϞμνʹͳΔ·Ͱ  ๻ͨͪʹى͖༷ͨʑͳ໰୊  ൓ল఺ͱ՝୊

  4. ΦτϞμνಉ࢜Α͘஌Γ߹͓͏ ݱࡏͷΦτϞμν౓ɿ0 %

  5. ΤΠϕοΫεͱCyberAgentͷδϣΠϯτϕϯνϟʔ͕ੜΜͩ ࠃ಺ॳͷԻָετϦʔϛϯάαʔϏε × !5 AWAͷ͜ͱΛ஌Ζ͏

  6. AWAͷ͜ͱΛ஌Ζ͏ ೔ຊ൛Google PlayͷʮBest of 2017ʯϕετΞϓϦେ৆ड৆ !6

  7. AWAͷ͜ͱΛ஌Ζ͏ 2018೥͸େ෺ΞʔςΟετ͕ଓʑͱࢀՃ w .S$IJMESFO w ௣໊ྛޝ w ίϒΫϩ w দ೚୩༝࣮

    w ߴڮ༏ w FUDʜ !7 ೥΋CBDLOVNCFSΛ
 ൽ੾Γʹʜʂ
  8. AWAͷ͜ͱΛ஌Ζ͏ ·͢·͢ݸੑ͋;ΕΔαʔϏεʹਐԽ 2019೥1݄25೔ʹॳͷϝδϟʔόʔδϣϯΞοϓ !8

  9. εϚʔτεϐʔΧʔΛ஌Ζ͏ ର࿩ܕͷԻ੠ૢ࡞ʹରԠͨ͠AIΞγελϯτΛར༻Ͱ͖ΔεϐʔΧʔ AIεϐʔΧʔͱ΋ݺ͹ΕΔ !9 Google Home Amazon Echo LINE Clova

    WAVE Apple HomePod
  10. AWA͸ೋେΞγελϯτͱΦτϞμνʹ 2018೥3݄ Amazon EchoʹରԠ 2018೥12݄ Google HomeʹରԠ !10

  11. ͳͥΦτϞμνʹͳΓ͍ͨͷ͔ʁ ݱࡏͷΦτϞμν౓ɿ20 %

  12. ͳͥΦτϞμνʹͳΓ͍ͨͷ͔ʁ 1.εϚʔτεϐʔΧʔࢢ৔ͷՄೳੑ 2.ԻָαʔϏεͱͷ૬ੑͷྑ͞ !12

  13. 1.εϚʔτεϐʔΧʔࢢ৔ͷՄೳੑ

  14. 1.εϚʔτεϐʔΧʔࢢ৔ͷՄೳੑ !14 3rdύʔςΟ͔ΒAIΞγελϯτ౥ࡌεϐʔΧʔ͕ଓʑొ৔ LF-S50G WC / SONY Google Assistant Amazon

    Alexa VCGX30B / ONKYO ALLUE / Harman Kardon HOME SPEAKER 500 / BOSE LS mini / LiveSmart Sonos One / Sonos ྆ํ౥ࡌ ※ରԠ༧ఆ
  15. 1.εϚʔτεϐʔΧʔࢢ৔ͷՄೳੑ • ถࠃͰτϤλ/LexusͷҰ෦ंछʹAlexa౥ࡌ • Alexa Auto SDK Λൃද • 12݄

    Fire TV Stick͕AlexaରԠ !15 2018೥ Alexaͷंࡌ౥ࡌɾεϚʔτTV౥ࡌ͕Ճ଎ εϐʔΧʔͷීٴʹ͔͔ΘΒͣ
 AIΞγελϯτʹରԠ͢Ε͹
 Մೳੑ͕޿͕Δ
  16. 2.ԻָαʔϏεͱͷ૬ੑͷྑ͞

  17. 2.ԻָαʔϏεͱͷ૬ੑͷྑ͞ !17 εϚʔτεϐʔΧʔอ༗ऀ͸༗ྉϓϥϯʹੵۃత Amazon Music × Echo΍ LINE Music ×

    ClovaͷΑ͏ʹɺ ҆Ձͳϓϥϯ΍௕ظͷແྉظؒͱͷ ηοτൢച΋ଟ͘ɺॳΊͯαϒεΫ ϦϓγϣϯΛମݧ͢ΔϢʔβ΋ଟ͍ Իָ഑৴αϒεΫͷʮεϚʔτεϐʔΧʔʯ࢖༻ͷ࣮ଶ ΑΓҾ༻ https://amp.review/2018/03/30/smartspeaker/
  18. 2.ԻָαʔϏεͱͷ૬ੑͷྑ͞ !18 • ೔ຊͰ͸radikoΞϓϦ/εΩϧ͕ਓؾͳ ͜ͱ΋ཪ෇͚ΒΕΔ • ઒ͷͤͤΒ͗ͳͲ؀ڥԻΞϓϦ΋ਓؾ Ոࣄ΍εϚϗͳͲଞͷ࡞ۀΛ͠ͳ͕Βͷར༻γʔϯ͕ଟ͍ →ͳ͕Β࡞ۀͱԻָͷ૬ੑ͸ྑ͍

  19. AWA × Google Home ͕ ΦτϞμνʹͳΔ·Ͱ ݱࡏͷΦτϞμν౓ɿ30 %

  20. Google HomeରԠͷԻָϓϩόΠμ ౰࣌ɺରԠαʔϏε͸3ͭͷΈ ※2019/3ݱࡏ Youtube Music ͕௥Ճ !20 AWA͸2017೥6݄͝ΖΑΓ։ൃ։࢝

  21. ࠷΋࢖͍ͨ͘ͳΔԻָϓϩόΠμΛ໨ࢦͯ͠ !21 • ແྉΞΧ΢ϯτͰ΋࢖͑Δ • ࣭ͷྑ͍ϓϨΠϦετ͕બग़͞ΕΔΑ͏ʹ • ΦϯσϚϯυ࠶ੜ͕Ͱ͖Δ • ࣗ෼͕࡞੒ͨ͠ϓϨΠϦετ͕࠶ੜͰ͖Δ

    • ΞϓϦͰ͓ؾʹೖΓͨ͠ۂ͕࠶ੜͰ͖Δ • ύʔιφϥΠζ͞ΕͨDiscovery͕࠶ੜͰ͖Δ ඞਢػೳϓϥεΞϧϑΝΛ࣮ݱͯ͠AWA඼࣭Λ໨ࢦ͢
  22. ۩ମతʹԿΛ͢Ε͹͍͍ͷ͔ !22 (PPHMF"TTJTUBOU͔Β "8"ͷΞϓϦέʔγϣϯΛհͯ͠ ָۂͳͲͷίϯςϯπΛ࠶ੜͰ͖ΔΑ͏ʹ͢Δ

  23. Google Home / Google Backendͷ࢓ࣄ !23  ϢʔβͷϘΠεΛ#BDLFOE΁
 ૹ৴ 

    ϘΠεΫΤϦΛࣗવݴޠॲཧͯ͠
 ݕࡧΫΤϦʹม׵  Ϣʔβઃఆ΍ΧλϩάΛݕࡧ  ্Ґ݁ՌΛूܭ  ݁ՌΛݩʹىಈαʔϏεΛબ୒  BDDFTTUPLFOͱEFFQMJOLΛ
 Ϩγʔόʔ )PNF ʹૹ৴ Google Home Google Backend  554ͰϢʔβʹϑΟʔυόοΫ  "8"ϨγʔόʔىಈɾಡΈࠐΈ
  24. Google Home։ൃʹඞཁͳAWAͷػೳ !24 0"VUI 3FDFJWFS %BUB'FFET &YUFSOBM"1*

  25. 1. OAuth

  26. 1. OAuth !26 (PPHMF)PNFʹ"8"ΞΧ΢ϯτͷݖݶΛҠৡ͢ΔͨΊͷೝূػߏ Launch WebView Redirect

  27. None
  28. 2. Receiver

  29. 2. Receiver !29 (PPHMF)PNF͕࠶ੜཁٻɾΩϡʔૢ࡞͢ΔͨΊͷϓϩάϥϜ • Ξοϓϩʔυ͞Εͨ։ൃίʔυΛGoogle Home͕μ΢ϯϩʔυͯ͠ར༻ • OAuthͰϢʔβʔ͕ঝೝ͞ΕΔͱɺGoogle Home͸ͦΕҎ߱ͷશͯͷ࠶ੜ


    ϦΫΤετʹOAuthΞΫηετʔΫϯΛૹ৴ • Ϩγʔόʔ͸ͦͷτʔΫϯͰAWA API͔Βύʔιφϧ৘ใΛऔಘͨ͠Γɺ
 ࠶ੜΩϡʔΛߏஙͨ͠ΓɺϝσΟΞίϯτϩʔϧΛߦ͏
  30. None
  31. AWAͰ͸ϦϦʔεࡁͷGoogle Castίʔυͱڞ༻ !31 1. JavaScriptͰهड़͍ͯͨ͠ίʔυΛTypeScript + React / Redux ʹ

    ͜Ε·ͰɿεϚϗ͔ΒͷϦΫΤετͰ࠶ੜ Sender:εϚϗ -> Receiver:Google Cast ϦϦʔεޙɿGoogle Assistant͔Β΋࠶ੜͰ͖ΔΑ͏ʹ Sender:Google Assistant(Home) -> Receiver:Google Home ͭ·Γ"TTJTUBOU͕౥ࡌ͞Ε͍ͯΕ͹4FOEFSʹͳΕΔ 2. Home͸Sender, Receiver྆ํඋ͓͑ͯΓ1୆Ͱ׬݁Ͱ͖ΔΑ͏ʹ
  32. 3. Data Feeds

  33. 3. Data Feeds !33 (PPHMF$MPVEͷݕࡧͱ"8"ͷίϯςϯπΛϚονͤ͞Δ • ͦͷͨΊʹGoogleʹAWAͷίϯςϯπͷϝλ৘ใΛఏڙ͢Δ • Google͸ͦΕΛSearchΤϯδϯʹऔΓࠐΜͩΓAssistantͷֶशʹ࢖͏
 →

    Feed Ingestion ͱ͍͏ • Feed format͸JSON-LD • Feedʹ͸࠶ੜՄೳͳdeeplink(URL)͕ೖΓɺGoogle Cloud͸ͦͷdeeplink Λloadؔ਺ͰAWAͷReceiverʹ౉͢
  34. { "@context": "http://schema.org", "@type": "DataFeed", "dateModified": "2019-02-22T15:11:32+09:00", "dataFeedElement": [ {

    "@context": "http://schema.googleapis.com/", "@type": "MusicRecording", "@id": "https://s.awa.fm/track/trackId1", "name": "trackName1", "url": "https://s.awa.fm/track/trackId1", "popularityScore": [ { "@type": "PopularityScoreSpecification", "value": 1, Feed Spec for Media Actions ͋Δtrackͷྫ @id: ҰҙͰ͋Ε͹ԿͰ΋Α͍
  35. “byArtist": { "@type": "MusicGroup", "@id": "https://s.awa.fm/artist/artistId1", "name": "artistName1" }, "inAlbum":

    { "@type": "MusicAlbum", "@id": "https://s.awa.fm/album/albumId1", "name": "albumName1" }, "duration": "PT5m11s", "publisher": "גࣜձࣾA", "thumbnailUrl": "https://pimg.awa.io/v2/jacket/albumId1.h600.w600.jpg", "potentialAction": [ { Feed Spec for Media Actions ͋Δtrackͷྫ
  36. "potentialAction": [ { "@type": "ListenAction", "target": [ { "@type": "EntryPoint",

    "urlTemplate": "https://s.awa.fm/track/trackId1? action=play&play_type=google_assistant", "actionPlatform": [ "http://schema.org/DesktopWebPlatform", "http://schema.org/MobileWebPlatform", "http://schema.org/IOSPlatform", "http://schema.org/AndroidPlatform", "http://schema.googleapis.com/GoogleAudioCast", "http://schema.googleapis.com/GoogleVideoCast" ] Feed Spec for Media Actions ͋Δtrackͷྫ actionPlatform: ࠶ੜΛڐՄ͢ΔPlatform urlTemplate: Ϩγʔόʔ͕ίϯςϯπΛղऍ ͢ΔͨΊͷURL
  37. "expectsAcceptanceOf": { "@type": "Offer", "eligibleRegion": [ { "@type": "Country", "name":

    "JP" } ], "category": "subscription", } } ] }, … ] Feed Spec for Media Actions ͋Δtrackͷྫ ͜ͷΦϒδΣΫτͷ͔ͨ·Γ͕1ϑΝΠϧ50MB΄Ͳʹऩ·Δ·Ͱଓ͍͍ͯ͘
  38. Feed Spec for Media Actions !38 ͜ΕΛ1೔1ճશίϯςϯπੜ੒ͯ͠Googleʹఏڙ • τϥοΫ2017೥౰࣌໿4,000ສ →

    ݱࡏ͸5,000ສҎ্ • ΞϧόϜ໿500ສ • ΞʔςΟετ໿350ສ • ࢼ͠ʹੜ੒ͨ͠1ϑΝΠϧͷॲཧ͔࣌ؒΒɺ୯७ܭࢉͨ͠ΒτϥοΫ͚ͩͰ120࣌ ؒҎ্͔͔Δ →ੜ੒ϓϩάϥϜͷޮ཰Խ͕ඞਢཁ݅
  39. GolangʹΑΔϑΟʔυੜ੒ϓϩάϥϜ !39 ϝΠϯϓϩηε͸Լه1,2ͷgoroutineΛੜ੒ͯ͠ॲཧऴྃΛ଴ͪଓ͚Δ
 1. DBݕࡧͯ͠2ʹσʔλΛ౉͢ɺΛ܁Γฦ͢goroutine
 2. ड͚औͬͨσʔλΛݩʹϑΟʔυΛੜ੒ͯ͠S3ʹΞοϓϩʔυ͢Δ goroutine(ϫʔΧʔͱݺͿ) ฒߦॲཧͰޮ཰Խ

  40. ϫʔΧʔʹ͍ͭͯ(1/2) !40 ϫʔΧʔ͸InterfaceͰఆٛͯ͠ɺtrack / album / artist / playlistͷ֤struct͕
 ͦΕΒΛ࣮૷͍ͯ͘͜͠ͱͰɺجຊతͳੜ੒ϧʔτΛڞ௨Խͤ͞Δ

    Worker interface { SetEntity(entity interface{}) IsTarget() bool FetchFavorite() (fav int, err error) SetRelatedContents() (contents map[string]string, err error) EncryptIDs() map[string]string EscapeNames(contents map[string]string) map[string]string CreateElement(fav int, encIDs, escapeNames map[string]string) (bytes.Buffer, error) }
  41. ϫʔΧʔʹ͍ͭͯ(2/2) !41 ϫʔΧʔͷॲཧͰ΋I/OΠϕϯτ΍ฒߦॲཧ͕Մೳͳ෦෼͸ੵۃతʹฒྻԽ͠ɺ sync.WaitGroupͰॲཧΛ଴ͪ߹ΘͤΔ … wg := &sync.WaitGroup{} wg.Add(3) var

    params feedParams go fetchFavorite(w, wg, &params) go fetchRelatedContents(w, wg, &params) go encryptIDs(w, wg, &params) wg.Wait() … func fetchFavorite(w Worker, wg *sync.WaitGroup, params *feedParams) { defer wg.Done() fav, err := w.FetchFavorite() params.fav = fav if err != nil { params.err = multierror.Append(params.err, errors.Wrap(err, "failed to FetchFavorite")) } }
  42. νϡʔχϯά͠΍͍͢Α͏ʹ !42 ࠶Ϗϧυ͢Δ͜ͱͳ͘ઃఆ஋Λ͍͡ΕΔΑ͏؀ڥม਺Λଟ༻ type configuration struct { MongoHost string `envconfig:"MONGO_HOST"

    default:"localhost:27017"` MongoDatabase string `envconfig:"MONGO_DATABASE" default:"test"` MongoSocketTimeout int `envconfig:"MONGO_SOCKET_TIMEOUT" default:"15"` RedisAddr string `envconfig:"REDIS_ADDR" default:"localhost:6379"` RedisDB int `envconfig:"REDIS_DB" default:"0"` Mode string `envconfig:"MODE" default:"test"` Type string `envconfig:"TYPE"` WorkerNum int `envconfig:"WORKER_NUM" default:"10"` Timeout int `envconfig:"TIMEOUT" default:"300"` FindLimit int `envconfig:"FIND_LIMIT" default:"500000"` FeedLimit int `envconfig:"FEED_LIMIT" default:"50000"` } • WorkerNum: ϫʔΧʔ਺ • FindLimit: DB͔ΒҰ౓ʹ औಘ͢Δ਺ • FeedLimit: 1ϑΝΠϧʹ
 ੜ੒͢Δίϯςϯπ਺ ݱࡏ͸τϥοΫ5,000ສʹରͯ͠35ʙ40෼ఔͰऴΘΔΑ͏ʹ
  43. 4. External API

  44. 4. External API !44 ύʔτφʔʹ"8"ϢʔβͷҰ෦σʔλΛఏڙ͢Δ • AWA͸ΞΫηετʔΫϯඞਢͷεϚʔτεϐʔΧʔ޲͚APIΛύʔτφʔʹఏڙ • ύʔτφʔ͸ͦΕΛར༻ͯ͠ఆظతʹϢʔβͷεςʔλεɾϓϨΠϦετ৘ใΛऔಘɾར༻ 1.

    HomeΞϓϦͷΞΧ΢ϯτ࿈ܞޙͷ εςʔλε৘ใ 2. ϢʔβͷϚΠϓϨΠϦετ৘ใ Voice Searchͷީิʹ
  45. AWA SideɿϑΟʔυੜ੒ɾAPIશମߏ੒ਤ !45 Route 53 API Gateway S3 Bucket AWS

    Cloud VPC ECR AWS Batch Lambda event (time-base) ECS CloudWatch AWA API CloudFront for feeds creation Requests from Partner ໊લղܾ Internet όονίʔυ S3 Bucket Lambda functionίʔυ GitHub EC2 (Build Server) git push git push External API
  46. 4. External API 1. Route 53Ͱఆٛͨ͠CNAMEϨίʔυΛCloudFrontͷCNAMEsʹηοτ 2. CloudFrontͷOrigin NameʹAPI Gatewayͷ”Endpoint/Stage”Λࢦఆ

    3. CloudFront͸SSLऴ୺ͱɺ΋͠΋ͷͨΊʹΩϟογϡ͢Δ໨తͰ४උ 4. Lambda function͸GolangͰ࣮૷͠ɺϏϧυόΠφϦΛΞοϓϩʔυ 5. API GatewayͱLambdaͦΕͧΕ͔ΒARNΛඥ෇͚Δ Route 53 API Gateway Lambda ECS AWA API CloudFront Requests from Partner ໊લղܾ Internet Lambda !46 upload
  47. API Gatewayͷ໾ׂ !47 • Lambdaؔ਺ͷEndpointͱͯ͠
 ϦΫΤετΛϓϩΩγ͢Δ͚ͩ • APIΩʔೝূͰଞ͔ΒͷΞΫηεΛ ੍ݶ͢Δଞɺ࢖༻ྔϓϥϯػೳͰϦ ΫΤετ੍ݶΛ͔͚Δ͜ͱ΋

    • ແྉར༻࿮΋͋Δ͠LBΑΓ҆Ձͳ ͷͰϦΫΤετ਺࣍ୈͰ͸Φεεϝ
  48. Lambda function !48 • GolangͰͳͯ͘΋͍͍ɻ౰࣌ਖ਼ࣜʹରԠ͞Εͨ͹͔ΓͩͬͨͷͰ࢖ͬͯΈ ͔ͨͬͨͷͱɺόΠφϦͰύϑΥʔϚϯε͕Αͦ͞͏ͱ͍͏ҹ৅͔Β package main import "github.com/aws/aws-lambda-go/lambda"

    func handler(ctx context.Context, proxyReq events.APIGatewayProxyRequest) (Response, error) { … } func main() { lambda.Start(handler) }
  49. ๻ͨͪʹى͖༷ͨʑͳ໰୊ ݱࡏͷΦτϞμν౓ɿ80 %

  50. ๻ͨͪʹى͖༷ͨʑͳ໰୊ !50 όοναʔόͷϦιʔε໰୊ ਓؾͷۂ͕࠶ੜ͞Εͳ͍͜ͱ͕͋Δ ϦΫΤετΛࢭΊΔͳʂ

  51. 1. όοναʔόͷϦιʔε໰୊

  52. 1. όοναʔόͷϦιʔε໰୊ !52 ϑΟʔυੜ੒ॲཧ͸ฒྻ࣮ߦ਺͕ଟ͍΄ͲϦιʔεΛ ࢖͍ɺଞͷδϣϒʹӨڹΛٴ΅͢ • ॏཁͳδϣϒ͕OSʹΑͬͯkill͞ΕΔ͜ͱ͕͋ͬͨ • ಛʹτϥοΫ͸௕࣌ؒɺ͔ͳΓͷϫʔΧʔ਺Λىಈͤ͞Δ

  53. AWS BatchͰಠཱͨ͠؀ڥͰ࣮ߦ͢ΔΑ͏ʹ S3 Bucket VPC ECR AWS Batch event (time-base)

    CloudWatch όονίʔυ S3 Bucket EC2 (Build Server) git push • ϑϧϚωʔδυܕͷόονίϯϐϡʔςΟϯάδϣϒͷ࣮ߦ؀ڥ ECS EC2 Cluster Docker Image auto scaling Feeds git pull pull image download shell & binary build binary Job Definition
  54. AWS BatchͰಠཱͨ͠؀ڥͰ࣮ߦ͢ΔΑ͏ʹ S3 Bucket VPC ECR AWS Batch event (time-base)

    CloudWatch όονίʔυ S3 Bucket EC2 (Build Server) git push ECS EC2 Cluster Docker Image auto scaling Feeds git pull pull image download shell & binary build binary ᶃ CPU Unit΍ϩʔϧ౳Λఆٛͨ͠ίϯϐϡʔςΟϯά؀ڥ(EC2)Λ࡞੒ ᶄ ্ه؀ڥΛར༻͢ΔδϣϒΛఆٛɻϝϞϦ΍؀ڥม਺͸͜͜Ͱࢦఆ͢Δɻ Job Definition ᶃ ᶄ !54
  55. AWS BatchͰಠཱͨ͠؀ڥͰ࣮ߦ͢ΔΑ͏ʹ ᶅ CloudWatchΠϕϯτΛcronͰεέδϡʔϦϯά͠ɺλʔήοτʹ
 AWS BatchδϣϒΛࢦఆ S3 Bucket VPC ECR

    όονίʔυ S3 Bucket EC2 (Build Server) git push EC2 Cluster Docker Image auto scaling Feeds git pull pull image download shell & binary build binary Job Definition AWS Batch event (time-base) CloudWatch ᶅ !55 ECS
  56. AWS BatchͰಠཱͨ͠؀ڥͰ࣮ߦ͢ΔΑ͏ʹ ᶆ ॲཧίʔυΛϏϧυͨ͠GoόΠφϦΛS3 Bucketʹ഑ஔ ᶇ ্هόΠφϦΛS3͔Βऔಘ࣮ͯ͠ߦ͢ΔDockerΠϝʔδΛECRʹ४උ
 →ࣗಈతʹߏங͞ΕΔECSΫϥελɾαʔϏε(EC2λΠϓ)্Ͱ࣮ߦ͞ΕΔͨΊ S3 Bucket

    VPC AWS Batch event (time-base) CloudWatch ECS EC2 Cluster auto scaling Feeds pull image download shell & binary Job Definition !56 ECR όονίʔυ S3 Bucket EC2 (Build Server) git push git pull build binary Docker Image ᶆ ᶇ
  57. AWS BatchͰಠཱͨ͠؀ڥͰ࣮ߦ͢ΔΑ͏ʹ !57 δϣϒ͕αϒϛοτ͞ΕͨΒΩϡʔʹཷ·ΓEC2 Cluster͕ߏங͞ΕΔɻ Cluster্ͰECSλεΫ͕γΣϧΛμ΢ϯϩʔυɾΩοΫ͠ɺGoόΠφϦ Λμ΢ϯϩʔυɾ࣮ߦͯ͠ϑΟʔυ࡞੒ɾS3ʹΞοϓϩʔυ·Ͱߦ͏ɻ S3 Bucket VPC

    ECR AWS Batch event (time-base) CloudWatch όονίʔυ S3 Bucket EC2 (Build Server) git push ECS EC2 Cluster Docker Image auto scaling Submit Job Add a queue to Job Feeds git pull pull image download shell & binary build binary Job Definition
  58. AWS BatchͰ՝୊ʹײͨ͡఺ w ࠷ॳͷ؀ڥ४උ͕΍΍खؒ w ීஈ࢖͍͸+FOLJOTͳͲͷ$*$%πʔϧͰ0, w ࠓճͷΑ͏ͳ՝୊Λղܾ͚ͨ͠Ε͹ w ։࢝࣌ؒʹݫີͳόονॲཧʹ͸ෆ޲͖

    w &$ͳͲͷϦιʔε४උ͕ඞཁͳͱ͖͸։͕࢝஗͘ͳΔ w δϣϒͷ࣮ߦॱংΛ੍ޚ͢Δʹ͸4UFQ'VODUJPOTͳͲͷ ػೳΛซ༻͢Δඞཁ͋Γ ݱࡏ ͱ͸͍͑ৗ࣌Քಇ͍ͯ͠ΔόονΠϯελϯεͷϦιʔεʹׯব ͠ͳ͍͠ɺ͏·͘࢖͑͹ίετతʹ΋͓͢͢Ί !58
  59. 2. ਓؾͷۂ͕࠶ੜ͞Εͳ͍͜ͱ͕͋Δ

  60. 2. ਓؾͷۂ͕࠶ੜ͞Εͳ͍͜ͱ͕͋Δ !60 • ಛʹɺ୹͍ۂ໊ͩͱ༷ʑͳΞʔςΟετͷۂͱ͔ͿΔ • Googleݕࡧͷਫ਼౓ʹҕͶ͍ͯͨ෦෼΋͋ͬͨ • ࠶ੜ͍ͨ͠ۂ͕࠶ੜ͞Εͳ͍ମݧ͸ۃྗආ͚͍ͨ AWAଆͰԿ͔Ͱ͖Δ͜ͱ͕ͳ͍͔

    ඞਢػೳ͸։ൃ׬ྃ͠ςετΛॏͶ͍͕ͯͨɺதʑਫ਼౓͕ ্͕ΓͮΒ͔ͬͨ
  61. Popularity ScoreΛಋೖ !61 • ࠶ੜ΍͓ؾʹೖΓ࣮੷͕͋ΔίϯςϯπͷείΞΛܭࢉͯ͠HIT͠΍͘͢ • શείΞ͸1೔1ճϑΟʔυ࡞੒લʹߋ৽ 127.0.0.1:6379> scan 0

    1) “soon:track" 2) "topic:track" 3) "general:track" 4) "topic:album" 5) "general:album" 6) "topic:artist" 7) “general:artist" soon:[type] -> ϦϦʔεલͷίϯςϯπ topic:[type] -> ϦϦʔε͔ΒҰఆظؒͷίϯςϯπ general:[type] -> ্هҎ֎ͷ࠶ੜ࣮੷͕͋Δίϯςϯπ
  62. ਓؾͷۂ͕HIT͠΍͘͢ͳͬͨ !62 Redisͷ֤ΫϥελϝϯόʔΛಡΈࠐΈɺ࠶ੜ࣮੷ͷ͋Δ ίϯςϯπΛλʔήοτʹϑΟʔυੜ੒ 127.0.0.1:6379> zrevrange general:track 0 2 withscores

    1) "trackId001" 2) “13935530" 3) "trackId003" 4) "12261936" 5) "trackId002" 6) "9867839" τϥοΫ࠶ੜ࣮੷Ϋϥελͷ্Ґ3ۂΛදࣔ ࠶ੜɾ͓ؾʹೖΓɾϓϨΠϦετ࠾༻਺ΛՃຯͨ͠είΞ
  63. 3. ϦΫΤετΛࢭΊΔͳʂ

  64. !64 • 2017೥10݄த०͔Β։࢝ • Webϖʔδ͕ଘࡏ͢Δ͔Ͳ͏͔ͷνΣοΫͱɺGoogle Assistantͷ ݕࡧ݁Ռͷਫ਼౓Λ্͛ΔֶशͷͨΊ Google͕ϑΟʔυ಺WebϖʔδͷΫϩʔϦϯάΛ։࢝ 3. ϦΫΤετΛࢭΊΔͳʂ

  65. ಥવAWAͷγΣΞϖʔδ΁ͷϦΫΤετ͕૿Ճ !65 ϐʔΫଳ 1,000 req / min ͔Βಥൃతʹ૿͑ͨ →ίϯςφͷϔϧενΣοΫ͕ଓʑͱunhealthyʹ 10,000ͷϥΠϯ

    ݱࡏͷΦτϞμν౓ɿ60 %
  66. !66 • τϥοΫ / ΞϧόϜ / ΞʔςΟετ / ϓϨΠϦετ /

    ϢʔβผͷWebϖʔδ • ֤ίϯςϯπΛࢼௌ࠶ੜͰ͖Δ • AWAͷೝ஌ɾΞϓϦ΁ͷτϥϑΟοΫͱͯ͠ॏཁ AWAͷγΣΞϖʔδͱ͸ʁ
  67. UA͸95%͕ΫϩʔϥͰɺͦͷ92%͕ΞϝϦΧͩͬͨ͆ !67 औΓٸ͗unhealthyͷίϯςφΛམͱͯ͠ૣ͘ೖΕସΘΔΑ͏ʹ
 → ͢΂ͯhealthyʹ໭ͬͨ

  68. !68 • ࠷େϗετɿ8 → 20 • ΠϯελϯελΠϓɿt2.small → c4.xlarge •

    CPU༻ͷCloudWatchΞϥʔϜɿaverage → maximumʹɻ͖͍͠஋΋60 → 40ʹͯ͠ɺݕ஌࣌ʹ2ίϯςφͣͭ૿͑ΔΑ͏ʹ • ΠϝʔδαΠζ΋ݮΒͯ͠ૉૣ͘ίϯςφىಈͰ͖ΔΑ͏ʹ ௚ۙEC2→ECSʹߏ੒มߋ͠ɺίϯςφϗετͷCPU Unit͕ ෛՙʹରͯ͠଍Γͣʹόʔετͨ͜͠ͱ͕ݪҼ →1୆ʹ4ίϯςφɺ࠷େಉ࣌ʹ80ίϯςφىಈ͢Δܭࢉ ରࡦɿΞϥʔϜɾΦʔτεέʔϧͷݟ௚͠
  69. ͜ΕͰ҆Β͔ʹ຾Ε…

  70. ·ͤΜͰͨ͠ʂ

  71. !71 ΋ͬͱ͍͚ΔͱࢥΘΕͨͷ͔ ̒ʙ̔ສΛ௒͑ΔΑ͏ʹ( ^)o(^ ) 80,000ͷϥΠϯ ΫϩʔϦϯά൒୺ͳ͍ͬͯʂʂ ݱࡏͷΦτϞμν౓ɿ30 %

  72. !72 ໐Γଓ͚ΔΞϥʔτ(શͯγΣΞϖʔδαʔό)

  73. !73 ໐Γଓ͚ΔΞϥʔτ(શͯγΣΞϖʔδαʔό)

  74. !74 ໐Γଓ͚ΔΞϥʔτ(શͯγΣΞϖʔδαʔό)

  75. !75 w 8"' 8FC"QQMJDBUJPO'JSFXBMM  w ࠷খઃఆͷ SFRNJOͰݕূ w ϒϩοΫ͞Εͣɻӈ͸શͯͷϦΫΤετ

    ͕ڐ༰͞Ε͍ͯΔάϥϑ AWS WAFͷϨʔτϕʔεϧʔϧͰ΋ࢭ·Βͳ͍ʂ Ϋϩʔϥ͔ΒͷϦΫΤετ͸Ұ෦IP͸ॏෳ͍ͯ͠Δ΋ͷͷɺ͔ͳΓ ͷ୆਺͔Β෼ࢄ͍ͯ͠Δ
  76. !76 ΠϯελϯελΠϓΛ্͛ͨʹ΋ؔΘΒͣ࠷େ·Ͱεέʔϧͯ͠͠·͍
 AWAଆ͚ͩͰରॲ͢Δʹ͸ίετ͕͔͔ͬͯ͠·͏ɻ →GoogleʹฏۉతʹϦΫΤετͯ͠΋Β͏Α͏ґཔ ͦͯ͠ղܾ΁ɾɾɾ ໿ 200 req / sec

    ΄Ͳʹམͪண͍ͨ͜ͱͰղܾɾɾʂ ݱࡏͷΦτϞμν౓ɿ80 %
  77. ͦͯ࣌͠͸ྲྀΕ…

  78. AWAͱGoogle Home͸ΦτϞμνʹ !78  EJTDPWFSZ Կ͔࠶ੜԻָΛ࠶ੜͷτϦΨʔ   ΫϦεϚεϓϨΠϦετ 

    64"  உͷ܄ষ  58*$&  %"16.1  26&&/  .S$IJMESFO  ͍͋ΈΐΜ ੢໺Χφ 2018/12/20ʙ27ͷ࠶ੜϥϯΩϯά ݱࡏͷΦτϞμν౓ɿ100 %
  79. ൓ল఺ͱ՝୊

  80. ൓ল఺ͱ՝୊(1/3) !80 • (Google) ๲େͳίϯςϯπσʔλͷIngestion • 2ʙ3ϲ݄͸͔͔Δ૝ఆ͕࣮ͩͬͨࡍ͸΋ͬͱ΋ͬͱ͔͔ͬͨ • (AWA) WebΫϩʔϦϯάલʹGoogleʹࣄલ֬ೝ͢΂͖ͩͬͨ

    • ΫϩʔϦϯάظؒɺαʔόʔίετ͕͔͞ΜͰ͠·ͬͨ ͓ޓ͍ະ஌ͷྖҬͷ։ൃͰεέδϡʔϧ͕ಡΈͮΒ͔ͬͨ
  81. ൓ল఺ͱ՝୊(2/3) !81 • (Google) ೔ຊޠͷԻ੠ೝࣝͷ೉͠͞ • γνϡΤʔγϣϯ࠶ੜʹ͓͍ͯɺ೿ੜχϡΞϯε͕ղऍ͞Εͳ͔ͬͨ • ྫ͑͹ “य़”ɺ”य़ͷۂ”ɺ”य़ʹௌ͖͍ͨۂ”

    ͳͲͷࡉ͔͍ҧ͍Ͱ΋શͯ
 όϦΤʔγϣϯͱͯ͠ϑΟʔυఏڙͨ͠ํ͕HIT͠΍͘͢ͳͬͨ • “AWA” ͸։ൃऴ൫·Ͱ “ΤʔɾμϒϦϡʔɾΤʔ” ͱൃԻ͞Ε͍ͯͨ • ݪҼ͸ΞϝϦΧͷϓϩϨεஂମ • ݱࡏ͸গ͠վળͯ͠ “Ѩ೾㽉” ͱൃ࿩͞ΕΔɾɾ(´ʀωʀʆ)
  82. ൓ল఺ͱ՝୊(3/3) !82 • (AWA) ࣗ੮Ͱͷ࣮ػςετ͕ͪΐͬͱஏ͔͍ͣ͠ • Ͱ΋ɺΦτϞμνͱͷձ࿩͸وॏͳ࣌ؒ ※Amazon Echoฤ΋ଘࡏ

  83. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ