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
840
いかにして 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
アプリエンジニアのためのGraphQL入門.pdf
spycwolf
0
110
The Rise of LLMOps
asei
9
1.8k
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Mastering Quickfix
daisuzu
1
190
静的解析で実現した効率的なi18n対応の仕組みづくり
minako__ph
1
120
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
複雑なState管理からの脱却
sansantech
PRO
1
160
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
4
240
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
180
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
310
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Producing Creativity
orderedlist
PRO
341
39k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Building an army of robots
kneath
302
43k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
A designer walks into a library…
pauljervisheath
204
24k
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.