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

Serverless で位置情報を活用する

Serverless で位置情報を活用する

2016/03/29
AWSで動かしているサービスの裏側を覗いてみる会@八王子
https://8creator.doorkeeper.jp/events/40931
にて発表した資料になります
#aws #jawsug #soracom

uchimanajet7

March 30, 2016
Tweet

More Decks by uchimanajet7

Other Decks in Technology

Transcript

  1. 2 ͝஫ҙ ‣ 2016೥03݄28೔ݱࡏͷ৘ใͰ͢ ‣ ࢿྉ಺ͷදݱ΍จݴ͸มߋ͞ΕΔՄೳੑ͕͋Γ ·͢ ‣ ݸਓͰͷൃද༻ͳͷͰࠓޙձ͔ࣾΒग़Δਖ਼ࣜ൛ ͱҟͳΔ৔߹͕͋Γ·͢

    ‣ ਖ਼ࣜ൛ͱͷࠩҟ͕͋ͬͨ৔߹ਖ਼ࣜ൛͕ج४ͱͳ Γ·͢ͷͰྃ͝ঝ͍ͩ͘͞ ‣ ͝ҙݟ΍࣭͝໰͕͋Γ·ͨ͠Β͓ؾܰʹ͓໰͍ ߹Θ͍ͤͩ͘͞
  2. 8 What is SkyBrain ? ‣ Ґஔ৘ใͷ׆༻Λ໨తͱͯ͠࡞੒தͷ IoT ޲͚αʔϏ ε

    ‣ ௨৴ϓϥοτϑΥʔϜ͸ SORACOM Air Λར༻ ‣ ػث͸εϚʔτϑΥϯΛར༻ͯ͠ϓϩτλΠϐϯάத ‣ Ϋϥ΢υ؀ڥ͸ AWS Λར༻͠ॊೈ͔ͭ҆ՁͰߏங ‣ S3ɺLambdaɺAPI Gateway ͱ͍ͬͨ AWS ͷϑϧϚ ωʔδυαʔϏεΛੵۃతʹར༻͠ Serverless ʹ ‣ ߏங࣌ؒͷ୹ॖͱߏஙޙͷӡ༻ෛ୲ܰݮΛߟ͑ͯϑϧ ϚωʔδυαʔϏεΛར༻
  3. 10 Why is SkyBrain ? ‣ IoT ޲͚ͱ͸ݴͬͯ΋ Things ͸͍࣋ͬͯͳ͍

    ‣ ྻं΍όεͳͲͷ༌ૹʹؔ͢Δ৘ใ͸ଟগ͍࣋ͬͯΔ ‣ Trainʢྻंʣ΍ Transportʢ༌ૹʣͳΒ͍ۙྖҬ ‣ ͜ͷྖҬͰ͋Ε͹͜Ε·Ͱͷ஌ݟ΍ࢿ࢈Λੜ͔ͨ͠׆༻͕Ͱ͖ ͦ͏ ‣ खܰʹ࢖͑ͯखܰʹ΍ΊΒΕΔΫϥ΢υͷߴ͍ΞδϦςΟ΍ͦ ͷଞͷྑ͞Λͦͷ··αʔϏεʹ׆͔͍ͨ͠ ‣ ಘҙྖҬͰͷڧΈͱΫϥ΢υɾιϑτ΢ΣΞͷڧΈͰطଘͷαʔ ϏεͱͷࠩผԽΛਤΓ͍ͨ ‣ ஍ਤ্ʹϚοϐϯά͢Δ͜ͱ΍Ґஔิਖ਼Λߦ͑Δٕज़Λ֫ಘ͠ ͍͖͍ͯͨ
  4. 12 SkyBrain ‣ Ґஔ৘ใσʔλͷ஝ੵ͸ SORACOM Funnel or Amazon Kinesis Ͱߦ͏

    ‣ Ґஔ৘ใσʔλͷ׆༻ʹ͍ͭͯ͸ Amazon API Gateway Λ ར༻ͯ͠ API ܦ༝Ͱߦ͏ ‣ σʔλͷ஝ੵͱ׆༻͕؆୯͔ͭ҆શɾ҆Ձʹߦ͑Δ ‣ ΄΅ϦΞϧλΠϜͳσʔλΛ׆༻Ͱ͖ΔΑ͏ʹͳΔ ‣ ϦΞϧλΠϜͳσʔλ͕ՃΘΔ͜ͱͰطଘͷσʔλ΍ API ͕৽ͨͳՁ஋Λ࣋ͭ ‣ Ϣʔβʔʹରͯ͠৽ͨͳՁ஋Λఏڙ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹ ͳΔ
  5. 14 SkyBrain ‣ ஝ੵʹ͸౰ॳ AWS IoT Λར༻͍ͯͨ͠ ‣ ಛ௃తͳDevice Shadows

    ΍Pub/Sub ͷSub Λར༻͢Δ Մೳੑ͕௿͍ ‣ Amazon Kinesis Ͱ༻݅΋ੑೳ΋ඞཁे෼ͦ͏ͩͬͨ ‣ ଍Γͳ͍෦෼͸ AWS LambdaͰิ׬͢Ε͹໰୊ͳͦ͞͏ ‣ SORACOM ͔Β Funnel ͱ͍͏ศརͳػೳ͕ϦϦʔε͞ Εͨ͜ͱ΋େ͖͍ ‣ SORACOM Funnel ܦ༝Ͱ͋Ε͹ೝূ෦෼Λ͓೚ͤͰ͖Δ ͷͰؾʹͤͣʹૹ৴͢Δ͜ͱ͕Ͱ͖Δ
  6. 16 SkyBrain ‣ Ґஔ৘ใͷऔಘʹ͸ HTML+JavaScript Λར༻ ‣ Geolocation.watchPosition() Λར༻͍ͯ͠Δ ‣

    ͜ͷͨΊ Amazon S3 ͷ੩త΢ΣϒαΠτͷϗεςΟϯά͚ͩͰ αʔϏεΛఏڙ͢Δ͜ͱ͕Մೳ ‣ Amazon Kinesis Streams ʹ AWS Lambda ؔ਺Λػೳɾ༻్ผʹ ෳ਺ݸ௥Ճͯ͋͠Δ ‣ ৽͍͠ػೳ΍༻్͕௥Ճʹͳͬͯ΋͜ͷߏ੒ͩͱඞཁʹԠͯ͡ AWS Lambda ؔ਺Λ௥Ճ͢Ε͹ྑ͍ ‣ AWS Lambda ؔ਺ͷϦτϥΠ΍σʔλͷอ࣋ʹؔͯ͠΋ Amazon Kinesis+AWS Lambda ଆ͕نఆͷൣғͰΧόʔͯ͘͠ΕΔ
  7. 18 SkyBrain ‣ ౰ॳ͸ Amazon API Gateway ͷλΠϜΞ΢τ੍ݶʹΑΓར ༻Ͱ͖Δൣғ͕ݶఆతͩͬͨ ‣

    ઌ೔ͷΞοϓσʔτʹΑΓλΠϜΞ΢τ੍ݶ͕29ඵ·Ͱ৳ ͼͨͷͰར༻Ͱ͖Δൣғ͕޿͕ͬͨ ‣ Amazon S3 ʹσʔλΛ஝ੵ͢Δஈ֊Ͱ׆༻͢ΔଆΛҙࣝ͠ ͨߏ଄Ͱ஝ੵ͢ΔΑ͏ʹ͍ͯ͠Δ ‣ Amazon API Gateway Λར༻͢Δ͜ͱʹΑΓΩϟογϡͷ ༗ޮԽ΍εϩοτϦϯάͳͲͷػೳ͕ར༻Ͱ͖Δ ‣ ඞཁͳσʔλ͕͋Δ৔߹͸ AWS Lambda ؔ਺Λ௥Ճ͢Δ͜ ͱͰରԠ͢Δ͜ͱ͕Ͱ͖Δ
  8. 20 SkyBrain ‣ Ґஔ৘ใͷ׆༻ɾදࣔʹ͸ HTML+JavaScript Λར༻ ‣ Amazon API Gateway

    ܦ༝Ͱऔಘͨ͠JSONΛ஍ਤαʔϏ ε্ʹදࣔ ‣ Amazon API Gateway ܦ༝Ͱ AWS Lambda ؔ਺Λػೳɾ ༻్ผʹෳ਺ݸ௥Ճͯ͋͠Δ ‣ ৽͍͠ػೳ΍༻్͕௥Ճʹͳͬͯ΋͜ͷߏ੒ͩͱඞཁʹԠ͡ ͯ AWS Lambda ؔ਺Λ௥Ճ͢Ε͹ྑ͍ ‣ API ͷ؅ཧ෦෼ʹؔͯ͠͸ Amazon API Gateway ͷػೳͰ ୲อ͞ΕΔͨΊ AWS Lambda ؔ਺ͷಈ࡞ʹ஫ྗ͢Ε͹Α͍
  9. 22 ·ͱΊ ‣ SkyBrain Λల։͍ͯ͘͜͠ͱͰϦΞϧλΠϜσʔλΛ औಘɾ஝ੵͯ͠ API Ͱ׆༻Ͱ͖ΔΑ͏ʹ͍ͯ͘͠ ‣ ϦΞϧλΠϜσʔλʹΑΓطଘͷ

    API ΍σʔλʹ৽ͨͳ Ձ஋΍ར༻༻్͕૿͑ΔՄೳੑΛ໛ࡧ͢Δ ‣ Serverless ͳߏ੒ʹͨ͜͠ͱͰ࡞ͬͨαʔϏε΍ػೳʹ ΋Ϋϥ΢υͷྑ͍ͱ͜Ζ͕ͦͷ··׆͔͍ͤͯΔ ‣ AWS Lambda Λ׆༻͢Δࡍʹ͸ϓϥΨϒϧʹͳΔΑ͏ ʹ Amazon Kinesis ΍ Amazon API Gateway ͳͲͷ αʔϏεΛҙࣝͯ͠ར༻ͨ͠ํ͕ྑ͍
  10. 23 ·ͱΊ ‣ ݱঢ়͸σϓϩΠ΍؂ࢹपΓ͕࣮૷͞Ε͍ͯͳ͍ঢ়ଶ ‣ Amazon Kinesis ͷΩϟύγςΟʹؔͯ͠΋࠷௿ݶͷߟྀ ͔͍ͯ͠͠ͳ͍ঢ়ଶ ‣

    ࣮ࡍʹαʔϏεͱͯ͠ϦϦʔε͢Δࡍʹ͸ॏཁͳ෦෼ ‣ IoT αʔϏε޲͚ʹϓϩτλΠϐϯάதͳͷͰมԽʹ͸ॊ ೈʹରԠ͍ͯ͘͠ ‣ มԽ΁ͷରԠ͸Մೳͳͱ͜Ζ͔Βૉૣ͘ΧΠθϯ͍ͯ͘͠ ‣ ஌ݟ΍ϊ΢ϋ΢͕ແ͍͜ͱ΋ଟ͋͘ΔͷͰͱʹ͔͘ Tryˍ Error Λ܁Γฦ͍ͯ͘͠
  11. 25 Appendix ‣ גࣜձࣾιϥίϜ - https://soracom.jp/ ‣ Cloudcraft - Draw

    AWS diagrams - https://cloudcraft.co/ ‣ AWS Lambda / Amazon API Gateway Deep Dive - http://www.slideshare.net/keisuke69/aws-lambda- amazon-api-gateway-deep-dive ‣ ΞΠίϯૉࡐμ΢ϯϩʔυαΠτʮicooon-monoʯ - http://icooon-mono.com/
  12. 26 Appendix ‣ גࣜձࣾϰΝϧݚڀॴ - http://www.val.co.jp/ ‣ Ӻ͢ͺ͋ͱϫʔϧυ - https://ekiworld.net/

    ‣ Ӻ͢ͺ͋ͱ - YouTube - https://www.youtube.com/channel/ UChsdHb4qHO5eFmSOhl0Udsw ‣ ʮӺ͢ͺ͋ͱʯͷ͋ͨΒ͍͠࿏ઢਤ - http://rosenzu.strikingly.com/
  13. 27 Appendix ‣ JAWS-UG தԝઢ - http://jaws-ug.jp/bc/chuoline/ ‣ JAWS-UG ژԦઢ

    - https://jawsug-keioline.doorkeeper.jp/ ‣ uchimanajet7 - Pixelhub.me - http://pixelhub.me/pixelhub1/index.php? user=uchimanajet7