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

20万超のIoTデバイス同時接続を支えるNature RemoのシステムとAWS / IoT ...

Songmu
February 10, 2021

20万超のIoTデバイス同時接続を支えるNature RemoのシステムとAWS / IoT AWS Loft Nature Remo 2021

Songmu

February 10, 2021
Tweet

More Decks by Songmu

Other Decks in Technology

Transcript

  1. 2 Me • দ໦ խ޾ (id:Songmu) • Nature גࣜձࣾ औక໾CTO

    • https://songmu.jp/riji • https://github.com/Songmu • ޷͖ͳݴޠ͸GoͱPerlͱதࠃޠ • 3 Times ISUCON Winner • ஶॻʹʮΈΜͳͷGoݴޠʯ౳ • झຯ͸OSS׆ಈͰ͢
  2. Home Automation to Virtual Power Plant 14 2019- Phase 1

    ホームオートメーション 2020- Phase 2 エネルギーマネージメント 2022 Phase 3 Virtual Power Plant
  3. Features • ͍ΘΏΔIoT੡඼ͷεϚʔτϦϞίϯ • εϚʔτϑΥϯ΍εϚʔτεϐʔΧʔ͔ΒՈిૢ࡞ • ΤΞίϯɾTVɾϥΠτ౳ • طଘͷ੺֎ઢϦϞίϯΛͦͷ··ஔ͖׵͑ΒΕΔ •

    ؆୯ʹ࢖͑ΔϦϞίϯֶश(ݕग़)ػೳ • ηϯγϯά΍ϢʔβʔͷҐஔ৘ใΛ΋ͱʹՈిૢ࡞ • Թ౓ɾ࣪౓ɺՈ͔Β཭Εͨ࣌ɺ͍ۙͮͨͱ͖ͳͲ
  4. Remarkable Points • ૉ๿ͳGo੡ͷWebΞϓϦέʔγϣϯ • Redis Pub/SubΛ༻͍ͨɺAPI - Streamؒͷ΍ΓͱΓ •

    Nature Remo͸ALBΛܦ༝ͯ͠streamαʔόʔʹ Websocket઀ଓ͍ͯ͠Δ • AlexaͷΧελϜεΩϧ͸AWS Lambdaܦ༝Λ࢖࣮ͬͯߦ ͞ΕΔ
  5. Simple Web Applications with Go • ී௨ͷWebΞϓϦέʔγϣϯ • ΋ͱ΋ͱherokuͰϗετ໊͍ͯͨ͠࢒΋ •

    ϑϨʔϜϫʔΫ • github.com/nbio/hitch • Gorilla web toolkitΛ෦෼తʹར༻ • MySQL/Redis • gorp/redigo • guregu/dynamo
  6. Utilize Redis Pub/Sub • Redis Pub/SubΛ׆༻͍ͯ͠Δ • API͔Β͸RedisʹPublish • Stream͸RedisΛSubscribe

    • ૬ޓ௨৴͠ͳ͍ૄ݁߹Λ࣮ݱ͍ͯ͠Δ • Streamଆ͸͋͘·ͰWebSocketͱRedis͔ΒͷSubscribeͰ ड͚෇໋͚ͨྩͷ࣮ߦ͔͓͜͠ͳΘͣঢ়ଶΛ࣋ͨͳ͍
  7. Amazon ElastiCache Redis • PubSub༻: ඇΫϥελRedis • ηϯαʔσʔλͷҰ࣌อଘ: ΫϥελϞʔυ •

    ࠷ۙ෼ׂ • Ϋϥελ༻͸Redis 6ޓ׵ͷM6gΛ౤ೖ • ૝ఆΑΓ΋શવCPUΛ࢖Θͣ • Graviton͍͢͝
  8. Log Monitoring • go.uber.go/zap Ͱඪ४ग़ྗͷJSONϩάΛCloudWatch Logs ʹૹ৴ • CloudWatch Logs

    Insights΋҆ఆ͖ͯͯ͠ศར • ͔͠͠೗ԿͤΜߴ͍💸 • Ұ෦ͷϩά͸GoΞϓϦ͔Β௚઀Amazon Kinesis Data FirehoseΛୟ͍ͯS3ૹ৴ • Amazon AthenaͰௐࠪ
  9. Further use AWS • AWS IoT • ແཧͯ͠࢖͏ඞཁ͸ͳ͍ͱߟ͍͑ͯΔ͕ɺબ୒ࢶΛ޿͛ ͯඞཁʹԠͯ͡࢖͍͍ͨ •

    ػցֶशܥػೳ • Ϣʔεέʔε • ࣨԹ΍շద౓ͷࣗಈௐ੔ • ిྗͷ࠷దԽ΍धڅௐ੔
  10. github.com/natureglobal/firequeue • Amazon Kinesis Data Firehose΁ͷૹ৴ࣦഊ࣌ͷϦτϥΠ • ΠϯϝϞϦΩϡʔͳͷͰشൃͷՄೳੑ͸͋Δ • ͦ͜͸ׂΓ੾Γ

    • Ұ෦ͷϩάΛGoͷΞϓϦ͔ΒKinesis Data Firehoseʹ௚઀ ౤͍͛ͯΔͨΊ • ϩάίϨΫλܦ༝Ͱ͸ͳ͍(ཱ͍ͯͯͳ͍) • ͦ͜ͷૹ৴ͷ࣮֬ੑΛ্͛ΔͨΊʹϥΠϒϥϦ࡞੒