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

GCP サーバーレスサービス× 少数チームによる事業立ち上げ / gcp_serverless...

mokuo
September 24, 2019

GCP サーバーレスサービス× 少数チームによる事業立ち上げ / gcp_serverless_startup_business

GCP サーバーレス サービスについて / アーキテクチャ / メリット / ハマりどころ / 今後の課題

mokuo

September 24, 2019
Tweet

More Decks by mokuo

Other Decks in Programming

Transcript

  1. Agenda - ࣗݾ঺հ - Sansan αʔϏε঺հ - ߴਫ਼౓ͳσʔλԽΛࢧ͑Δϊ΢ϋ΢ - GCP

    αʔόʔϨε αʔϏεͷ׆༻ࣄྫ ʙ৽ͨͳσʔλԽαʔϏεͷݕূʙ 2
  2. ࣗݾ঺հ - ໦ా ༔Ұ࿠ - Sansanגࣜձࣾ DSOC Development Group ΤϯδχΞ

    - αʔόʔαΠυΛத৺ʹϑϩϯτΤϯυɾ Πϯϑϥʹ΋ڵຯ͕͋Γ·͢ - Sansan Tech Podcast ΍ͬͯ·͢ʂ 3
  3. Agenda - ࣗݾ঺հ - Sansan αʔϏε঺հ - ߴਫ਼౓ͳσʔλԽΛࢧ͑Δϊ΢ϋ΢ - GCP

    αʔόʔϨε αʔϏεͷ׆༻ࣄྫ ʙ৽ͨͳσʔλԽαʔϏεͷݕূʙ 4
  4. 6

  5. Agenda - ࣗݾ঺հ - Sansan αʔϏε঺հ - ߴਫ਼౓ͳσʔλԽΛࢧ͑Δϊ΢ϋ΢ - GCP

    αʔόʔϨε αʔϏεͷ׆༻ࣄྫ ʙ৽ͨͳσʔλԽαʔϏεͷݕূʙ 7
  6. Agenda - ࣗݾ঺հ - Sansan αʔϏε঺հ - ߴਫ਼౓ͳσʔλԽΛࢧ͑Δϊ΢ϋ΢ - GCP

    αʔόʔϨε αʔϏεͷ׆༻ࣄྫ ʙ৽ͨͳσʔλԽαʔϏεͷݕূʙ 14
  7. GCP αʔόʔϨε αʔϏεʹ͍ͭͯ - Google App Engine - Cloud Firestore

    - Cloud Tasks - Stackdriver - Cloud Storage - Cloud Functions 18
  8. GCP αʔόʔϨε αʔϏεʹ͍ͭͯ - Google App Engine - Cloud Firestore

    - Cloud Tasks - Stackdriver - Cloud Storage => AWS S3 - Cloud Functions => AWS Labmda 19
  9. Google App Engine PaaSʢPlatform as a Serviceʣ - εέʔϧΞ΢τɾσϓϩΠ͕ߴ଎ -

    Πϯελϯε͕θϩ·ͰεέʔϧΠϯ - αϙʔτϥϯλΠϜ - Java, Python, Go, PHP, Node.js, Rubyʢbetaʣ 20
  10. Cloud Firestore ͷ֊૚σʔλ ྫʣͦΕͧΕͷνϟοτϧʔϜʹෳ਺ͷϝοηʔδ͕͋Δ - rooms - room-A - messages

    - message-1 - message-2 - … - room-B - … 22 name: “։ൃϧʔϜ” from: “ଠ࿠”, msg: “͜Μʹͪ͸ʂ” from: “࣍࿠”, msg: “Hello!”
  11. Cloud Firestore ͷ֊૚σʔλ ྫʣͦΕͧΕͷνϟοτϧʔϜʹෳ਺ͷϝοηʔδ͕͋Δ - rooms - room-A - messages

    - message-1 - message-2 - … - room-B - … 23 name: “։ൃϧʔϜ” from: “ଠ࿠”, msg: “͜Μʹͪ͸ʂ” from: “࣍࿠”, msg: “Hello!” ← ʢϧʔτʣίϨΫγϣϯ ← υΩϡϝϯτ ← rooms ͷαϒίϨΫγϣϯ ← υΩϡϝϯτ
  12. Cloud Firestore ͷσʔλܕ - Map - JavaScript ͷΦϒδΣΫτɺRuby ͷϋογϡɺPython ͷࣙॻܕͷΑ͏ͳ஋ΛೖΕΒ

    ΕΔ - Array - Boolean - Date and time - String - … ࢀߟ: https://firebase.google.com/docs/firestore/manage-data/data-types 24
  13. Cloud Tasks ϑϧϚωʔδυͳλεΫΩϡʔαʔϏε - ॲཧΛඇಉظͰ࣮ߦͰ͖Δ - HTTP Target λεΫʢbetaʣ -

    App Engine λεΫ - ಉ࣌λεΫͷ࠷େϨʔτ΍࠷େ਺ΛઃఆͰ͖Δ 25
  14. ΞʔΩςΫνϟ KPI ج൫ ϩΪϯά / Τϥʔ௨஌ Stackdriver Ϣʔβʔଆ γεςϜ BigQuery

    Cloud Pub/Sub ࣗಈԽΤϯδϯ Cloud Dataflow App Engine Cloud Functions Cloud Storage Cloud Firestore Compute Engine Cloud Tasks ೖྗ / σʔλԽ γεςϜ
  15. ΞʔΩςΫνϟ KPI ج൫ ϩΪϯά / Τϥʔ௨஌ Stackdriver Ϣʔβʔଆ γεςϜ BigQuery

    Cloud Pub/Sub ࣗಈԽΤϯδϯ Cloud Dataflow App Engine Cloud Functions Cloud Storage Cloud Firestore Compute Engine Cloud Tasks ೖྗ / σʔλԽ γεςϜ
  16. ϑΝΠϧΞοϓϩʔυͰಛఆͷॲཧΛߦ͏ - Cloud Functions ͷ Cloud Storage τϦΨʔ - Cloud

    Tasks ͷ App Engine λεΫ 34 Cloud Storage Cloud Functions App Engine Cloud Tasks
  17. KPI ج൫ - Google App Engine ͔Β Cloud Pub/Sub ܦ༝ͰϩάΛૹ৴

    - Tableau ͰՄࢹԽ 36 App Engine BigQuery Cloud Pub/Sub Cloud Dataflow
  18. ϝϦοτᶃɿΞϓϦέʔγϣϯͷίʔυʹूதͰ͖Δ - ඇಉظ࣮ߦ - ఆظ࣮ߦ - σϓϩΠ - IPΞυϨε੍ݶ -

    τϥϑΟοΫ෼ׂ 40 Cloud Tasks App Engine Cron gcloud ίϚϯυ App Engine ϑΝΠΞ ΢Υʔϧ Traffic Splitting App Engine
  19. ϝϦοτᶃɿΞϓϦέʔγϣϯͷίʔυʹूதͰ͖Δ - ඇಉظ࣮ߦ - ఆظ࣮ߦ - σϓϩΠ - IPΞυϨε੍ݶ -

    τϥϑΟοΫ෼ׂ 41 Cloud Tasks App Engine Cron gcloud ίϚϯυ App Engine ϑΝΠΞ ΢Υʔϧ Traffic Splitting App Engine
  20. τϥϑΟοΫ෼ׂ - Traffic Splitting - ෳ਺όʔδϣϯͷΠϯελϯεΛಉ࣌ʹಈ͔ͤΔ
 - IP ΞυϨε΍ Cookie

    ͰτϥϑΟοΫΛ෼ׂͰ͖Δ
 - ؅ཧը໘͔ΒΠϯελϯεͷόʔδϣϯΛมߋͰ͖Δ 42 App Engine
  21. τϥϑΟοΫ෼ׂ - Traffic Splitting - ෳ਺όʔδϣϯͷΠϯελϯεΛಉ࣌ʹಈ͔ͤΔ
 => ಈ࡞֬ೝ΍ςετ - IP

    ΞυϨε΍ Cookie ͰτϥϑΟοΫΛ෼ׂͰ͖Δ
 => A/B ςετ - ؅ཧը໘͔ΒΠϯελϯεͷόʔδϣϯΛมߋͰ͖Δ 43 App Engine
  22. τϥϑΟοΫ෼ׂ - Traffic Splitting - ෳ਺όʔδϣϯͷΠϯελϯεΛಉ࣌ʹಈ͔ͤΔ
 => ಈ࡞֬ೝ΍ςετ - IP

    ΞυϨε΍ Cookie ͰτϥϑΟοΫΛ෼ׂͰ͖Δ
 => A/B ςετ - ؅ཧը໘͔ΒΠϯελϯεͷόʔδϣϯΛมߋͰ͖Δ 44 App Engine
  23. τϥϑΟοΫ෼ׂ - Traffic Splitting - ෳ਺όʔδϣϯͷΠϯελϯεΛಉ࣌ʹಈ͔ͤΔ
 => ಈ࡞֬ೝ΍ςετ - IP

    ΞυϨε΍ Cookie ͰτϥϑΟοΫΛ෼ׂͰ͖Δ
 => A/B ςετ - ؅ཧը໘͔ΒΠϯελϯεͷόʔδϣϯΛมߋͰ͖Δ => ϩʔϧόοΫ 45 App Engine
  24. ϋϚΓͲ͜Ζ - ᶃ Google App Engine ؀ڥ - ᶄ App

    Engine ϑΝΠΞ΢Υʔϧ - ᶅ Cloud Firestore ͷσʔλϕʔεઃܭ 51
  25. ϋϚΓͲ͜ΖᶃɿGoogle App Engine ؀ڥ - ελϯμʔυ؀ڥ or ϑϨΩγϒϧ؀ڥ => ՄೳͳݶΓελϯμʔυ؀ڥΛ࢖͏

    - σϓϩΠ΍εέʔϦϯά͕ߴ଎ - Πϯελϯε͕θϩ·ͰεέʔϧΠϯ - ެࣜυΩϡϝϯτࢀর - https://cloud.google.com/appengine/docs/flexible/java/flexible-for- standard-users?hl=ja 52 App Engine
  26. GAE/FE Λ࢖͏৔໘ - Google App Engine / Flexible Environment -

    - GAEΠϯελϯεΛ VPC ωοτϫʔΫʹඥ෇͚͍ͨ࣌ - AWS ্ͷࣾ಺αʔϏεͱ VPN Ͱ઀ଓ͔ͨͬͨ͠ͷͰɺҰ෦ GAE/FE Λ ࢖༻ - ݱࡏ͸ Serverless VPC Access Λ࢖͑͹ɺελϯμʔυ؀ڥ͔Β VPC Ϧ ιʔεʹΞΫηεՄೳ - ৐Γ׵͑Λݕ౼த 53 App Engine
  27. GAE/FE Λ࢖͏৔໘ - Google App Engine / Flexible Environment -

    - ಛఆͷϥΠϒϥϦΛ࢖͍͍ͨ࣌ - ผαʔϏεʹ੾Γग़ͯ͠ Docker ΠϝʔδΛ࢖༻ - ݱࡏ͸ Cloud Run Λ࢖༻͢Δ͜ͱͰɺGAE/SE ͷΑ͏ͳεέʔϥϏϦ ςΟΛอͪͭͭɺDocker ΠϝʔδΛ࢖ͬͨߏ੒ʹͰ͖Δ 54 App Engine
  28. ϋϚΓͲ͜ΖᶄɿApp Engine ϑΝΠΞ΢Υʔϧ GCP αʔϏεؒͷ௨৴΋ϒϩοΫ͞ΕΔ͜ͱ͕͋Δ - Cloud Pub/Sub ͸άϩʔόϧͳαʔϏεͰ͋ΔͨΊɺ
 ϗϫΠτϦετ௥Ճ͸Ͱ͖ͳ͍

    - Cloud Tasks ͸಺෦తʹ URL ϑΣον αʔϏεΛ࢖͍ͬͯΔͨΊɺ
 URL ϑΣον αʔϏεͷ IP ΞυϨεΛڐՄ͢Δ 55 Cloud Storage Cloud Functions App Engine Cloud Tasks App Engine Cloud Pub/ Sub Cloud Storage App Engine
  29. ϋϚΓͲ͜ΖᶅɿCloud Firestore ͷσʔλϕʔεઃܭ SQL ͷΑ͏ͳ COUNT ؔ਺͸ͳ͍ - υΩϡϝϯτΛΨόͬͱऔ͖ͬͯͯΧ΢ϯτ͢Δ͜ͱ͸Ͱ͖Δ -

    ෼ࢄΧ΢ϯλΛ࢖͏ - ੍໿ɿ1 υΩϡϝϯτ͋ͨΓ 1 ඵؒʹ໿ 1 ճ͔͠ߋ৽Ͱ͖ͳ͍ - Χ΢ϯλ༻ͷυΩϡϝϯτΛෳ਺༻ҙͯ͠ɺϥϯμϜʹΠϯΫϦϝϯτ͢Δ - શυΩϡϝϯτΛऔಘͯ͠߹ܭΛܭࢉ͢Δ - FieldValue.increment() Λ࢖͏ʢv1.1.0 ͰϦϦʔεʣ - ཁ݅ʹΑͬͯ͸ɺRedis ͳͲͰΧ΢ϯτ͢Δͷ΋͋Γ 56 Cloud Firestore
  30. Firestore Ͱؔ࿈ΛͲͷΑ͏ʹ͔࣋ͭ ॻ͖ࠐΈ΍ಡΈࠐΈͷස౓Ͱ൑அ͢Δ - 1 : N ͷσʔλʹ͍ͭͯ - Ұॹʹѻ͏͜ͱ͕ଟ͍৔߹

    => Array ܕͱͯ͠ϑΟʔϧυʹ࣋ͨͤΔ - 1 υΩϡϝϯτ͋ͨΓ 1 ඵؒʹ໿ 1 ճ͔͠ߋ৽Ͱ͖ͳ͍ - ผʑʹѻ͏͜ͱ͕ଟ͍৔߹ => αϒίϨΫγϣϯʹ࣋ͨͤΔ - ίϨΫγϣϯͱαϒίϨΫγϣϯʹ·͕ͨͬͨΫΤϦ͸Ͱ͖ͳ͍ 57 Cloud Firestore
  31. ࠓޙͷ՝୊ᶃɿ։ൃ؀ڥ - Cloud Firestore ͸ 1 ϓϩδΣΫτʹ 1 ͔ͭ͠ DB

    Λ࡞Εͳ͍ - ։ൃɾࣗಈςετ - Cloud Tasks ͸ Push ͳͷͰɺϩʔΧϧʹ޲͚ΒΕͳ͍ - ։ൃ࣌͸ Cloud Tasks ΛϞοΫ͢Δ͔ 60
  32. ࠓޙͷ՝୊ᶄɿಈ࡞֬ೝ - Heroku Review Apps ͷΑ͏ͳ͜ͱΛ͍ͨ͠ - PR ͝ͱʹ؀ڥΛཱͯΔ -

    Google App Engine ͸ෳ਺όʔδϣϯͷΠϯελϯεΛಉ࣌ʹಈ͔͢͜ͱ ͕Ͱ͖Δ 61
  33. ࠓޙͷ՝୊ᶆɿΤϥʔ௨஌ - Stackdriver Error Reporting ͔Βͷ ϝʔϧ௨஌Λ Gmail ͷϑΟϧλػೳͰ Slack

    ʹ௨஌͍ͯ͠Δ - λΠϜϥά͕͋Δ - ςΩετΛΧελϚΠζͰ͖ͳ͍ - Datadog ΁ͷू໿Λݕ౼ 63