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

kosen12sLT_4.pdf

 kosen12sLT_4.pdf

Shintani Teppei

March 30, 2019
Tweet

More Decks by Shintani Teppei

Other Decks in Technology

Transcript

  1. ϚΠΫϩαʔϏεԽͷϝϦοτ • ։ൃ࣌ʹߟ͑ͳ͍ͱ͍͚ͳ͍είʔϓ͕ڱ͘ͳΔ • “ਖ਼͘͠αʔϏεͷ੾Γ෼͚͕Ͱ͖Ε͹” ࣗ਎ͷαʔϏεͷ͜ͱ͚ͩΛߟ͑Ε͹Α͘ͳΔ • ো֐ͷ఻ൖͷ࠷খԽ • αʔϏε͝ͱʹαʔόʔΛىಈͤ͞ΔͷͰෆྀͷࣄނʹΑΓαʔόʔ͕ͪΐͬ͜ͱαʔόʔ͕མͪͨͱ

    ͯ͠΋”ਖ਼࣮͘͠૷͍ͯ͠Ε͹”αʔϏεશମͷμ΢ϯ͕໔ΕΔ • αʔόʔεϖοΫͷ࠷దԽ • αʔϏε͝ͱʹཁٻ͞ΕΔύϑΥʔϚϯε͕ҧͬͨΓ͢ΔͷͰ”ͪΌΜͱΠϯϑϥΛ؅ཧͰ͖ͯΕ͹”
 ʮ͜ͷαʔϏε͸ϝϞϦϚγϚγͰʯ͕؆୯ʹͰ͖Δ • CIͷߴ଎Խ • ଞαʔϏεͷॲཧ͸mockͯ͠ςετΛॻ͘ͷͰঢ়ଶͷֻ͚ࢉ͕ݮͬͯςετ͕؆ܿʹͳΔ • ਖ਼͘͠mock͢Δͷ͸ΊͪΌେม • Ϟμϯͳ։ൃΛͯͦ͠͏ͳงғؾ͕ग़Δ • ຊ౰͸͔ͳΓటष͍
  2. ஍ࠈͷ͓඼ॻ͖ ᶃ ؅ཧ͢Δαʔό૿͑Δ஍ࠈ ᶄ ϩάऩूͲ͏͢ΔΜͩ஍ࠈ ᶅ ࠷దͳݴޠͰ࣮૷ͨ͘͠ͳͬͯ͘Δ஍ࠈ ᶆ JOIN, τϥϯβΫγϣϯ,

    ֎෦ࢀর੍໿࢖͑ͳ͍஍ࠈ ᶇ ୤ϙϦϞʔϑΟοΫςʔϒϧ஍ࠈ ᶈ Ϩίʔυอଘ࣌ͷؔ࿈ςʔϒϧߋ৽callback֎͢஍ࠈ ᶉ Ҡߦظؒͷίʔυڞ༗Ͳ͏͢Δ͔஍ࠈ ᶊ ΫϥΠΞϯταΠυ͸Կͱ௨৴͢Ε͹͑͑Μ΍஍ࠈ ᶋ ͦ΋ͦ΋υϝΠϯڥքมΘΔ஍ࠈ ᶌ ϚΠΫϩαʔϏε෼͚͗ͯ͢͠·ͬͨ஍ࠈ 
 and many more…
  3. ᶃ ؅ཧ͢Δαʔό૿͑Δ஍ࠈ ͦΜͳ͋ͳͨʹɿInfrastructure as Code(IaC) • ϓϩϏδϣχϯάɺ֤αʔόͷཁٻੑೳΛશͯίʔυͰ؅ཧ͢Δ • →ଐਓԽΛͳ͘͢ •

    ࠷ۙΑ͘ฉ͘ͷ͸TerraformΛ࢖ͬͯk8s(GKE/EKS)΍ECSΛ؅ཧ͢Δ • ͜ͷลͷಋೖ͸ҰேҰ༦Ͱ͸·ͣແཧ • αʔό؅ཧʹΦʔφʔγοϓΛ࣋ͭΠϯϑϥΤϯδχΞ͸ඞਢ Terraform ɾɾɾ༗໊ͳΫϥ΢υαʔϏεΛڞ௨ͷॻ͖ํͰίʔυԽͰ͖Δπʔϧ k8s(kubernetes)ɾɾɾͨ͘͞Μͷdocker containerΛ͍͍ײ͡ʹ؅ཧ͢ΔϑϨʔϜϫʔΫ(OSS)
 GKE/EKS͸k8sͷSaaS ECS ɾɾɾEKSͱҧ͍͕෼͔ΒΜɻ୭͔ڭ͑ͯ΄͍͠
  4. ᶆ JOIN, τϥϯβΫγϣϯ, ֎෦ࢀর੍໿࢖͑ͳ͍஍ࠈ • DBΛ෼͚Δͱ͍͏͜ͱ͸ࠓ·ͰͷਓྨͷӥஐΛࣺͯΔͱ͍͏͜ͱ • ҟͳΔDBಉ࢜ͷJOIN͸Ͱ͖ͳ͍͠ɺτϥϯβΫγϣϯ΋షΕͳ͍ɺ
 ֎෦ࢀর੍໿΋࢖͑ͳ͍ •

    ͱ͸͍͑σʔλෆ੔߹Λى͜͢Θ͚ʹ΋͍͔ͳ͍ͷͰαʔϏεؒ௨৴ͷҝͷผͷ࢓૊Έ Λ༻ҙ͢Δඞཁ͕͋Δ • API callʁ HTTP஗Ԇ଴ͯͳ͘ͳ͍ʁ • ඇಉظॲཧʁ σʔλෆ੔߹ͷՄೳੑ͋ΔΑͶʁ • ͜͜͸ཁ݅ͱʹΒΊͬͯ͜͠ͲͪΒ͕ྑ͍ͷ͔൑அ͢Δඞཁ͕͋Δ • ஗Ԇ΋ͤ͞ΒΕͳ͍͠ෆ੔߹΋ࠔΔ௨৴͕͋Δ৔߹͸ಉҰαʔϏε಺ʹ
 ஔ͍͓͔ͯ͘͠ͳ͍
  5. ᶆ JOIN, τϥϯβΫγϣϯ, ֎෦ࢀর੍໿࢖͑ͳ͍஍ࠈ ͦΜͳ͋ͳͨʹɿؤு࣮ͬͯ૷ • ͜͜͸ؤுΔ͔͠ͳ͍ • ࣗ෼ͷͱ͜Ζͷ৔߹ •

    API call → Ϩεϙϯε͸JSONܗࣜͰ͸ͳ͘protobufܗࣜͰ௨৴ • ඇಉظॲཧ → Cloud Pub/SubΛ࢖ͬͯpub/subͰ΍ΓऔΓ • payloadͷserialize͸API callͱಉ༷ͷprotobufܗࣜͰߦͳ͍ͬͯΔ pub/subɾɾɾ1ݸͷpublisherͱNݸͷsubscriber͕ඇಉظతʹ΍ΓͱΓΛ͢Δ࢓૊ΈɻCloud Pub/Sub͸ͦͷSaaS
 protobufɾɾɾσʔλࣗମ͸όΠφϦͰૹ৴࣌/ड৴࣌ʹserialize/deserializeΛߦ͏ɻJSONͱͷҧ͍͸ܕ͕͍ͭͯΔ
  6. ᶈ Ϩίʔυอଘ࣌ͷؔ࿈ςʔϒϧߋ৽callback֎͢஍ࠈ • ͦΕͧΕͷϚΠΫϩαʔϏε͸ࣗ਎͕ΦʔφʔγοϓΛ͍࣋ͬͯΔςʔϒϧ͚ͩૢ࡞ͯ͠΄ ͍͠ • ਌Ϩίʔυ͕࡟আ͞ΕͨΒࢠϨίʔυ΋Ұॹʹ࡟আ͢Δ or ֎෦Ωʔͷͱ͜ΛNULLʹ͢Δ •

    Φʔφʔγοϓ֎ͷϨίʔυΛมߋ͍ͨ͠৔߹΋ଟʑ͋Δ • ී௨Ͱ͋Ε͹O/R mapper΍webϑϨʔϜϫʔΫ͕͍͍ײ͡ʹ΍ͬͯ͘ΕΔػೳΛ
 ࠶࣮૷͢Δඞཁ͕͋Δ ࣌ؒͳ͚Ε͹skip
  7. ᶈ Ϩίʔυอଘ࣌ͷؔ࿈ςʔϒϧߋ৽callback֎͢஍ࠈ • ͦΕͧΕͷϚΠΫϩαʔϏε͸ࣗ਎͕ΦʔφʔγοϓΛ͍࣋ͬͯΔςʔϒϧ͚ͩૢ࡞ͯ͠΄ ͍͠ • ਌Ϩίʔυ͕࡟আ͞ΕͨΒࢠϨίʔυ΋Ұॹʹ࡟আ͢Δ or ֎෦Ωʔͷͱ͜ΛNULLʹ͢Δ •

    Φʔφʔγοϓ֎ͷϨίʔυΛมߋ͍ͨ͠৔߹΋ଟʑ͋Δ • ී௨Ͱ͋Ε͹O/R mapper΍webϑϨʔϜϫʔΫ͕͍͍ײ͡ʹ΍ͬͯ͘ΕΔػೳΛ
 ࠶࣮૷͢Δඞཁ͕͋Δ ͦΜͳ͋ͳͨʹɿؤு࣮ͬͯ૷
  8. ᶉ Ҡߦظؒͷίʔυڞ༗Ͳ͏͢Δ͔஍ࠈ • ϚΠΫϩαʔϏεԽʹ͋ͨͬͯผϦϙδτϦʹίʔυΛҠ͍ͯ͘͠ඞཁ͕͋Δ • Ͱ΋ػೳ։ൃνʔϜ͸ΰϦΰϦػೳ࡞ͬͯΔͷͰҠͦ͏ʹ΋Ҡͤͳ͍ ͦΜͳ͋ͳͨʹɿ͕Μ͹Δ 1. ϞϊϦγοΫͳΞϓϦέʔγϣϯʹϚΠΫϩαʔϏεʹରԠ͢ΔॲཧΛߦ͏
 ΫϥεΛ࡞࣮ͬͯ૷ΛҠ͍ͯ͘͠(·ͩಉ͡ϦϙδτϦ)

    2. ϚΠΫϩαʔϏεʹରԠ͢ΔॲཧΛॻ͍ͨΫϥεΛڞ௨ϥΠϒϥϦԽ • ػೳ։ൃνʔϜ΋ͦͷϥΠϒϥϦʹมߋΛՃ͑ͯ΋Β͏Α͏ʹ͢Δ 3. ৽͘͠ϦϙδτϦΛ࡞Γڞ௨ϥΠϒϥϦΛ࢖ͬͯϚΠΫϩαʔϏεΛ࡞͍ͬͯ͘ 4. ϞϊϦε͔Βஈ֊తʹڞ௨ϥΠϒϥϦΛൈ͍͍͖ͯ࠷ऴతʹ͸ϥΠϒϥϦফ໓
  9. ᶊ ΫϥΠΞϯταΠυ͸Կͱ௨৴͢Ε͹͑͑Μ΍஍ࠈ ͦΜͳ͋ͳͨʹɿBackend For Frontend(BFF) • ΫϥΠΞϯτͱόοΫΤϯυͷதؒ؅ཧ৬తͳଘࡏ(proxy server) • ΫϥΠΞϯτ͔Βཉ͍͠৘ใͷϦΫΤετ͕ಧ͘ͱόοΫΤϯυ(ϚΠΫϩ

    αʔϏε)ʹ໰͍߹ΘͤͯΑ͠ͳʹσʔλΛऔ͖ͬͯͯ͘ΕΔ • ΫϥΠΞϯτ͸BFFͱ௨৴͢Δ͚ͩͰΑ͘ͳΔ • ΫϥΠΞϯτͱBFF͸GraphQLͰ΍ΓऔΓ͢Δ͜ͱ͕ଟ͍ؾ͕͢Δʁ GraphQLɾɾɾ୯ҰͷΤϯυϙΠϯτʹରͯ͠POSTΛߦ͍ɺbodyʹΫΤϦΛ෇༩͢Δ͜ͱʹΑΓཉ͍͠σʔλΛ
 ɹɹɹɹɹɹɹऔಘͰ͖ΔΑ͏ʹ͢Δ࢓૊ΈɻJSONͱҧͬͯܕ͕͍ͭͯΔͷ͕خ͍͠ɻ