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

Google App Engine を利用した、新規 Web サービスの立ち上げ方

Google App Engine を利用した、新規 Web サービスの立ち上げ方

TECH PLAY Conference 2017 - クラウド最先端技術
#techplayconf2017 #techplayjp

Osamu TONOMORI

August 20, 2017
Tweet

More Decks by Osamu TONOMORI

Other Decks in Technology

Transcript

  1. Agenda 1. Who Am I ? 2. Overview of Google

    App Engine 3. In the case of Mercari Kauru 4. Summary
  2. Who Am I ? • ओ৿ ཧ - Osamu TONOMORI


    ʢTwitter & GitHub: @osamingoʣ • גࣜձࣾι΢κ΢ - ϝϧΧϦΧ΢ϧνʔϜ
 ʢEx-Company: CyberAgent, Inc. ~ AbemaTV, Inc.ʣ • ιϑτ΢ΣΞΤϯδχΞ - Gopher
 ʢServer-side Leader, Scrum Master, Mood Makerʣ
  3. About Google App Engine (GAE) • Google Cloud Platform ͕ఏڙ͢ΔαʔϏεͷͻͱͭɻ

    • 2007೥ʹ Python, Java ͕࢖͑Δ PaaS ͱͯ͠ϦϦʔεɻ • GAE ʹ͸ɺStandard Environment, Flexible Environment ͷ2छྨ͕͋Δɻ • ར༻Ͱ͖ΔϦʔδϣϯ͕ݶΒΕ͍ͯΔ͕ɺ౦ژϦʔδϣϯʹ͸༗Γ㽂ɻ • ओͳڝ߹͸ɺHeroku, Engine Yard ͳͲɻ
  4. Google App Engine - Standard Environment (SE) • 2007೥ͷϦϦʔε౰ॳ͔Β͋Δͷ͕ɺStandard Environment

    Ͱ͢ɻ • ࢖༻Ͱ͖Δݴޠ͕ɺݶΒΕ͍ͯΔɻ
 Python 2.7.x, Java 7 or 8(β), PHP 5.5.x, Go 1.6 or 1.8 (β) • ϧʔϧ͸ଟ͍͕ɺͦͷ෼։ൃ΍ӡ༻ָ͕ʹͰ͖Δɻ • ઃఆΛ޻෉͢Ε͹ɺແྉͰ࢖͍ଓ͚ΒΕΔɻ
  5. Google App Engine - Flexible Environment (FE) • Google Cloud

    Next 2017 ʹͯɺGA ʹͳͬͨʂ • ΞϓϦέʔγϣϯͷத਎͸ɺ nginx + docker ߏ੒ʹͳ͍ͬͯΔɻ
 docker ͳͷͰɺՄೳੑ͸ແݶେͱ͍ͬͯ΋աݴͰ͸ແ͍ʂ • Google ͸ɺ Flexible Environment Λਪͯ͠ߦ͖͍ͨงғؾΛײ͡Δɻ
 Google App Engine ͷ LP ͕ɺFE લఏͰͷઆ໌͕ଟ͍ɻ
  6. Google App Engine - How to choose SE or FE?

    • ࠓͷͱ͜Ζ͸ɺStandard Environment Λબ୒͢Ε͹ؒҧ͍ͳ͍ɻ • Flexible Environment Λબ୒͢Δ৔߹ͷνΣοΫ߲໨
 ✔ Python, Java, PHP, Go Ҏ֎ͷݴޠͰ։ൃ͍ͨ͠ɻ
 ✔ ϑΝΠϧ࡞੒ͳͲɺҰ࣌తͳσΟεΫॻ͖ࠐΈ͕ඞཁʹͳΔɻ
 ✔ NAT ήʔτ΢ΣΠͳͲɺ಺෦ωοτϫʔΫʹॴଐ͢Δඞཁ͕͋Δɻ
 ✔ SSH ઀ଓΛߦ͍ɺσόοά͢Δඞཁ͕͋Δɻ
  7. Google App Engine - Scaling • Automatic (SE, FE)
 Application

    ͷϝτϦΫε৘ใʹΑͬͯ Instance ਺͕ࣗಈՄม͢Δɻ
 ࣌ؒଳʹΑΔΞΫηεมಈ͕ଟ͍ɺAPI ͳͲʹ޲͍͍ͯΔɻ • Basic (SE)
 ىಈ͢Δ࠷େ Instance ਺Λઃఆ͢Δ৔߹ʹઃఆ͢Δɻ
 ઃఆͰ͖Δ Instance class ΋๛෋ͰɺBatch ͳͲʹ޲͍͍ͯΔɻ • Manual (SE, FE)
 ىಈ͍ͯ͠Δ Instance Λݻఆ͢Δ৔߹ʹઃఆ͢Δɻ
  8. Google App Engine - Database • Cloud Datastore
 Google ۘ੡

    NoSQL ͷ Full-Managed αʔϏεɻ
 GAE ͷ৔߹͸ɺجຊతʹ Datastore Λ࢖͏͜ͱʹͳΔɻ • Cloud SQL
 Full-Managed ͷ RDB αʔϏεɻ
 ରԠ͍ͯ͠Δͷ͸ɺ MySQL 5.6 or 5.7, PostgreSQL 9.6 (β) ͷ 2 छྨ • Others
 Cloud Bigtable, Cloud Spanner, etc.
  9. Google App Engine - Caching System • Memcache
 GAE ͔ΒʹݶΓɺ

    Managed ͷ Memcache ͕ར༻Ͱ͖Δɻ
 ΍ͨΒૣ͘ 5ms ͱ͔ͰɺΩϟογϡऔಘ͕Ͱ͖Δɻ
 ͔͠͠ɺ՝ۚͯͨ͠ͱͯ͠΋ SLA ͸อূ͞Εͳ͍ͷͰ஫ҙ
  10. Google App Engine - Object Storage • Blobstore
 Cloud Storage

    ͕ϦϦʔε͞ΕΔ·Ͱ͸ɺBlobstore ͕ओྲྀͩͬͨɻ
 URL ൃߦ͢Δඞཁ͕͋Δ͕ɺେ͖͍αΠζʢ2GBʣͷϑΝΠϧΛѻ͑Δɻ • Cloud Storage
 ݱࡏͷओྲྀ͸ɺCloud Storage Ͱར༻Λਪ঑͞Ε͍ͯΔɻ
 Blobstore ͷػೳ΋ར༻Ͱ͖ΔΑ͏ʹޓ׵ੑ͕อͨΕ͍ͯΔɻ
  11. Google App Engine - Message Queueing • Taskqueue
 ֤ Service

    (Module) ؒͷඇಉظॲཧʹΑ͘༻͍Δɻ
 GAE ͔ΒͷΈ & ႈ౳ੑ୲อΛ͠ͳ͍͍͚ͳ͍͕ɺ࢖͍উख͕ͱͯ΋ྑ͍ɻ • Cloud Pub/Sub
 GAE ಺ʹ͸ดͣ͡ɺGAE ͱଞαʔϏεΛܨ͙͜ͱ͕Ͱ͖Δɻ
 Cloud Storage ͷ Upload Notification ͳͲɻ
  12. Google App Engine - Job Scheduler • Taskqueue - cron

    job
 Taskqueue ͷ 1 ػೳͱͯ͠ɺఏڙ͞Ε͍ͯΔɻ
 ઃఆͨ͠ Endpoint ʹରͯ͠ Kick ͢ΔɻϦτϥΠػೳ΋༗Γɻ
 ਓؒʹ༏͍͠ઃఆه๏Ͱخ͍͠
  13. Google App Engine - Search • Search API
 GAE ͔ΒݶΓར༻Ͱ͖Δɺݕࡧػೳɻ


    ܗଶૉղੳ΍ɺϑΝηοτݕࡧ΋͋ΔͷͰߜࠐΈػೳ΋ڧ͍ɻ
 ͨͩ͠ɺN-gram ΍ɺSynonym ʹ͸ରԠ͍ͯ͠ͳ͍ɻ
  14. Google App Engine - Logging • Stackdriver Logging
 ΞΫηεϩά͸ɺࣗಈతʹ Stackdriver

    Logging ʹू໿͞ΕΔɻ
 ΞϓϦέʔγϣϯ಺Ͱग़ྗ͢Δϩά΋ɺಉ༷ʹू໿͞ΕΔɻ
 ಛఆͷ৚݅ͷϩάΛ BigQuery ౳ʹྲྀ͢͜ͱ΋ग़དྷΔɻ
  15. Google App Engine - Monitoring & Alert • Stackdriver Monitoring


    Stackdriver Logging ͱಉ༷ʹࣗಈతʹϝτϦΫε͕ऩू͞ΕΔɻ
 GAE ͚ͩͰͳ͘ɺGCP ্ʹ͋ΔαʔϏε΋ࣗಈతʹऩू͞ΕΔɻ
 ऩू͞ΕͨϝτϦΫεΛݩʹ Alert ͷઃఆ΋Ͱ͖Δɻ
  16. Google App Engine - Others • Cloud Endpoint
 ΞΫηε؅ཧ΍ɺϞχλϦϯά͕Ͱ͖Δ API

    ήʔτ΢ΣΠɻ
 Open API ࢓༷Λ༻͍ͯɺΫϥΠΞϯτͱαʔόؒͰ࢓༷Λڞ༗Ͱ͖Δɻ
 gRPC (β) ൛΋͋Δ͕ɺݱࡏ GAE ʹ͸ະରԠ
  17. Google App Engine - Use cases • Snapchat (Snap, Inc.)


    Google Cloud Platform Live: Interview with SnapChat's Bobby Murphy
 https://youtu.be/17PtS1Qx8kU • Super Mario Run (Nintendo Co., Ltd. & DeNA, Inc.)
 Google Cloud Platform ಋೖࣄྫ - ೚ఱಊגࣜձ༷ࣾ
 https://youtu.be/-29lW2EWock
  18. Team Members - Server-side • ࠷ॳͷ 3 ϲ݄͙Β͍͸ɺࣗ෼ͻͱΓ͚ͩɻ
 GAE ͩͱɺΠϯϑϥߏங͍Βͳ͍ͷͰଈ೔͔Βίʔυॻ͚Δɻ

    • ݱࡏ͸ɺ4 ਓʢ1ਓ͸ผνʔϜ݉೚ʣମ੍Ͱ։ൃ͍ͯ͠Δɻ
 શһ Server-side ΤϯδχΞͰɺInfra ઐ೚͸ډͳ͍ɻ
  19. Webhook Service • ֎෦αʔϏε͔Βͷ Event Λड͚෇͚Δɻ • Mercari, Tracking ͳͲ

    • Webhook Ͱ͸ɺ۩ମతͳॲཧ͸͠ͳ͍ɻ • Taskqueue ʹྲྀ͔͢ɺLogging Λߦ͏͚ͩɻ • ڧ͍ Instance ͸ཁΒͳ͍͠ɺScale out ͚ͩͯ͘͠ΕΕ͹ྑ͍ɻ
  20. Management Service (Event & Batch) • ඇಉظͰߦ͏ॲཧΛશͯ੥͚ෛ͏αʔϏε • Basic Scaling

    Ͱ Instance Class ΛڧΊʹઃఆͯ͠ॲཧ͠·͘Δɻ • ࣌ؒͷ͔͔Δ Batch ॲཧ΋ߦ͏ɻ
 ʢਖ਼௚ɺSubscriber, Batch ʹ෼ׂ͢Ε͹ྑ͔ͬͨͱޙչ͍ͯ͠Δɻʣ
  21. Database • Mercari Kauru Ͱ͸ɺ
 ɹCloud Datastore
 ɹCloud SQLʢMySQL 5.7ʣ


    ͷͲͪΒ΋ར༻͍ͯ͠·͢ɻ • DDD Λ࠾༻͍ͯͯ͠ɺ
 Domain Repository ͰӅṭ͍ͯ͠Δɻ
  22. Database - Cloud Datastore • Datastore Ͱ͸ɺMercari Kauru ݻ༗ͷσʔλΛอ͍࣋ͯ͠·͢ɻ •

    ಛʹແݶʹ஝ੵ͞Ε͍ͯ͘ܥͷσʔλ͸ɺNoSQL ͷಘҙ෼໺ɻ • Like, Stock, Notification, PushNotificationToken, etc.
  23. Database - Cloud SQL • MySQL ʹ͸ɺ੡඼ͷϚελσʔλΛอ͍࣋ͯ͠·͢ɻ • ݩͷ Schema

    ͕ɺਖ਼نԽ͞Ε͍ͯͯ NoSQL ʹ֨ೲ͢Δͷ͸೉͍͠ɻ • Ϛελσʔλ͸ɺ੔ܗ͞Ε Cache Խ͞ΕΔͷͰɺগΞΫηεɻ
 ʢGAE ͔Β͸ɺ12 connections/instance ͱ੍ݶ͞Ε͍ͯΔɻʣ • ͜͜Λؒҧ͑ΔͱΤά͍ͷͰɺอશ͕ୈҰͷબ୒Λͨ͠ɻ
  24. Version - Development • Development Ͱ͸ɺbranch ຖʹ؀ڥΛ؆୯ʹ༻ҙ͍ͯ͠Δɻ • ֤ Version

    ʹ͸ݻ༗ͷαϒυϝΠϯ͕ൃߦ͞ΕΔɻ • ฒྻͰػೳ։ൃ΍ɺQA Λߦ͑ΔͷͰͱͯ΋ศརɻ
  25. Logging & Analytics • Application ͔Βॻ͖ग़͢ϩά͸ JSON Format Ͱॻ͖ग़͍ͯ͠Δɻ •

    Stackdriver Logging ʹू໿͞ΕͨޙɺBigQuery ʹྲྀ͠ࠐΜͰ͍Δɻ
 BigQuery ʹ͸ɺJSON ؔ਺͕͋ΔͷͰѻָ͍͕ʹͳΔɻ • Firebase Analytics ͔Β΋ BigQuery ʹ Event ϩάΛྲྀ͠ࠐΜͰ͍Δɻ
 Server, Client Λॎஅͯ͠෼ੳΛߦ͑Δ (๑•̀ŷ•́)و✧
  26. Release & Deploy • શͯ ChatOps Ͱߦ͍ͬͯΔɻ
 @kaurungo [release, migrate,

    traffic, etc.] • GAE ʹ͸ Admin API ͱ͍͏ɺ༷ʑͳૢ࡞͕Ͱ͖Δ API ͕͋Δɻ
 ops-bot ͱ͍͏ Service Λ੾ͬͯɺ GAE ্Ͱӡ༻͍ͯ͠Δɻ
  27. Summary • খ࢝͘͞ΊΔͳΒ Google App Engine ͸ɺྑ͍બ୒ࢶͷͻͱͭɻ
 ಛʹ։ൃΑΓ΋ɺӡ༻ΛΞάϨογϒʹߦ͑Δɻ • େ͖͘ҭͯΔͷ΋ྑ͠ɺGCP

    ͷԸܙΛ਺ଟ͘ड͚Δ͜ͱ͕Ͱ͖Δɻ
 ͱͯͭ΋ͳ͘ώοτͨ͠Βɺ࠷খݶͷίετͰ GCE, GKE ʹҠߦͰ͖Δɻ • φϨοδ΋஝ੵ͞Ε͍ͯΔ͠ɺϝϯςφϯε΋׆ൃʹߦΘΕ͍ͯΔɻ
 ಛʹ೔ຊͰ͸ɺGCPUG ίϛϡχςΟͷԸܙ͕ड͚ΒΕΔɻ