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

Microservices Batch on GAE

Microservices Batch on GAE

Implement microservices architecture batch Scala program on Google AppEngine Standard Environment.

petitviolet

March 27, 2018
Tweet

More Decks by petitviolet

Other Decks in Programming

Transcript

  1. ("&Ͱ.JDSPTFSWJDFTͳόον΁ 'SJOHF$P -UE )JSPLJ,PNVSBTBLJ!QFUJUWJPMFU

  2. ࣗݾ঺հ w খࢵ߂و )JSPLJ,PNVSBTBLJ  w ΠϯλʔωοτͰ͸!QFUJUWJPMFU w αʔόαΠυΤϯδχΞ! w

    ͜ͷ೥͘Β͍͸͍͍ͩͨ4DBMBॻ͍ͯΔ
  3. ͜ͷลͷ࿩Ͱ͢

  4. ࠓ೔࿩͢͜ͱ࿩͞ͳ͍͜ͱ ࿩͢͜ͱ w ("& 5BTL2VFVF 4DBMBͰόονΛ࡞Δ࿩ w ओʹΞʔΩςΫνϟతͳઓུ ࿩͞ͳ͍͜ͱ w

    ("& 5BTL2VFVFͷࡉ͔͍࿩ w 4DBMBͷ࣮૷ςΫχοΫ
  5. ࠓ೔࿩͢͜ͱ࿩͞ͳ͍͜ͱ ࿩͢͜ͱ w ("& 5BTL2VFVF 4DBMBͰόονΛ࡞Δ࿩ w ओʹΞʔΩςΫνϟతͳઓུ ࿩͞ͳ͍͜ͱ w

    ("& 5BTL2VFVFͷࡉ͔͍࿩ w 4DBMBͷ࣮૷ςΫχοΫ
  6. όονʁ

  7. όονʁ ϓϩάϥϜ܈Λॲཧ໨త͝ͱʹ۠੾Γɺ͜ͷ۠੾ Γຖʹॱ࣮࣍ߦͯ͠Ώ͘ॲཧͷ͜ͱ XJLJQFEJB  ཁ͢ΔʹɺԿ͔͠ΒͷॲཧΛॱ࣮࣍ߦ͢Δ͜ͱ

  8. όονͷ͋Δ͋Δ Α͋͘Δ৚݅͸ҎԼͷΑ͏ͳ΋ͷ w ఆظ࣮ߦ DSPO  w σʔλΛཷΊͯ·ͱΊͯॲཧ w FUD

  9. όον΁ͷΘ͕·· w ىಈ࣌Ҏ֎͸͓͔͚ۚͨ͘ͳ͍ w ίέͨΒࣗಈͰϦτϥΠ͍ͨ͠ w σʔλ͕૿͑ͨΒΦʔτεέʔϧ͍ͤͨ͞

  10. ͦΕɺ("&Ͱग़དྷΔΑ

  11. ("& w (PPHMF"QQ&OHJOF w ͍ΘΏΔ1BB4 w \4UBOEBSE 'MFYJCMF^&OWJSPONFOUͷछྨ w 4&͸੍ݶ͕ݫ͍͕͠ӡ༻͸͓೚ͤ

    w '&͸੍ݶ͕؇͍͕ӡ༻͸΍΍खಈ
  12. ("& ϑϨΩγϒϧ؀ڥ͸ɺελϯμʔυ؀ڥΛิ׬͢ Δ͜ͱΛ໨తͱ͍ͯ͠·͢ɻ IUUQTDMPVEHPPHMFDPNBQQFOHJOFEPDTqFYJCMFKBWBqFYJCMFGPSTUBOEBSEVTFST IMKB جຊ͸4&Λݕ౼͠ɺμϝͬΆ͍ͳΒ'&ʹ͢Δ

  13. ("& ϑϨΩγϒϧ؀ڥ͸ɺελϯμʔυ؀ڥΛิ׬͢ Δ͜ͱΛ໨తͱ͍ͯ͠·͢ɻ IUUQTDMPVEHPPHMFDPNBQQFOHJOFEPDTqFYJCMFKBWBqFYJCMFGPSTUBOEBSEVTFST IMKB جຊ͸4&Λݕ౼͠ɺμϝͬΆ͍ͳΒ'&ʹ͢Δ ΠϯελϯελΠϓͰεέʔϧઓུΛม͑ΒΕΔ w BVUPNBUJDҰ൪͓೚ͤͰ("&ͬΆ͍ w

    CBTJDόονͱ͔ w NBOVBMखӡ༻Ͱ*BB4دΓ
  14. όον΁ͷΘ͕·· w ىಈ࣌Ҏ֎͸͓͔͚ۚͨ͘ͳ͍ w ("&4&ͳΒ࣮ߦ࣌ؒ՝ۚ w ίέͨΒࣗಈͰϦτϥΠ͍ͨ͠ w  w

    σʔλ͕૿͑ͨΒΦʔτεέʔϧ͍ͤͨ͞ w
  15. 5BTL2VFVF

  16. 5BTL2VFVF w ("&ɺಛʹ4&Ͱ؆୯ʹ࢖͑ΔδϣϒΩϡʔ w \1VTI 1VMM $SPO^Ωϡʔͷछྨ͋Δ w ("&αʔϏεؒͷ࿈ܞʹ1VTIΩϡʔ͕ඇৗʹศར w

    DSPO΋͋ΔͷͰόονͷىಈ΋؆୯ w εςʔλε͕YYͱ͔ͳΒϦτϥΠͯ͘͠ΕΔ
  17. 5BTL2VFVF w ઃఆ΋ൺֱత୯७Ͱ؆୯ʹ࡞੒Մೳ w ͜Μͳײ͡ ˡϦτϥΠճ਺ͷ্ݶ ˡλεΫͷੜଘ࣌ؒ

  18. όον΁ͷΘ͕·· w ىಈ࣌Ҏ֎͸͓͔͚ۚͨ͘ͳ͍ w ("&4&ͳΒ࣮ߦ࣌ؒ՝ۚ w ίέͨΒࣗಈͰϦτϥΠ͍ͨ͠ w 5BTL2VFVFʹϦτϥΠػೳ͕͋Δ w

    σʔλ͕૿͑ͨΒΦʔτεέʔϧ͍ͤͨ͞ w
  19. όον΁ͷΘ͕·· w ىಈ࣌Ҏ֎͸͓͔͚ۚͨ͘ͳ͍ w ("&4&ͳΒ࣮ߦ࣌ؒ՝ۚ w ίέͨΒࣗಈͰϦτϥΠ͍ͨ͠ w 5BTL2VFVFʹϦτϥΠػೳ͕͋Δ w

    σʔλ͕૿͑ͨΒΦʔτεέʔϧ͍ͤͨ͞ w σʔλগ σʔλଟ
  20. ΦʔτεέʔϧʹΉ͚ͯ w εέʔϧΞοϓ͍ͨ͠ w ("&ͩͱࣗಈͰ͸ग़དྷͳ͍ w εέʔϧΞ΢τ͍ͨ͠ w ("&͸ϦΫΤετ਺૿ͰεέʔϧΞ΢τ w

    σʔλ਺͕૿͑ΔͱϦΫΤετ਺͕૿͑ΔΑ͏ ʹ࣮૷͢Δ
  21. ΦʔτεέʔϧʹΉ͚ͯ w εέʔϧΞοϓ͍ͨ͠ w ("&ͩͱࣗಈͰ͸ग़དྷͳ͍ w εέʔϧΞ΢τ͍ͨ͠ w ("&͸ϦΫΤετ਺૿ͰεέʔϧΞ΢τ w

    σʔλ਺͕૿͑ΔͱϦΫΤετ਺͕૿͑ΔΑ͏ ʹ࣮૷͢Δ
  22. 4DBMBͱ("&

  23. 4DBMBͱ("& w 'SJOHFͰ͸αʔόαΠυ։ൃʹ4DBMBΛΑ͘࢖͏ w ("&4&ͷ+BWBରԠ͸೥݄ w IUUQTDMPVEQMBUGPSNHPPHMFCMPHDPN+BWBPO"QQ&OHJOF4UBOEBSEFOWJSPONFOUJTOPXHFOFSBMMZBWBJMBCMFIUNM w 4&Ͱ+BWB͕ಈ͚͹4DBMB΋ಈ͘ʂ

  24. 4DBMBͰόονॲཧ w 4DBMB͸ඇಉظॲཧ΍ϧʔϓॲཧ͕هड़͠΍͘͢ɺ όονͰ͋Γ͕ͪͳॲཧΛ؆୯ʹॻ͚Δ w 'VUVSFͱ-JTUNBQͷΑ͏ͳ"1*Λ࢖͏ val targets: List[Data] =

    ??? val resultFutures: List[Future[Result]] = targets map { target => Future { execute(target) } // 何か重い処理を非同期で実行 } val results: Future[List[Result]] = Future.sequence(resultFutures)
  25. ͜͜Ͱ໰୊ൃੜ w ("&4&͸γϯάϧίΞ w ඇಉظॲཧͷޮՌ͕ബ͍ w '&ʹͯ͠ϚϧνίΞʹ͢Δʜ

  26. ίΞ͕଍Γͳ͚Ε͹ ϚγϯΛ૿΍ͤ͹͍͍͡Όͳ͍

  27. 5BTL2VFVFΛ࢖ͬͯίΞΛ૿΍͢ ϚϧνίΞγϯά ϧίΞ ϚϧνΠϯελϯε w ඇಉظॲཧΛλεΫͱͯ͠5BTL2VFVF΁QVU͢Δ w \ಉ͡ ผͷ^("&αʔϏεͰड͚औͬͯඇಉظॲཧ w

    ϧʔϓॲཧ΋ҰͭͣͭผͷλεΫʹ͢Δ 5BTL2VFVF
  28. େ͖ͳόονॲཧΛ খ͞ͳλεΫʹ෼ׂͯ͠ ඇಉظʹॲཧ͢Δ

  29. ·͞ʹ.JDSPTFSWJDFT

  30. ͪͳΈʹ ("&4&ͩͱϝϞϦͷ࠷େαΠζ͕(#ͳͷͰɺ Լखʹେ͖ͳόονΛಈ͔͢ͱ؆୯ʹ00.͕ى ͖ΔͷͰɺόονΛখ͘͞෼ׂͤ͟ΔΛ͑ͳ͍ σʔλଟ

  31. .JDSPTFSWJDFTͳόον όονॲཧΛ෼ׂͯ͠ޙଓͷॲཧ΁͸5BTL2VFVF Λ࢖ͬͯܨ͙ 5BTL2VFVF ॲཧର৅ͷ ҰཡΛऔಘ Ұͭͣͭ ॲཧ͢Δ ͞Βʹࡉ͔͘ ॲཧ͢Δ

    ଴ͪ߹Θͤͯ ΫϦʔϯΞοϓ ʜ ʜ
  32. όον΁ͷΘ͕·· w ىಈ࣌Ҏ֎͸͓͔͚ۚͨ͘ͳ͍ w ("&4&ͳΒ࣮ߦ࣌ؒ՝ۚ w ίέͨΒࣗಈͰϦτϥΠ͍ͨ͠ w 5BTL2VFVFʹϦτϥΠػೳ͕͋Δ w

    σʔλ͕૿͑ͨΒΦʔτεέʔϧ͍ͤͨ͞ w ࡉ͔͘λεΫʹ੾Γ෼͚ͯεέʔϧΞ΢τ 5BTL2VFVF
  33. ·ͱΊ 4DBMBͰॻ͍ͨόονΛ ("&4&Ͱಈ͔͢ͱ޾ͤʹͳΕΔ