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
770
"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
380
Backend エンジニア視点からの GraphQL / GraphQL from a perspective of backend engineer
qsona
27
8.2k
3 Practices about Service-to-Service GraphQL Ruby Client
qsona
1
860
いかにして 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
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
180
Google Cloud で始める Cloud Run 〜AWSとの比較と実例デモで解説〜
risatube
PRO
0
120
5分でわかるDuckDB
chanyou0311
10
3.3k
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
320
2024年にチャレンジしたことを振り返るぞ
mitchan
0
150
APIとはなにか
mikanichinose
0
110
サーバーなしでWordPress運用、できますよ。
sogaoh
PRO
0
120
能動的ドメイン名ライフサイクル管理のすゝめ / Practice on Active Domain Name Lifecycle Management
nttcom
0
200
多様なメトリックとシステムの健全性維持
masaaki_k
0
110
Yahoo! ズバトクにおけるフロントエンド開発
lycorptech_jp
PRO
0
100
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
500
Server-Side Engineer of LINE Sukimani
lycorp_recruit_jp
0
340
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Automating Front-end Workflow
addyosmani
1366
200k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Code Reviewing Like a Champion
maltzj
521
39k
The Language of Interfaces
destraynor
154
24k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Site-Speed That Sticks
csswizardry
2
190
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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.