Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
"Microservices" is dead. Long live "Microservic...
Search
qsona
December 21, 2018
Technology
0
760
"Microservices" is dead. Long live "Microservices". #ginzarails
銀座Rails #4
qsona
December 21, 2018
Tweet
Share
More Decks by qsona
See All by qsona
サーバー間 GraphQL と webmock-graphql の話 / server-to-server graphql and webmock-graphql
qsona
4
350
Backend エンジニア視点からの GraphQL / GraphQL from a perspective of backend engineer
qsona
28
8.1k
3 Practices about Service-to-Service GraphQL Ruby Client
qsona
1
830
いかにして GraphQL を組織に導入するか (新規開発編) / how we introduce GraphQL on scratch development
qsona
6
3.9k
Well-organized Transaction Script - リファクタリングの妥協的手法 -
qsona
4
1.3k
GraphQL と Prisma から考える次のN年を見据えた技術選定 / Architecture decision for the next N years at StudySapuri
qsona
25
14k
最高のマスターデータ管理手法考察 & VSCode Extension を活用した話 / developing masterdata management tool by using vscode extension
qsona
9
6.1k
GraphQL を活用したスキーマ駆動開発の実践 / schema-driven development with GraphQL
qsona
6
5k
GraphQL を利用したアーキテクチャの勘所 / Architecture practices with GraphQL
qsona
37
15k
Other Decks in Technology
See All in Technology
複雑なState管理からの脱却
sansantech
PRO
1
140
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
Lambdaと地方とコミュニティ
miu_crescent
2
370
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
Terraform Stacks入門 #HashiTalks
msato
0
350
Platform Engineering for Software Developers and Architects
syntasso
1
520
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
180
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
190
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Designing the Hi-DPI Web
ddemaree
280
34k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
We Have a Design System, Now What?
morganepeng
50
7.2k
Visualization
eitanlees
145
15k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
What's new in Ruby 2.0
geeforr
343
31k
Code Reviewing Like a Champion
maltzj
520
39k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Transcript
"Microservices" is dead. Long live "Microservices". @qsona / FiNC Technologies
Inc. 2018-12-21 ۜ࠲Rails#4 @ϦϯΫΞϯυϞνϕʔγϣϯ #ginzarails
"Microservices fundamentalism" is like abstinence-only sex ed: ϚΠΫϩαʔϏεݪཧओٛɺېཉͷΈ͔ΒͳΔੑڭҭͷΑ͏ͩɻ
Over the years, the "Microservices rhetoric" got louder and angrier.
More mean-spirited. ʹΘͨͬͯɺϚΠΫϩαʔϏεͷϨτϦοΫ (࣮͞ͷͳ͍ඒࣙྷ۟)ɺ ͏Δ͘͞ɺౖΓͬΆ͘ɺڱྔʹͳ͖ͬͯͨɻ
͜Εͳʹ • TDD is dead. Long live testing. (by DHH)
ͱ͍͏໊ΤϯτϦͷվม • ͝ଘ͡ͳ͍ํ ςετۦಈ։ൃ CΛඞಡʂ
Θͨͩ͠Ε • @qsona, ϚΠΫϩαʔϏεԺ݈
Microservices ݪཧओٛʁ
ྫ: ίϯΣΠͷ๏ଇ • ৫ͷߏͱٕज़ͷߏҰக͍ͯ͘͠ɺͱ ͍͏๏ଇ
ίϯΣΠͷ๏ଇݪཧओٛ • 1αʔϏεɾ1νʔϜ͡Όͳ͍ͱͩΊ • ৫ΛׂΒͳ͍ͳΒɺαʔϏεΛׂΔҙຯ ͳ͍ • 100ਓҎ্ͷ৫͡Όͳ͚ΕͬͪΌͩΊ
※ಉ྅Ͱ͢(@ota42y͞Μ)
(ͪͳΈʹ༰͍͍ͩͨಉҙ) it depends... agree
Microservices ݪཧओٛ...? • গͳ͘ͱ Martin Fowler Sam Newmanͷ ͜ͱͰͳ͍
• ൴Βͷൃ৴ɺͱͯͱ࣮ͯ • Ұ෦ΛΓऔ֦ͬͯେղऍ͠ɺڧ͗͢Δൃ৴ ͕ͳ͞ΕΔ͜ͱ͕͋Δ
qsonaͷॴײ • શͯͷڧ͍ҙݟ (ݪཧओٛ) ɺ͋ΔίϯςΩετΛ ݩʹൃ৴͞ΕΔ • ࣮ࡍͷݱΛࢧ͑ΔΞϓϦέʔγϣϯΤϯδχΞͷ ࢹɺஔ͍͚ͯ΅Γʹ͞Ε͍ͯΔΑ͏ʹײ͡Δ •
࠷ۙɺϚΠΫϩαʔϏεͱ͍͏ݴ༿Λൃ͢Δͷ͕ ͔ΒΕΔΑ͏ʹͳͬͨ...
qsonaͷॴײ • "counterintuitive ram" (ײʹ͢ΔഁṀ) ͱͯ͠ɺݱঢ়Λม͑ΔͨΊʹɺݪཧओٛతͳ ҙݟΛڣͿɺͱ͍͏͜ͱ͋Δ͕.... • Microservices ʹ͓͍ͯɺͦ͏͍͏ϑΣʔζ
ੈքతʹݟͨΒͱͬ͘ʹա͗ڈ͍ͬͯΔ
qsonaͷॴײ • ίϯΣΠͷ๏ଇݪཧओٛͰ͍͏ͱ... • ٕज़ͱಉ༷ɺ৫ΓతͰͳ͍ • ٕज़ͱ৫ͷ྆ྠͰɺϏδωεɾϓϩμΫτʹ͖߹͍ͬͯ͘ ͷ • ٕज़ͷϦΞʔΩςΫτʹ͕͔͔࣌ؒΔ
• αʔϏεͷ୯Ґ = ৫ ͕ৗʹΓཱͭ΄ͲϏδωε୯७Ͱͳ͍ • ݪཧओٛతओுɺݱͷͱઓ͏ਓʹڹ͔ͳ͍
What is "Microservices" ? • ҰݴͰઆ໌Ͱ͖ͳ͍͠ɺ໌֬ͳఆٛͳ͍ • ίϯηϓτͷू߹ͱɺपลͷΤίγεςϜͱ ͯ͠ଊ͑ͯ΄͍͠
"Microservices" as a Concept • ϏδωευϝΠϯͰαʔϏεΛׂ͢Δ͜ͱ • αʔϏεͷ౷߹ʹඪ४ͷٕज़Λ͏͜ͱ • ୯Ұݪଇɺૄ݁߹ͱߴڽूɺetc
• ϚΠΫϩαʔϏεͷʮྑ͞ʯΛ୲อ͢ΔྖҬ • ॳग़͔Βશ͘มΘ͍ͬͯͳ͍
"Microservices" as an Ecosystem • Docker, Kubernetes, ECS / GKE
• CI/CD πʔϧ • Envoy, Service Mesh (Istio, AWS App Mesh) • ϚΠΫϩαʔϏεͷʮσϝϦοτʯΛফ͢ྖҬ • ʑਐԽ͍ͯ͠Δ
Concept & Ecosystem • ίϯηϓτΛΓɺඞཁͳͱ͖ʹऔΓೖΕΔ͜ͱͰɺϝ ϦοτΛڗड͠ɺ • ΤίγεςϜʹ͏·͘Δ͜ͱͰɺ σϝϦοτΛݮΒ͢ •
ͦ͏͍͏͏·͍͖߹͍ํΛ͢ΕɺϚΠΫϩαʔϏε ΈΜͳͷຯํʹͳΔ • ͱ͍͏ओுΛ͜Ε͔Β͍͖͍ͯͨ͠
গ͠ઢ
Q. Mircoservices ΛͬͪΌ͍ ͚ͳ͍ձࣾʁ • ͳ͍…ͱ͍͍͍͕ͨɺ͋Δ͔͠Εͳ͍ • ελʔτΞοϓͰ • ·ͩϓϩμΫτΛϩʔϯνͯ͠ͳͯ͘
• ΤϯδχΞֶੜ͚ͩ...
None
None
FiNC ❤ Microservices • "ϚΠΫϩαʔϏε" ͱ͍͏ݴ༿ΛΒͳ͍͏ͪ ͔ΒϚΠΫϩαʔϏεΛࢦ͍ͯͨ͠ • ʮҰੜʹҰͷ͔͚͕͑ͷͳ͍ਓੜΛαϙʔτ ͢ΔʯͨΊͷ
Microservices ΛΓ͍ͨਓ Λ͔͚ͯ΄͍͠ • We are hiringɺਅʹ࠾༻ͬͯ·͢
શͯͷձ͕ࣾͦ͏Ͱͳ͍ • ՝ͷઃఆ༷ʑɺత༷ʑ • ۙͳΛղܾ͢Δձࣾ͋Δ • খ͞ͳϓϩμΫτΛ࡞Γଓ͚Δձࣾ͋Δ • ͦ͏͍͏ձࣾΤϯδχΞʹͱͬͯɺ Microservices
ແԑͳͷ͔ʁ
To be continued...
Rails and Microservices • Rails ͔ΒݟΔͱɺ Microservices ࣗͱҧ͏ྖҬͷΛղܾ͢Δଘࡏ •
Rails ʹΓͳ͍ͱ͜ΖΛ Microservices ͰิͰ͖Δ
͓·͔ͤ vs ΞϥΧϧτ
Easy vs Simple ;ͭ͏ͷRailsΞϓϦέʔγϣϯ։ൃ, Takafumi ONAKA https://www.slideshare.net/takafumionaka/rails-77195340
"Easy" is Difficult. • Easy Λҡ࣋͢ΔͷΉ͔͍ͣ͠
Is Rails "Easy"? • Rails ͲΜͳʹର͢Δ͑Λ༻ҙͯ͠Δ Θ͚Ͱͳ͍ • ͦΜͳສೳͳEasyଘࡏ͠ͳ͍
Rails ͱ େن։ൃ
Rails ͱ େن։ൃ • جຊతʹ "தن" ·ͰͷΞϓϦέʔγϣϯ Λߴʹ࣮͢Δͷʹ͍͍ͯΔ • େنʹͳΔͱ͘͠ͳΔଆ໘͋Γ
• ੩తܕ͚, ϞδϡʔϧԽ, Dependency Injection, Event sourcing ͷΈͳͲͳ͍
Rails Λ֦ு͢Δʁ • Service Object, Form Object • Decorator •
Trailblazer • ...
Rails Λ֦ு͠ͳ͍ • ͋Δఔͷൣғ·Ͱ Rails ( + PlainͳΫϥ ε )
Ͱ͏·͘Γ • Rails Ͱ͏·͘ΕΔൣғΛӽ͖͑ͯͨΒɺ αʔϏεΛׂ͍ͯ͘͠ɺͱ͍͏ߟ͑ํ
ྫ: Πϕϯτιʔγϯά • ୯ҰͷRailsαʔϏεͰΠϕϯτιʔγϯά ͢ΔͱɺͦΕͳΓʹ͕ى͖͍͢ • ActiveRecordͷcallbackΛ͏ͱɺҙਤͤͣ ʹൃಈ͢Δ͕ى͖͕ͪ • transaction
ͷൣғʁ
Ұͭͷߟ͑ํ • ୯ҰͷRailsαʔϏεͰɺΠϕϯτιʔγϯά͠ͳ͍ (callback͘͝ݶఆత༻్Ͱ) • ͦͷ͔ΘΓɺ୯ҰαʔϏεͷtransaction୲อ͢Δ • ෳαʔϏεؒΠϕϯτιʔγϯά͠ɺ݁Ռ߹ੑΛ ୲อ͢Δ •
ྫ͑ GCPͷ Cloud Pub/Sub ͏
ϝϦοτΛड͚Δ͜ͱͱɺ σϝϦοτͷରॲ • ݸผσϓϩΠ, োہॴԽ, ݸผεέʔϦϯά ͳͲͷԸܙΛಉ࣌ʹड͚Δ • ࢄΩϡʔ, ࢄτϨʔγϯά,
etc... ͷۤ͠Έ Λड͚Δ • ͜ΕΛࢧ͑ΔΤίγεςϜݱࡏඇৗʹΓ ্͕͍ͬͯΔ
Rails ͱ γεςϜׂ
γεςϜׂͷ؍ • جຊతʹRailsαʔϏε͕Ͱ͔͘ͳΔͱਏ͍ͷͰɺԿ Β͔ͷׂͨ͘͠ͳΔ (ͱ͜͜ͰԾఆ͢Δ) • ٕज़తͳ؍ʹԊׂͬͯ͢Δਓ͕ଟ͍ • ཧը໘Railsɺόον༻Railsɺetc... •
ϚΠΫϩαʔϏεͰɺϏδωευϝΠϯʹͦͬͯ ׂ͢Δ
Α͋͘ΔγφϦΦ • αʔϏεͷϦϦʔεͱཧը໘ͷϦϦʔε͍ͨ͠ Ͷɾɾɾ • ཧը໘༻ͷRails͕ര • Shared Database Pattern
Shared ORM Pattern (அ͞ ΕͨϞϊϦε) • ςʔϒϧͷεΩʔϚมߋͳͲ͕͓ޓ͍ʹӨڹ͢ΔΑ͏ʹ ͳͬͯਏ͍
Α͋͘ΔγφϦΦ • ཧը໘Λ͍͚ͨ͠Ͳɺڞ༗DBΞϯν ύλʔϯͩΑͶɾɾɾ • ཧը໘Single Page AppͰ࡞Δ • ཧը໘͚ͷAPIΛ͕Μͬͯ։ൃ͢Δ
• ͦΕ Rails ΤϯδχΞͷຊͩͬͨͷ͔...?
Rails ͷྑ͞Λੜ͔͍ͨ͠ • View·ͰαΫοͱศརʹ࡞ΕΔͷ͕Railsͷྑ ͞͡Όͳ͍͔ • ཧը໘ΛSPAʹͱ͔ɺࢷΛམͱͨ͠ ύοαύαͷRailsͰ...
ϏδωευϝΠϯͰׂ͠Α͏ • ϏδωευϝΠϯͷڥքΛݟ͚ͭΑ͏ • Domain-Driven Design ͷग़൪ • ͦͷڥքʹԊׂͬͯ͠Α͏ •
ͦͷ͔ΘΓɺཧը໘·Ͱ֤αʔϏεͰఏڙ ͠Α͏
ཧը໘ͷ౷߹ʁ • ͜ͷํ๏ʹ͢Δͱɺཧը໘͕ࢄΒΔ • ΞΧϯτ • σʔλͷ౷߹ • UIͷ౷߹/౷Ұײ
ΞΧϯτͷ౷߹ • SAML ͷඪ४ٕज़Λར༻ͨ͠ Single Sign-onΛ࣮ ͢Δ (language-agnostic) • ͦͷ্ͰɺRailsʹ͚ͨศརͳํ๏༻ҙ͢Δ
• ྫ͑ɺ Rails Engine ͷgemΛಋೖ͢Δ͚ͩͰͰ͖ ΔΑ͏ʹ͢Δ • ඪ४ + ศརϥΠϒϥϦͷೋஈߏ͑
σʔλͷ౷߹ • લఏͱͯ͠ɺσʔλΛ౷߹ͯ͠ѻ͏͜ͱʹ σϝϦοτ͋Δ • ݸਓͷηϯγςΟϒͳใͷΞΫηείϯ τϩʔϧ͕͘͠ͳΔ
σʔλͷ౷߹ • ࠷ݶͷใAPIͰ࿈ܞ͢Δ • ߹ʹΑͬͯڞ༗DB (֎͔Β Read Only) • εΩʔϚมߋͰཧը໘͕յΕΔՄೳੑ͕
͋Δ͕ɺͷμϯλΠϜ͕ڐ͞ΕΔͳ ΒͦΕͰ͍͍
UIͷ౷߹ • ϦϯΫूɺڞ௨ͷϔομʔ͕͋Εڐ͞Ε ΔͳΒͦΕͰ͍͍ • ແཧͯ͠౷߹͢Δͱେม • ෳͷαʔϏεͷίϯϙʔωϯτΛɺͬͱ ߴʹ౷߹ɾ࿈ܞ͍ͯ͘͠ʹɾɾɾʁ
Micro Frontends • ͜ͷಓΛಥ͖٧Ί͍ͯ͘ͱ Micro Frontends ͱ͍͏ΞʔΩςΫνϟʹͳ͍ͬͯ͘ • ֤αʔϏε͕ Web
Components Λఏڙ͠ɺ ౷߹ϨΠϠʔ͕ͦΕΒΛஔ͢Δ • ֤ComponentΠϕϯτͳͲͰڠௐͯ͠ಈ͘
None
None
ྲྀΕͷ͓͞Β͍ • ϏδωευϝΠϯͰׂ͢Δ (ίϯηϓτ) • αʔϏεׂΛߦ͍ͳ͕Βɺ ཧը໘͕؆୯ʹͭ͘ΕΔ (ϝϦοτ) • ཧը໘ͷମݧׂ͕͞ΕΔ
(σϝϦοτ) • ཧը໘ͷ౷߹ΛɺඞཁʹԠͯ͡ ஈ֊తʹߦ͍ͬͯ͘ (ΤίγεςϜͷࢧԉ)
͍͑ͨ͜ͱ • ʮϏδωευϝΠϯͰׂ͢Δʯ = ίϯηϓτ • ͦΕʹΑΓϝϦοτ͕ಘΒΕΔ • ͦͷίϯηϓτͷͱʹΤίγεςϜ͕ൃల ͠ɺಓඋ͞Ε͍ͯ͘
FiNC ❤ Micro Frontends • Micro Frontends ͷಓզʑ͕ઌಋ͢Δ • ຊʹඞཁͱ͍ͯ͠Δ͔ΒΔ
• ͪΖΜɺ୭͕ඞཁͱ͢ΔΞʔΩςΫνϟͰ ͳ͍ • େࣄͳͷɺઌʹਐΈ͍ͨͱ͖ͷಓ͕͋Δ͜ͱ
͔͜͜Βࡶଟͳ
Rails ͱ ΫϥυαʔϏε
Rails ͱ ΫϥυαʔϏε • Web αʔϏεͷकඋൣғͷ֦େ • ྫ͑ IoT ͷձࣾ
=> AWS IoT ͱͦͷपลͷ ϚωʔδυαʔϏεΛϑϧ׆༻͍ͨ͠ • ͚ͩͲɺWebαʔϏεϞόΠϧΞϓϦ͚ API Rails Ͱఏڙ͍ͨ͠
ΞʔΩςΫνϟͷҰྫ • Web αʔϏε Rails • AWS ͚ʹ Serverless Framework
Λར༻͢Δ • ࣮ଶͱͯ͠ AWS Lambda ʹσϓϩΠ͞ΕΔ • ϝϦοτ • Web API SNS/SQSͰͷΠϕϯτͳͲɺ࿈ܞΛ͢Δͷ͕؆୯ʹग़དྷΔʂ • AWS IoT DynamoDB ͳͲͷϨϕϧͳίϯϙʔωϯτΛ Rails ͕ҙࣝ ͠ͳ͍Ͱྑ͘ͳΓɺૄ݁߹ʹͳΔ
ٕज़ҟ࣭ੑ / Language-agnostic
Language-agnostic • ϓϩάϥϛϯάݴޠʹඇґଘͳٕज़બఆ • ྫ: Sidecar Pattern (Envoy ͳͲ)
"ඪ४"ͷҙࣝ • ݴޠඇґଘͳ෦Λଟ͘͢બ => ٕज़ͷඪ४ੑʹҙ͕ࣝ͘ • ٕज़બఆʹ͓͚Δɺࢹͷ͕Γ
ྫ: 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
ྫ: Web API ༷ • ͪΖΜɺ།Ұͷ͑ͳ͍͕… • ͲͷΑ͏ͳࢹΛͬͯબఆ͢Δ͔ • ͷલͷ՝ʹରॲ͢Δ͜ͱɺ
ͪΖΜେࣄ͕ͩ • ଞݴޠͰ࣮Ͱ͖Δ͔ʁͱ͍͏ࢹΛͭ
ྫ: Web API ༷ • RESTful + OpenAPI ͳΒɺ࠷ѱOpenAPI͕ඇରԠͷݴޠΛ ͬͯμϝʔδ͕গͳ͍
• ಠࣗϑΥʔϚοτࣗલϥΠϒϥϦΛఆٛ͗͢͠Δͱɺଞͷݴ ޠʹߦͬͨͱ͖ʹ͖͍ͭΑͶ.. • JSON API, GraphQL, gRPC • ίϛϡχςΟͷαϙʔτঢ়گͲ͏͔ʁ • ࠷ѱɺࣗͰ࣮ͨ͠ΓOSSߩݙͰ͖ΔϨϕϧ͔ʁ
"ඪ४" ͷؔ৺ • ඪ४ԽίϛϡχςΟαϙʔτʹର͢Δؔ৺ ɺٕज़తͳΛଅ͢ɺͱ͍͏Ծઆ
·ͱΊ
·ͱΊ • ·ͱ·Γ·ͤΜͰͨ͠ɺ͝ΊΜͳ͍͞ • શͳΔྗྔෆ • ཧͷཪ͚গͳ͔ͬͨ... • λΠτϧͰͬͯ͢Έ·ͤΜͰͨ͠...͢Έ·ͤ Μ͢Έ·ͤΜ...
ݴ͍͔ͨͬͨ͜ͱ • "ϚΠΫϩαʔϏε" ͱ͍͏ݴ༿ʹଉۤ͠͞Λײͨ͘͡ͳ ͍ɾײͯ͡΄͘͠ͳ͍ • RailsΤϯδχΞʹ "ࣗʹϚΠΫϩαʔϏεؔͳ͍" ͳΜͯࢥͬͯ΄͘͠ͳ͍ •
খ͞ͳ৫ͰϚΠΫϩαʔϏεΛҙ͍͍ࣝͯ͠ • "ϚΠΫϩαʔϏεͬͯ·͢" ͬͯݴͬͨΒୟ͔ΕΔੈͷ த·ͬͽΒͩ
ݴ͍͔ͨͬͨ͜ͱ • ίϯηϓτΛཧղ͠ɺ͏·͘औΓೖΕΔͱ͜ Ζ͔Β࢝ΊΑ͏ • ΤίγεςϜΛΓɺ ͏·͘Γ͜ͳͦ͏
"Microservices" Everywhere.