"Microservices" is dead. Long live "Microservices". #ginzarails

942bb606679caf4c57b38927f83178e1?s=47 qsona
December 21, 2018

"Microservices" is dead. Long live "Microservices". #ginzarails

銀座Rails #4

942bb606679caf4c57b38927f83178e1?s=128

qsona

December 21, 2018
Tweet

Transcript

  1. "Microservices" is dead.
 Long live "Microservices". @qsona / FiNC Technologies

    Inc. 2018-12-21 ۜ࠲Rails#4 @ϦϯΫΞϯυϞνϕʔγϣϯ #ginzarails
  2. "Microservices fundamentalism" is like abstinence-only sex ed: ϚΠΫϩαʔϏεݪཧओٛ͸ɺېཉͷΈ͔ΒͳΔੑڭҭͷΑ͏ͩɻ

  3. Over the years, the "Microservices rhetoric" got louder and angrier.

    More mean-spirited. ௕೥ʹΘͨͬͯɺϚΠΫϩαʔϏεͷϨτϦοΫ
 (੣࣮͞ͷͳ͍ඒࣙྷ۟)͸ɺ ͏Δ͘͞ɺౖΓͬΆ͘ɺڱྔʹͳ͖ͬͯͨɻ
  4. ͜Ε͸ͳʹ • TDD is dead. Long live testing. (by DHH)


    ͱ͍͏໊ΤϯτϦͷվม • ͝ଘ͡ͳ͍ํ͸
 ςετۦಈ։ൃ
 ෇࿥CΛඞಡʂ
  5. Θͨ͠͸ͩΕ • @qsona, ϚΠΫϩαʔϏεԺ݈೿

  6. Microservices ݪཧओٛʁ

  7. ྫ: ίϯ΢ΣΠͷ๏ଇ • ૊৫ͷߏ଄ͱٕज़ͷߏ଄͸Ұக͍ͯ͘͠ɺͱ ͍͏๏ଇ

  8. ίϯ΢ΣΠͷ๏ଇݪཧओٛ • 1αʔϏεɾ1νʔϜ͡Όͳ͍ͱͩΊ • ૊৫ΛׂΒͳ͍ͳΒɺαʔϏεΛׂΔҙຯ͸ ͳ͍ • 100ਓҎ্ͷ૊৫͡Όͳ͚Ε͹΍ͬͪΌͩΊ

  9. ※ಉ྅Ͱ͢(@ota42y͞Μ)

  10. (ͪͳΈʹ಺༰͸͍͍ͩͨಉҙ) it depends... agree

  11. Microservices ݪཧओٛ...? • গͳ͘ͱ΋ Martin Fowler ΍ Sam Newmanͷ ͜ͱͰ͸ͳ͍

    • ൴Βͷൃ৴͸ɺͱͯ΋ͱͯ΋੣࣮ • Ұ෦Λ੾Γऔ֦ͬͯେղऍ͠ɺڧ͗͢Δൃ৴ ͕ͳ͞ΕΔ͜ͱ͕͋Δ
  12. qsonaͷॴײ • શͯͷڧ͍ҙݟ (ݪཧओٛ) ͸ɺ͋ΔίϯςΩετΛ ݩʹൃ৴͞ΕΔ • ࣮ࡍͷݱ৔Λࢧ͑ΔΞϓϦέʔγϣϯΤϯδχΞͷ ࢹ఺͸ɺஔ͍͚ͯ΅Γʹ͞Ε͍ͯΔΑ͏ʹײ͡Δ •

    ࠷ۙɺϚΠΫϩαʔϏεͱ͍͏ݴ༿Λൃ͢Δͷ͕͸ ͹͔ΒΕΔΑ͏ʹͳͬͨ...
  13. qsonaͷॴײ • "counterintuitive ram" (௚ײʹ൓͢Δഁ৓Ṁ) ͱͯ͠ɺݱঢ়Λม͑ΔͨΊʹɺݪཧओٛతͳ ҙݟΛڣͿɺͱ͍͏͜ͱ͸͋Δ͕.... • Microservices ʹ͓͍ͯɺͦ͏͍͏ϑΣʔζ͸

    ੈքతʹݟͨΒͱͬ͘ʹա͗ڈ͍ͬͯΔ
  14. qsonaͷॴײ • ίϯ΢ΣΠͷ๏ଇݪཧओٛͰ͍͏ͱ... • ٕज़ͱಉ༷ɺ૊৫΋΍͸Γ໨తͰ͸ͳ͍ • ٕज़ͱ૊৫ͷ྆ྠͰɺϏδωεɾϓϩμΫτʹ޲͖߹͍ͬͯ͘΋ ͷ • ٕज़ͷϦΞʔΩςΫτʹ͸͕͔͔࣌ؒΔ

    • αʔϏεͷ୯Ґ = ૊৫ ͕ৗʹ੒Γཱͭ΄ͲϏδωε͸୯७Ͱ͸ͳ͍ • ݪཧओٛతओு͸ɺݱ৔ͷ໰୊ͱઓ͏ਓʹ͸ڹ͔ͳ͍
  15. What is "Microservices" ? • ҰݴͰ͸આ໌Ͱ͖ͳ͍͠ɺ໌֬ͳఆٛ΋ͳ͍ • ίϯηϓτͷू߹ͱɺपลͷΤίγεςϜͱ ͯ͠ଊ͑ͯ΄͍͠

  16. "Microservices" as a Concept • ϏδωευϝΠϯͰαʔϏεΛ෼ׂ͢Δ͜ͱ • αʔϏεͷ౷߹ʹ͸ඪ४ͷٕज़Λ࢖͏͜ͱ • ୯Ұ੹೚ݪଇɺૄ݁߹ͱߴڽूɺetc

    • ϚΠΫϩαʔϏεͷʮྑ͞ʯΛ୲อ͢ΔྖҬ • ॳग़͔Βશ͘มΘ͍ͬͯͳ͍
  17. "Microservices" as an Ecosystem • Docker, Kubernetes, ECS / GKE

    • CI/CD πʔϧ • Envoy, Service Mesh (Istio, AWS App Mesh) • ϚΠΫϩαʔϏεͷʮσϝϦοτʯΛফ͢ྖҬ • ೥ʑਐԽ͍ͯ͠Δ
  18. Concept & Ecosystem • ίϯηϓτΛ஌Γɺඞཁͳͱ͖ʹऔΓೖΕΔ͜ͱͰɺϝ ϦοτΛڗड͠ɺ • ΤίγεςϜʹ͏·͘৐Δ͜ͱͰɺ
 σϝϦοτΛݮΒ͢ •

    ͦ͏͍͏͏·͍෇͖߹͍ํΛ͢Ε͹ɺϚΠΫϩαʔϏε ͸ΈΜͳͷຯํʹͳΔ • ͱ͍͏ओுΛ͜Ε͔Β͍͖͍ͯͨ͠
  19. গ͠୤ઢ

  20. Q. Mircoservices Λ΍ͬͪΌ͍ ͚ͳ͍ձࣾ͸ʁ • ͳ͍…ͱ͍͍͍͕ͨɺ͋Δ͔΋͠Εͳ͍ • ௒ελʔτΞοϓͰ • ·ͩϓϩμΫτΛϩʔϯνͯ͠ͳͯ͘

    • ΤϯδχΞ͸ֶੜ͚ͩ...
  21. None
  22. None
  23. FiNC ❤ Microservices • "ϚΠΫϩαʔϏε" ͱ͍͏ݴ༿Λ஌Βͳ͍͏ͪ ͔ΒϚΠΫϩαʔϏεΛࢦ޲͍ͯͨ͠ • ʮҰੜʹҰ౓ͷ͔͚͕͑ͷͳ͍ਓੜΛαϙʔτ ͢ΔʯͨΊͷ

    Microservices Λ΍Γ͍ͨਓ͸੠ Λ͔͚ͯ΄͍͠ • We are hiringɺਅ݋ʹ࠾༻΍ͬͯ·͢
  24. શͯͷձ͕ࣾͦ͏Ͱ͸ͳ͍ • ՝୊ͷઃఆ͸༷ʑɺ໨త΋༷ʑ • ਎ۙͳ໰୊Λղܾ͢Δձࣾ΋͋Δ • খ͞ͳϓϩμΫτΛ࡞Γଓ͚Δձࣾ΋͋Δ • ͦ͏͍͏ձࣾ΍ΤϯδχΞʹͱͬͯɺ
 Microservices

    ͸ແԑͳͷ͔ʁ
  25. To be continued...

  26. Rails and Microservices • Rails ͔ΒݟΔͱɺ Microservices ͸
 ࣗ෼ͱ͸ҧ͏ྖҬͷ໰୊Λղܾ͢Δଘࡏ •

    Rails ʹ଍Γͳ͍ͱ͜ΖΛ
 Microservices Ͱิ׬Ͱ͖Δ
  27. ͓·͔ͤ vs ΞϥΧϧτ

  28. Easy vs Simple ;ͭ͏ͷRailsΞϓϦέʔγϣϯ։ൃ, Takafumi ONAKA https://www.slideshare.net/takafumionaka/rails-77195340

  29. "Easy" is Difficult. • Easy Λҡ࣋͢Δͷ͸Ή͔͍ͣ͠

  30. Is Rails "Easy"? • Rails ͸ͲΜͳ໰୊ʹର͢Δ౴͑Λ༻ҙͯ͠Δ Θ͚Ͱ͸ͳ͍ • ͦΜͳສೳͳEasy͸ଘࡏ͠ͳ͍

  31. Rails ͱ େن໛։ൃ

  32. Rails ͱ େن໛։ൃ • جຊతʹ͸ "தن໛" ·ͰͷΞϓϦέʔγϣϯ Λߴ଎ʹ࣮૷͢Δͷʹ޲͍͍ͯΔ • େن໛ʹͳΔͱ೉͘͠ͳΔଆ໘͋Γ

    • ੩తܕ෇͚, ϞδϡʔϧԽ, Dependency Injection, Event sourcing ͷ࢓૊ΈͳͲ͸ͳ͍
  33. Rails Λ֦ு͢Δʁ • Service Object, Form Object • Decorator •

    Trailblazer • ...
  34. Rails Λ֦ு͠ͳ͍ • ͋Δఔ౓ͷൣғ·Ͱ͸ Rails ( + PlainͳΫϥ ε )

    Ͱ͏·͘΍Γ • Rails Ͱ͏·͘΍ΕΔൣғΛӽ͖͑ͯͨΒɺ αʔϏεΛ෼ׂ͍ͯ͘͠ɺͱ͍͏ߟ͑ํ
  35. ྫ: Πϕϯτιʔγϯά • ୯ҰͷRailsαʔϏε಺ͰΠϕϯτιʔγϯά ͢ΔͱɺͦΕͳΓʹ໰୊͕ى͖΍͍͢ • ActiveRecordͷcallbackΛ࢖͏ͱɺҙਤͤͣ ʹൃಈ͢Δ໰୊͕ى͖͕ͪ • transaction

    ͷൣғ͸ʁ
  36. Ұͭͷߟ͑ํ • ୯ҰͷRailsαʔϏε಺Ͱ͸ɺΠϕϯτιʔγϯά͠ͳ͍ (callback͸͘͝ݶఆత༻్Ͱ) • ͦͷ͔ΘΓɺ୯ҰαʔϏε಺ͷtransaction͸୲อ͢Δ • ෳ਺αʔϏεؒ͸Πϕϯτιʔγϯά͠ɺ݁Ռ੔߹ੑΛ ୲อ͢Δ •

    ྫ͑͹ GCPͷ Cloud Pub/Sub ࢖͏
  37. ϝϦοτΛड͚Δ͜ͱͱɺ σϝϦοτ΁ͷରॲ • ݸผσϓϩΠ, ো֐ہॴԽ, ݸผεέʔϦϯά ͳͲͷԸܙΛಉ࣌ʹड͚Δ • ෼ࢄΩϡʔ, ෼ࢄτϨʔγϯά,

    etc... ͷۤ͠Έ Λड͚Δ • ͜ΕΛࢧ͑ΔΤίγεςϜ͸ݱࡏඇৗʹ੝Γ ্͕͍ͬͯΔ
  38. Rails ͱ γεςϜ෼ׂ

  39. γεςϜ෼ׂͷ؍఺ • جຊతʹRailsαʔϏε͕Ͱ͔͘ͳΔͱਏ͍ͷͰɺԿ Β͔ͷ෼ׂͨ͘͠ͳΔ (ͱ͜͜Ͱ͸Ծఆ͢Δ) • ٕज़తͳ؍఺ʹԊͬͯ෼ׂ͢Δਓ͕ଟ͍ • ؅ཧը໘Railsɺόον༻Railsɺetc... •

    ϚΠΫϩαʔϏεͰ͸ɺϏδωευϝΠϯʹͦͬͯ ෼ׂ͢Δ
  40. Α͋͘ΔγφϦΦ • αʔϏεͷϦϦʔεͱ؅ཧը໘ͷϦϦʔε͸෼཭͍ͨ͠ Ͷɾɾɾ • ؅ཧը໘༻ͷRails͕ര஀ • Shared Database Pattern

    ΍ Shared ORM Pattern (෼அ͞ ΕͨϞϊϦε) • ςʔϒϧͷεΩʔϚมߋͳͲ͕͓ޓ͍ʹӨڹ͢ΔΑ͏ʹ ͳͬͯਏ͍
  41. Α͋͘ΔγφϦΦ • ؅ཧը໘Λ෼཭͍͚ͨ͠Ͳɺڞ༗DB͸Ξϯν ύλʔϯͩΑͶɾɾɾ • ؅ཧը໘͸Single Page AppͰ࡞Δ • ؅ཧը໘޲͚ͷAPIΛ͕Μ͹ͬͯ։ൃ͢Δ

    • ͦΕ͸ Rails ΤϯδχΞͷຊ๬ͩͬͨͷ͔...?
  42. Rails ͷྑ͞Λੜ͔͍ͨ͠ • View·ͰαΫοͱศརʹ࡞ΕΔͷ͕Railsͷྑ ͞͡Όͳ͍͔ • ؅ཧը໘ΛSPAʹ෼཭ͱ͔ɺࢷΛམͱͨ͠ ύοαύαͷRailsͰ͸...

  43. ϏδωευϝΠϯͰ෼ׂ͠Α͏ • ϏδωευϝΠϯͷڥքΛݟ͚ͭΑ͏ • Domain-Driven Design ͷग़൪ • ͦͷڥքʹԊͬͯ෼ׂ͠Α͏ •

    ͦͷ͔ΘΓɺ؅ཧը໘·Ͱ֤αʔϏεͰఏڙ ͠Α͏
  44. ؅ཧը໘ͷ౷߹͸ʁ • ͜ͷํ๏ʹ͢Δͱɺ؅ཧը໘͕ࢄΒ͹Δ • ΞΧ΢ϯτ • σʔλͷ౷߹ • UIͷ౷߹/౷Ұײ

  45. ΞΧ΢ϯτͷ౷߹ • SAML ౳ͷඪ४ٕज़Λར༻ͨ͠ Single Sign-onΛ࣮૷ ͢Δ (language-agnostic) • ͦͷ্ͰɺRailsʹ޲͚ͨศརͳํ๏΋༻ҙ͢Δ

    • ྫ͑͹ɺ Rails Engine ͷgemΛಋೖ͢Δ͚ͩͰͰ͖ ΔΑ͏ʹ͢Δ • ඪ४ + ศརϥΠϒϥϦͷೋஈߏ͑
  46. σʔλͷ౷߹ • લఏͱͯ͠ɺσʔλΛ౷߹ͯ͠ѻ͏͜ͱʹ͸ σϝϦοτ΋͋Δ • ݸਓͷηϯγςΟϒͳ৘ใͷΞΫηείϯ τϩʔϧ͕೉͘͠ͳΔ

  47. σʔλͷ౷߹ • ࠷௿ݶͷ৘ใ͸APIͰ࿈ܞ͢Δ • ৔߹ʹΑͬͯ͸ڞ༗DB (֎͔Β͸ Read Only) • εΩʔϚมߋͰ؅ཧը໘͕յΕΔՄೳੑ͕

    ͋Δ͕ɺ਺೔ͷμ΢ϯλΠϜ͕ڐ͞ΕΔͳ ΒͦΕͰ΋͍͍
  48. UIͷ౷߹ • ϦϯΫू΍ɺڞ௨ͷϔομʔ͕͋Ε͹ڐ͞Ε ΔͳΒͦΕͰ͍͍ • ແཧͯ͠౷߹͢Δͱେม • ෳ਺ͷαʔϏεͷίϯϙʔωϯτΛɺ΋ͬͱ ߴ౓ʹ౷߹ɾ࿈ܞ͍ͯ͘͠ʹ͸ɾɾɾʁ

  49. Micro Frontends • ͜ͷಓΛಥ͖٧Ί͍ͯ͘ͱ Micro Frontends
 ͱ͍͏ΞʔΩςΫνϟʹͳ͍ͬͯ͘ • ֤αʔϏε͕ Web

    Components Λఏڙ͠ɺ
 ౷߹ϨΠϠʔ͕ͦΕΒΛ഑ஔ͢Δ • ֤Component͸ΠϕϯτͳͲͰڠௐͯ͠ಈ͘
  50. None
  51. None
  52. ྲྀΕͷ͓͞Β͍ • ϏδωευϝΠϯͰ෼ׂ͢Δ (ίϯηϓτ) • αʔϏε෼ׂΛߦ͍ͳ͕Β΋ɺ
 ؅ཧը໘͕؆୯ʹͭ͘ΕΔ (ϝϦοτ) • ؅ཧը໘ͷମݧ౳͕෼ׂ͞ΕΔ

    (σϝϦοτ) • ؅ཧը໘ͷ౷߹ΛɺඞཁʹԠͯ͡
 ஈ֊తʹߦ͍ͬͯ͘ (ΤίγεςϜͷࢧԉ)
  53. ఻͍͑ͨ͜ͱ • ʮϏδωευϝΠϯͰ෼ׂ͢Δʯ
 = ίϯηϓτ • ͦΕʹΑΓϝϦοτ͕ಘΒΕΔ • ͦͷίϯηϓτͷ΋ͱʹΤίγεςϜ͕ൃల ͠ɺಓ͸੔උ͞Ε͍ͯ͘

  54. FiNC ❤ Micro Frontends • Micro Frontends ͷಓ͸զʑ͕ઌಋ͢Δ • ຊ౰ʹඞཁͱ͍ͯ͠Δ͔Β΍Δ

    • ΋ͪΖΜɺ୭΋͕ඞཁͱ͢ΔΞʔΩςΫνϟͰ ͸ͳ͍ • େࣄͳͷ͸ɺઌʹਐΈ͍ͨͱ͖ͷಓ͕͋Δ͜ͱ
  55. ͔͜͜Β͸ࡶଟͳ࿩

  56. Rails ͱ Ϋϥ΢υαʔϏε

  57. Rails ͱ Ϋϥ΢υαʔϏε • Web αʔϏεͷकඋൣғͷ֦େ • ྫ͑͹ IoT ͷձࣾ

    => AWS IoT ͱͦͷपลͷ ϚωʔδυαʔϏεΛϑϧ׆༻͍ͨ͠ • ͚ͩͲɺWebαʔϏε΍ϞόΠϧΞϓϦ޲͚ API͸ Rails Ͱఏڙ͍ͨ͠
  58. ΞʔΩςΫνϟͷҰྫ • Web αʔϏε͸ Rails • AWS ޲͚ʹ͸ Serverless Framework

    Λར༻͢Δ • ࣮ଶͱͯ͠͸ AWS Lambda ʹσϓϩΠ͞ΕΔ • ϝϦοτ • Web API ΍ SNS/SQSͰͷΠϕϯτͳͲɺ࿈ܞΛ͢Δͷ͕؆୯ʹग़དྷΔʂ • AWS IoT ΍ DynamoDB ͳͲͷ௿ϨϕϧͳίϯϙʔωϯτΛ Rails ͕ҙࣝ ͠ͳ͍Ͱྑ͘ͳΓɺૄ݁߹ʹͳΔ
  59. ٕज़ҟ࣭ੑ / Language-agnostic

  60. Language-agnostic • ϓϩάϥϛϯάݴޠʹඇґଘͳٕज़બఆ • ྫ: Sidecar Pattern (Envoy ͳͲ)

  61. "ඪ४"΁ͷҙࣝ • ݴޠඇґଘͳ෦෼Λଟ͘࢒͢બ୒
 => ٕज़ͷඪ४ੑʹҙ͕ࣝ޲͘ • ٕज़બఆʹ͓͚Δɺࢹ఺ͷ޿͕Γ

  62. ྫ: Web API ࢓༷ • Web API ΛͲͷΑ͏ͳܗࣜͰఏڙ͢Δ͔? • RESTful

    + JSON + OpenAPI • RESTful + ಠࣗϑΥʔϚοτ + JSON + Open API • JSON API (RESTfulͳAPIͷҰͭͷ࢓༷) • Netflix/fast_jsonapi : JSON API ܗࣜΛαϙʔτ͢Δgem • GraphQL + JSON • gRPC + Protocol Buffers
  63. ྫ: Web API ࢓༷ • ΋ͪΖΜɺ།Ұͷ౴͑͸ͳ͍͕… • ͲͷΑ͏ͳࢹ఺Λ΋ͬͯબఆ͢Δ͔ • ໨ͷલͷ՝୊ʹରॲ͢Δ͜ͱ͸ɺ


    ΋ͪΖΜେࣄ͕ͩ • ଞݴޠͰ΋࣮૷Ͱ͖Δ͔ʁͱ͍͏ࢹ఺Λ΋ͭ
  64. ྫ: Web API ࢓༷ • RESTful + OpenAPI ͳΒɺ࠷ѱOpenAPI͕ඇରԠͷݴޠΛ ࢖ͬͯ΋μϝʔδ͕গͳ͍

    • ಠࣗϑΥʔϚοτ΍ࣗલϥΠϒϥϦΛఆٛ͗͢͠Δͱɺଞͷݴ ޠʹߦͬͨͱ͖ʹ͖͍ͭΑͶ.. • JSON API, GraphQL, gRPC • ίϛϡχςΟͷαϙʔτঢ়گ͸Ͳ͏͔ʁ • ࠷ѱɺࣗ෼Ͱ࣮૷ͨ͠ΓOSSߩݙͰ͖ΔϨϕϧ͔ʁ
  65. "ඪ४" ΁ͷؔ৺ • ඪ४Խ΍ίϛϡχςΟαϙʔτʹର͢Δؔ৺ ͸ɺٕज़తͳ੒௕Λଅ͢ɺͱ͍͏Ծઆ

  66. ·ͱΊ

  67. ·ͱΊ • ·ͱ·Γ·ͤΜͰͨ͠ɺ͝ΊΜͳ͍͞ • ׬શͳΔྗྔෆ଍ • ࿦ཧͷཪ෇͚΋গͳ͔ͬͨ... • λΠτϧͰ௼ͬͯ͢Έ·ͤΜͰͨ͠...͢Έ·ͤ Μ͢Έ·ͤΜ...

  68. ݴ͍͔ͨͬͨ͜ͱ • "ϚΠΫϩαʔϏε" ͱ͍͏ݴ༿ʹଉۤ͠͞Λײͨ͘͡ͳ ͍ɾײͯ͡΄͘͠ͳ͍ • RailsΤϯδχΞʹ "ࣗ෼ʹ͸ϚΠΫϩαʔϏε͸ؔ܎ͳ͍" ͳΜͯࢥͬͯ΄͘͠ͳ͍ •

    খ͞ͳ૊৫Ͱ΋ϚΠΫϩαʔϏεΛҙ͍͍ࣝͯ͠ • "ϚΠΫϩαʔϏε΍ͬͯ·͢" ͬͯݴͬͨΒୟ͔ΕΔੈͷ த͸·ͬͽΒͩ
  69. ݴ͍͔ͨͬͨ͜ͱ • ίϯηϓτΛཧղ͠ɺ͏·͘औΓೖΕΔͱ͜ Ζ͔Β࢝ΊΑ͏ • ΤίγεςϜΛ஌Γɺ
 ͏·͘৐Γ͜ͳͦ͏

  70. "Microservices" Everywhere.