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
780
"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
400
Backend エンジニア視点からの GraphQL / GraphQL from a perspective of backend engineer
qsona
27
8.2k
3 Practices about Service-to-Service GraphQL Ruby Client
qsona
1
880
いかにして 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.2k
GraphQL を活用したスキーマ駆動開発の実践 / schema-driven development with GraphQL
qsona
6
5.1k
GraphQL を利用したアーキテクチャの勘所 / Architecture practices with GraphQL
qsona
37
15k
Other Decks in Technology
See All in Technology
[SRE kaigi 2025] ガバメントクラウドに向けた開発と変化するSRE組織のあり方 / Development for Government Cloud and the Evolving Role of SRE Teams
kazeburo
3
1k
メンバーがオーナーシップを発揮しやすいチームづくり
ham0215
2
310
インフラコストとセキュリティ課題解決のためのリアーキテクチャリング / srekaigi2025
hgsgtk
3
2.1k
大学教員が押さえておくべき生成 AI の基礎と活用例〜より効率的な教育のために〜
soh9834
1
140
reinvent2024を起点に振り返るサーバーレスアップデート
mihonda
1
140
第27回クラウド女子会 ~re:Invent 振り返りLT会~ 宣言型ポリシー、使ってみたらこうだった!
itkr2305
0
220
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
2
3.6k
クロスアカウントな RDS Snapshot Export による カジュアルなデータ集約の仕組み / 202501-finatext-technight-lt
wa6sn
1
110
SREKaigi.pdf
_awache
1
1.6k
なぜfreeeはハブ・アンド・スポーク型の データメッシュアーキテクチャにチャレンジするのか?
shinichiro_joya
3
820
DMMブックスへのTipKit導入
ttyi2
1
140
re:Invent2024 KeynoteのAmazon Q Developer考察
yusukeshimizu
1
170
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
A designer walks into a library…
pauljervisheath
205
24k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
Faster Mobile Websites
deanohume
305
30k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Facilitating Awesome Meetings
lara
51
6.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
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.