Pro Yearly is on sale from $80 to $50! »

個人開発しているサービスのインフラをAWSからGCPに載せ替えた話 💪 / kojin_kaihatsu_night_3

A79762150f8a3c6015ec11c4f494a371?s=47 kikunantoka
February 06, 2020

個人開発しているサービスのインフラをAWSからGCPに載せ替えた話 💪 / kojin_kaihatsu_night_3

A79762150f8a3c6015ec11c4f494a371?s=128

kikunantoka

February 06, 2020
Tweet

Transcript

  1. ݸਓ։ൃ͍ͯ͠ΔαʔϏεͷΠϯϑϥΛ AWS͔ΒGCPʹࡌͤସ͑ͨ࿩ ݸਓ։ൃ Night #3 on 2020/02/06 @kikunantoka

  2. ࣗݾ঺հ about: name: Fumitaka Kikukawa twitter: @kikunantoka work_at: giftee Inc.

    job: software engineer // ࠷ۙ͸FlutterͰΞϓϦΛ։ൃ͍ͯ͠·͢
  3. ݸਓ։ൃΛ͍ͯ͠ΔϞνϕʔγϣϯ • ࡞Γ͍ͨͱࢥͬͨ΋ͷɺ໘ന͍ͱࢥͬͨ΋ͷΛࣗ༝ؾ··ʹ࡞Γ͍ͨ • ٕज़ͷΩϟονΞοϓ • ৽͍ٕ͠ज़͕ग़͖͔ͯͨΒࢼͯ͠ΈΔ • ۀ຿ͰRailsͷόʔδϣϯΛ্͛ΔલʹݸਓͷαʔϏεͰૉৼΓ͢Δ •

    ͋ΘΑ͘͹ϚωλΠζ
  4. ݸਓ։ൃΛ͍ͯ͠ΔϓϩμΫτ https://nakamy.com

  5. ݸਓ։ൃΛ͍ͯ͠ΔϓϩμΫτ User 01 User 02 User 03 User 04 •

    ࣗ෼ͷϗʔϜը໘ΛΞοϓϩʔυ͢ΔͱɺTwitterͷ༑ͩͪͷϗʔϜը໘Λ೷͚Δ
  6. 2೥લ

  7. NakamyΛࢧ͑Δٕज़

  8. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2
  9. NakamyΛࢧ͑Δٕज़ • AWSͷແྉ࿮Ͱ΍͍ͬͯͨ

  10. ݸਓ։ൃ͋Δ͋Δ • ͳ͔ͳ͔αʔϏε͸উखʹ޿·Βͳ͍ • ޿ΊΔͨΊʹΠϯλϏϡʔͱ͔Λͯ͠ɺϗʔϜը໘Λ೷͘ͱ͍͏͜ͱ͕໘ന͍ͱײ ͯ͡΋Β͑ΔΑ͏ͳϝσΟΞΛ࡞Ζ͏ • ͔ͤͬͩ͘͠ɺ৽͍ٕ͠ज़Λࢼͯ͠Έ͍͔ͨΒGatsbyJS࢖ͬͯΈΑ͏ • ͦͷલʹݸਓϒϩά΋ͪΐ͏Ͳ࡞Γม͔͔͑ͨͬͨΒઌʹϒϩάͰࢼͯ͠ΈΑ͏

    • ͓ͬɺ৽͍͠αʔϏεࢥ͍͍͔ͭͨΒϓϩτλΠϓΛ࡞ͬͯΈΑ͏
  11. …࣌͸ա͗ɺ1೥ޙ

  12. ແྉ࿮ऴྃͷ͓஌Βͤ • 5,000ԁ/݄ ͔͔ͬͱΔ΍Μ͚…ʂ

  13. ແྉ࿮ऴྃͷ͓஌Βͤ • 5,000ԁ/݄ͷ಺༁ • EC2 1,000ԁ/݄ • ALB 2,000ԁ/݄ •

    RDS 2,000ԁ/݄
  14. Ϋϩʔζ͢Δʁ • ݩʑ͸1೥ͰͩΊͩͬͨΒΫϩʔζ͠Α͏ͱࢥ͍ͬͯͨ • ͔ͤͬ͘࡞ͬͨ͠ͳ͋ • ৽͍͠ࢼΈͷૉৼΓͷ৔ͱͯ͠΋࢒͓͖͍ͯͨ͠ • ΤϯδχΞͱͯ͠͸ϙʔτϑΥϦΦతͳཁૉ΋͋Δ •

    αʔϏεΛ޿ΊΔͨΊʹ৭ʑͱࢼͯ͠Έ͍ͨ • ͤΊͯɺΠϯϑϥඅ༻Λ཈͑Δ౒ྗΛ͠Α͏
  15. վΊͯཁ݅ • RailsΛಈ͔͍ͨ͠ • Πϯϑϥඅ༻ΛͳΔ΂͘཈͍͑ͨ • αʔϏε͕޿·ͬͨ࣌ʹεέʔϧ͢ΔϞσϧʹ͍ͨ͠ • ΍ͬͺΓHeroku΋ྑ͍ͳ͋ɺݸਓͰ΋TokyoϦʔδϣϯ࢖͑Δͱྑ͍ͷʹͳ͋

  16. GCPʹม͑ͯΈͨ࿩ • ࣾ಺ͷLTձͰಉ྅͔ΒCloud Runͱ͍͏໘ന͍΋ͷ͕ग़͖ͯͨͱ͍͏࿩Λฉ͍ͨ https://speakerdeck.com/mochisuna/docker-multi-stage-build

  17. GCPʹม͑ͯΈͨ࿩ • අ༻Λ཈͑ΒΕͦ͏ • ࢓ࣄͰ΋AWSΛ࢖͍ͬͯͨͷͰɺGCPΛ৮ͬͯΈͯɺٕज़஌ݟΛ޿͔͛ͨͬͨ • ͍ͬͦͷ͜ͱ͢΂ͯͷϦιʔεΛAWS -> GCPʹͰ͖ͳ͍͔ͳ͋

  18. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2
  19. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2 • Google Domains • Cloud Storage ( + Cloud CDN) • Cloud SQL • Cloud Run • Cloud Run • Cloud Run
  20. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2 • Google Domains • Cloud Storage ( + Cloud CDN) • Cloud SQL • Cloud Run • Cloud Run • Cloud Run
  21. Google Domains

  22. Google Domains • GoogleͷυϝΠϯ؅ཧαʔϏε • Whoisอޢ΋͋Δ • ҰԠ·ͩBETA • Ҡߦݩʹظݶ͕࢒͍ͬͯͨΒɺͦͷظݶ

    + 1೥ͷܖ໿ʹͳΔɺ΍͍͞͠ • Route 53ͰҠ؅ϩοΫΛղআͯ͠ɺҠߦਃ੥Λ͢Δ • AWSͷ࡞ۀʹɺ1ि͙ؒΒ͍͔͔ΔͷͰ஫ҙ
  23. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2 • Google Domains • Cloud Storage ( + Cloud CDN) • Cloud SQL • Cloud Run • Cloud Run • Cloud Run
  24. Cloud Storage • Google͕ఏڙ͢ΔΦϒδΣΫτετϨʔδ

  25. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2 • Google Domains • Cloud Storage ( + Cloud CDN) • Cloud SQL • Cloud Run • Cloud Run • Cloud Run
  26. Cloud SQL • ϑϧϚωʔδυϦϨʔγϣφϧσʔλϕʔεαʔϏε • Ұ൪খ͍͞ΠϯελϯελΠϓͷdb-f1-microͰɺ$9.96 • MySQL΋αϙʔτ͞Ε͍ͯΔ • ετϨʔδࣗಈ૿Ճ

    • ఆظతʹ1࣌ؒͷϝϯςφϯε͕ೖΔ͕࣌ؒ͸ࢦఆͰ͖Δ • 24࣌ؒಈ࡞͢Δ͜ͱΛอূ͢ΔαʔϏεͩͱݫ͍͔͠΋͠Εͳ͍
  27. NakamyΛࢧ͑Δٕज़ • Route 53 • S3 + Cloud Front •

    RDS • Certificate Manager • ELB • EC2 • Google Domains • Cloud Storage ( + Cloud CDN) • Cloud SQL • Cloud Run • Cloud Run • Cloud Run
  28. Cloud Run

  29. Cloud Run • ίϯςφΛαʔόϨεͰ࣮ߦ͢ΔαʔϏε • ࠷ۙBETA͕֎Εͨ • DockerͰಈ͔ͤΔ΋ͷͩͬͨΒಈ͘ • ΧελϜυϝΠϯ

    & SSLԽ͸Google DomainsʹυϝΠϯ͕͋Ε͹؆୯ • ΦʔτεέʔϦϯάͯ͘͠ΕΔ
  30. Cloud Run • ΞΫηε͕དྷͳ͚Ε͹ɺΠϯελϯε਺͕0ʹͳΔͷͰɺແྉ࿮ʹऩ·Δʢʁʣ

  31. ಈ͍ͨʂ

  32. අ༻͸Ͳ͏ͳ͔ͬͨ

  33. 5,000ԁ -> 1,500ԁఔ౓ʹͳͬͨ • ओʹDBͷඅ༻

  34. ͕ɺ͔͠͠՝୊͕͋ͬͨ

  35. Cloud RunͷΦʔτεέʔϦϯά͕ͤ͘΋ͷͩͬͨ • 1Πϯελϯε͋ͨΓ80ϦΫΤετࡹ͚Δ͕ɺϦΫΤετ਺ͷ૿Ճ཰Ͱ൑ఆ͍ͯ͠ ΔΑ͏ͰɺٸʹϦΫΤετ͕૿͑ΔͱϦΫΤετ਺͕গͳͯ͘΋ͲΜͲΜΠϯελ ϯεΛ૿΍ͦ͏ͱ͢Δ • ཪͰউखʹ૿΍͓͍ͯͯ͠ɺϔϧενΣοΫ͕௨ͬͨΒαʔϏεΠϯͯ͘͠ΕΕ͹ ͍͍ͷ͚ͩΕͲ΋ɺϨεϙϯεΛ଴্ཱͨͤͯͪ͛Δ࢓༷ͷ໛༷ •

    Rails͕ಈ࡞͢Δ؀ڥΛϓϩϏδϣχϯά͢Δʹ͸10ඵఔ౓͔͔ͬͯ͠·͏ͷͰɺ୆ ਺Λ૿΍͢λΠϛϯάͷϦΫΤετΛҾ͍ͨਓ͸͔ͳΓ଴ͨͤͯ͠·͏
  36. Cloud RunͷΦʔτεέʔϦϯά͕ͤ͘΋ͷͩͬͨ • ্ݶΛ1ʹ͓͚ͯ͠͹ɺͦΕҎ্εέʔϧ͠ͳ͍ͷͰ͸ʁ • ࢒೦ͳ͕Βɺͦ͏͍͏͜ͱ͸ͳ͘ʮRate exceeded.ʯΛฦͯ͠͠·͏ • ԼݶΛࢦఆͰ͖ΔͱճආͰ͖Δ͔΋͠Εͳ͍͕ɺݱঢ়͸ʮ؅ཧର৅ͷ Cloud

    Run Ͱ ͸ɺίϯςφ Πϯελϯεͷ࠷খ਺ͷઃఆ͸·ͩαϙʔτ͞Ε͍ͯ·ͤΜɻʯͱͷ ͜ͱ
  37. ࠓޙͲ͏͢Δ͔ • αʔϏεͱͯ͠ʮRate exceeded.ʯΛฦͯ͠͠·͏ͷ͸Ͳ͏ͩΖ͏͔ • ίϯςφͷαΠζΛݮΒ͢౒ྗΛͯ͠ΈΔʁGKEΛࢼͯ͠ΈΔʁ • HerokuͰྑ͍ͷͰ͸ʁ • ͦ΋ͦ΋Rails΍ΊΔʁRDBΛ΍ΊͯCloud

    FirestoreͳͲΛ࢖͏ߏ੒ʹ͢Δʁ • Έͳ͞ΜͲ͏͍ͯ͠Δͷ͔࠙਌ձͳͲͰ͓ฉ͔͍ͤͩ͘͞
  38. None
  39. ίϚʔγϟϧ - We are hiring !!!