Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
はてなリモートインターンシップ2022 マイクロサービス 講義資料
Search
Hatena
December 19, 2022
Programming
0
250
はてなリモートインターンシップ2022 マイクロサービス 講義資料
https://hatena.co.jp/recruit/intern/2022
Hatena
December 19, 2022
Tweet
Share
More Decks by Hatena
See All by Hatena
はてなインターンシップ2024 HTTP, Web, API 講義資料
hatena
0
990
はてなインターンシップ2024 RDBMS ブートキャンプ講義資料
hatena
0
790
はてなインターンシップ2024 フロントエンドブートキャンプ講義資料
hatena
0
720
はてなインターンシップ2024 コンテナ講義資料
hatena
0
790
はてなインターンシップ2024 コンテナオーケストレーション講義資料
hatena
0
700
はてなインターンシップ2024 インフラ講義資料
hatena
0
720
はてなインターンシップ2024 AI 講義資料
hatena
0
710
はてなインターンシップ2024 ブログライティング講義資料
hatena
4
2.7k
はてなリモートインターンシップ2023 Web, HTTP 講義資料
hatena
1
490
Other Decks in Programming
See All in Programming
Djangoの開発環境で工夫したこと - pre-commit / DevContainer
hiroki_yod
1
610
Vue.js_好きに捧ぐ Nuxt Hub で簡単に始めるCloudflare
xiombatsg
1
110
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
1
560
eBPF Deep Dive: Architecture and Safety Mechanisms
takehaya
12
1.2k
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
0
230
Gestaltung digitaler Lösungen – Produktions- oder Designprozess?
techstories
0
120
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
5
3.8k
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
2
270
HTTP compression in PHP and Symfony apps
dunglas
2
1k
Serverless苦闘史
mosh_inc
0
140
talk-with-local-llm-with-web-streams-api
kbaba1001
0
130
かんたんデザイン編集やってみた~「完全に理解した」までの道のり~
morit4ryo
1
110
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
How STYLIGHT went responsive
nonsquared
95
5.2k
What's new in Ruby 2.0
geeforr
343
31k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Side Projects
sachag
452
42k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Why Our Code Smells
bkeepers
PRO
334
57k
The Pragmatic Product Professional
lauravandoore
32
6.3k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Transcript
ϚΠΫϩαʔϏε #hatenaintern
☪仼סإ٭ٜ ˝ ם؆כםׂُؕؠٞئ٭لتֿלַֹֹס־־ ˝ ُؕؠٞئ٭لتס榫鏤סꦬ㍱妳־
☪仼ס⫂㳊 ˝ ُؕؠٞئ٭لتכע ˝ ٓؿٛت ˝ עיםמֽُׄؕؠٞئ٭لت ˝ ُؕؠٞئ٭لتס⮆Ⱏ亠嫎 ˝
ُؕؠٞئ٭لتסوٚؠطؔت ˝ ئ٭لتْشبٖ ˝ ױכ״
ֽ鎇םַ׆כ golang
ُؕؠٞئ٭لت ُؕؠٞئ٭لتכע
ُؕؠٞئ٭لت +
ُؕؠٞئ٭لت +
אאئ٭لتכע service a system that provides something that the public
needs, organized by the government or a private company Hatena REMOTE INTERNSHIP / ( ?)
ُؕؠٞئ٭لتכע + https://martinfowler.com/articles/microservices.html 2014 DDD( )
هٞءמכ׆סُؕؠٞئ٭لت 1 HTTP API - https://martinfowler.com/articles/microservices.html
ُؕؠٞئ٭لت REST API GraphQL gRPC... /
ةؘن٬يدتס䫍 2002 Amazon 1. ئ٭لتؕ٤ذ٭نؘ٭ت鵟י⪒יסظ٭ذכ嚀耆⪜ꝧ 2. אסؕ٤ذ٭نؘ٭ت鵟י鵟⟓םׄףםםַ 3. ؾشع٠٭ؠ飈סئ٭لتؕ٤ذ٭نؘ٭ت磬榺ג鵟⟓דֿׄ錉⺎ն 4.
✳榫䤗软עゖםַ HTTP Corba Pubsub ⛰ך荁ַ Bezos 5. Steve Yegge Google
ُؕؠٞئ٭لتס荁ַכ׆ API
ُؕؠٞئ٭لتס荁ַכ׆ ˝ 邾丗סؓوٛآ٭ب٘٤ך⺱⭚杼㲔逷䑒釐ֿםׂם ˝ ❆ֻף鵟湳ُؕؠٞئ٭لتכյ二ַؓوٛآ٭ب٘ ٤ךעאסُؕؠٞئ٭لتסٛؠؙتعדׄך鵟湳ֿך׀ ˝ ٚؕهٚٛך⺱׆כֿ⺎耆כַֻף⺎耆דֿյ銧鏤窜םל ֿ㰆㏇םַסֿَؕ٤ع ˝
ُؕؠٞئ٭لتׇכמز٭ّ⮉׆כֿך׀ ˝ 鵟湳םלْ٤طػ٤ت㓹泅ز٭ّםל
ُؕؠٞئ٭لتסחַכ׆ 1 web 2 20 ⾒ ⾒
ם僃鲣孱车זיַ־ ProtocolBu er gRPC GraphQL OpenAPI /
עיםכُؕؠٞئ٭لت ˝ עיםךُؕؠٞئ٭لت⮵榫יַױ ˝ 鐐ꄋئ٭لت ˝ هٞءذء ˝ 嚀危㰢綗 ˝
ز٭ّꝴךסظ٭ذס ˝ ؓوٛآ٭ب٘٤ُؕؠٞئ٭لتדׄך啶䡗יַכַֹյ釐碛釐碛ُ ؕؠٞئ٭لتיַ ˝ ؓوٛآ٭ب٘٤舅⛮עٓؿٛت┊㴩מ鷞榫יַ◄ֿ㛡ַ
ٓؿٛت ( ) 1 .... WAF(WebApplicationFramework)
ٓؿٛت 1 1 1 1 DB DB
ٓؿٛت 1 DB
vs CI/CD 2
1 1
ُؕؠٞئ٭لتס睦䈱 ? No /
㗞槡טׄגؤ٤ط؞تع DDD DB
磵⺬ꄆ邾 / ...
ُؕؠٞئ٭لتכظ٭ذ畘杼 ˝ ظ٭ذي٭ت┕סظ٭ذյُؕؠٞئ٭لتׇכמ斻玮י䧏ח׀ ˝ ظ٭ذي٭ت⪦僗כյ㗞槡טׄגؤ٤ط؞تعכַֹ䙫⽏ךֵױ荁ׂםַ ˝ ظ٭ذي٭ت邾丗סُؕؠٞئ٭لتך⪦僗כյظ٭ذي٭تֿ磵㷀ⶡ┉꤃㲹憠 מם ˝ ت؞٭ُ⪦僗יַג㕙⺬յֵئ٭لتך㚺催ⱶֻכ☽ئ٭لت㚺催מ鴑
䏼䑒釐ֵֿ ˝ ُؕؠٞئ٭لتׇכמ鸵⮉םظ٭ذي٭ت鹟䥃ך׀⮵憠ֵ ˝ ج؞ٖٛطؔ鈝憠鵭䈱鈝憠םלյ喋չ
ُؕؠٞئ٭لتכظ٭ذ畘杼
? No API GateWay API PC API API DB DB
1
ئ٭لتي٭تؓ٭؞طؠزٔ DB DB
ُؕؠٞئ٭لتס⮆Ⱏ
ُؕؠٞئ٭لتס⮆Ⱏ ˝ ُؕؠٞئ٭لت⛼זיַׂ꤀ע䑒յُؕؠٞئ٭لتס 鞊ⳉ婊㲊⛼哅ֿ䑒釐מם ˝ ُؕؠٞئ٭لتס⮆Ⱏ ˝ ⪮⛮氳ם⮆Ⱏ亠嫎釤⯥מյُؕؠٞئ٭لتס⯥䬠䤰ֻ יֽ׀ױֹ
ُؕؠٞئ٭لتס⯥䬠 DB
8 Fallacies of distributed computing ( 8 / ) -
1994 1. 2. 3. 4. 5. 6. 1 7. 8.
⺎鈝峮䓪 web / (Observability)
⺎鈝峮䓪 mackerel
ُؕؠٞئ٭لتס⮆Ⱏ ُؕؠٞئ٭لتס⮆Ⱏע荇չ孱孬ֿ㰆㏇ .... - - 僃鲣ךע⮆Ⱏ䣆Ⲃׄص٭ٜםלֿꝧ氦חחֵ
哅ⳉמ⮆Ⱏ ˝ 鏀錞 ˝ よ⿁辐炐٬吾碟 ˝ 鐐ꄋ ˝ ㏇䈻澬鏀 ˝
⭳蕔⛼哅 ˝ 鑁姲
哅ⳉמ⮆Ⱏ ˝ ٗ٭ا٭ֿאא樟ם㗞槡 ˝ ٗ٭ا٭ע⺱דֿյ姲״סֿ樟ם㗞槡
哅ⳉמ⮆Ⱏ /
㗞槡טׄגؤ٤ط؞تعמ⮆Ⱏ DDD DDD DDD
㗞槡טׄגؤ٤ط؞تعמ⮆Ⱏ (Entity Trap) - - - - DB ORM
ؕطٝ٭طؔهמ䷉ャ 1
攐䓪מ⮆Ⱏ / ( ) 1 (Availability) (Continuity) (Performance) / /
攐䓪מ⮆Ⱏ ײׂמُؕؠٞئ٭لت縒ֻ⯥מյױע㵚霄סئ٭لت⮆冪յלסֹםغْؕ ٤⣐ꪫֵֿ־釤哕״ױֹ /
❆ֻףج؞ٖٛطؔ ˝ ج؞ٖٛطؔמꄆ釐םظ٭ذ䣽ֹסעئ٭لتכי⮉ ⭳ױֹ ˝ 斻玮גظ٭ذي٭ت ˝ ❆ֻף鵟䅻סئ٭لتכ鐐ꄋئ٭لت⮆ꦕםל ˝ ⮯סئ٭لتכס鵟⟓ס倊⺘吾鋀ױֹ
❆ֻף⫋⮵榫䓪 ˝ ؓؗ٤ع㓹泅鵟湳յ婊岷嚀耆םל ˝ ⺱ؓؗ٤عך邾丗סئؕعמٞءؕ٤גַ ˝ 婊岷嚀耆ע䄄丗ֿ־־סךյُؕؠٞئ٭لتי⪦鵟 㓹泅מיֽ׀גַ ˝ 邾丗סئ٭لتך⮵榫ך׀־לֹ־
ُؕؠٞئ٭لتס⮆Ⱏ ˝ 釤י׀ג喋מُؕؠٞئ٭لتס⮆Ⱏ縒ֻכ׆ךע喋չ ם鈝憠ֵֿ ˝ 塜鉮ֿ扛ַ┩槡םסךյ喋չםססعٝ٭غ؛ن縒䜡ם ֿ錃銶ֹ ˝ 僃䖾ם錃銶ך扛ׄףؕطٝ٭طؔهמ䷉ャ◄ֿך׀ ˝
☽ס⣐ꪫכיظ٭ذס䣽ַמ浓泘׆כֵ
ُؕؠٞئ٭لتסوٚؠطؔت ˝ ُؕؠٞئ٭لتמֽׄظ٭ذס䣽ַ ˝ ئ٭لتꝴ鵟⟓ ˝ ئ٭لتْشبٖ ˝ ُؕؠٞئ٭لتסٛٛ٭تכٛنؒؠذٛ٤ء
ُؕؠٞئ٭لتמֽׄظ٭ذס䣽ַ
DB 1 1 DB to DB
CAP BASE 3 2 C: Consistency ( ) A: Availability
( P: Tolerance to network Partitions ( ) ( )CAP BASE Basically Available( ) Soft state( ) Eventually consistent( )
ُؕؠٞئ٭لتכ⮆丆عٚ٤اؠب٘٤ ! ئ٭لتױג׃عٚ٤اؠب٘٤עםַ 1
אך⮆丆عٚ٤اؠب٘٤גַ 2 Saga TCC
Saga T , T , T C , C ,
C :
Saga : AWS https://docs.aws.amazon.com/ja_jp/prescriptive-guidance/ latest/modernization-data-persistence/saga-pattern.html
TCC Try/Con rm/Cancel ײ؆ם荁ׄף⟊㰆յ鐍־ד״ם؞ٔ٤جٜ
TCC Try Cancel Try Con rm Con rm Cancel
TCC ˝ אבסئ٭لتמ◅㍑חٛؠؙتعֿ䑒釐 ˝ ع٭ذٜך侇ꝴֿ־־׆כֿؾشؠ
DB ? ... ADR
睦䈱縒ֻ泡גֹֿ荁ַ侇 1 1
ئ٭لتꝴ鵟⟓
ئ٭لتꝴ鵟⟓ schema rst
⫴璡䓪 1 1 1 /payment {"amount":300, "userAccount": "hoge"} /payment ID
/payment {"amount":300, "userAccount": "hoge","forPurchase": "abcd123"} forPurchase forPurchase
ئ٭لتْشبٖ
ُؕؠٞئ٭لتס畘杼 ˝ ؓوٛآ٭ب٘٤ע邾ꥭםئ٭لت紮סױ ˝ ؓوٛآ٭ب٘٤⟥渏י釤亠嫎ֿ培ַ ˝ ئ٭لتꝴס❣㰆꞊➟ ˝ 泃釱٬ٞءס⹜ ˝
ئؕغ٭قذ٭٤ֿ㛡ׂ⮵榫
ُؕؠٞئ٭لتס畘杼 ˝ ꤃㲹氦榟侇ס鐧削 ˝ ⠕չסئ٭لتꯂ樑מ釤יַׂכ侇ꝴֿ־־ ˝ ئ٭لتꝴס鵟⟓畘杼♓┕מ׆כֵֿאֹ
ئؕغ٭قذ٭٤ mackerel-container-agent
ئ٭لتْشبٖ proxy proxy ip
ئ٭لتْشبٖס䏔Ⱏ A B
ئ٭؞شعهٝ٭٭ Istio
ظ٭ذوٝ٭٤כؤ٤عٞ٭ٜوٝ٭٤ ˝ ظ٭ذوٝ٭٤ ˝ ⺨ئ٭لتמ㳝岣זיⳂׂوٞ؞ب ˝ 鵟⟓ס⯆䐒כ䗯㕔ס⹜ ˝ ىٜتزؘشؠ鏀錞٬鏀⺎םל车ֹ ˝
ْعٛشؠٞء⹜յؤ٤عٞ٭ٜوٝ٭٤峚
ظ٭ذوٝ٭٤כؤ٤عٞ٭ٜوٝ٭٤ ˝ ؤ٤عٞ٭ٜوٝ٭٤ ˝ ظ٭ذوٝ٭٤סؕ٤تذ٤تס畘杼 ˝ ⺨ئ٭لتסْعٛشؠٞء⹜ ˝ 啶䡗畘杼٬⺨牊رشبٍٖ٭غ
Envoy https://www.envoyproxy.io/ Lyft C++ L L HTTP HTTP, gRPC, WebSocket,
TCP ( )
Istio Istiod sidecar injection Envoy Envoy
ُؕؠٞئ٭لتסٛٛ٭ت亠嫎 API versioning / API
壿꣪氳מت؞٭ُסٛنؒؠذٛ٤ء GraphQL gRPC
催מ㰢שמע CloudNative CNCF Cloud Native Interactive Landscape The Amazon Builders'
Library microservice microservice - . oO( ( l _ l) ) Sam Newman 2016 Susan J. Fowler 2017 Neal Ford, Rebecca Parsons, Patrick Kua 2018 Sam Newman 2020 Microservice Architecture
ױכ״ ˝ ُؕؠٞئ٭لتע邾丗סئ٭لتֿ鵟⟓מזי鵽䯥י䡗 玮חؓ٭؞طؠزٔ ˝ ُؕؠٞئ٭لتס⮆Ⱏ亠嫎ע喋չם䣆嫎ֵֿ ˝ ُؕؠٞئ٭لتעؕطٝ٭طؔهמ䷉ャ禈ׄ׆כֿꄆ釐 ˝ ئ٭لتْشبٖםלסوٚؠطؔت⪌יַ׆ֹ
זיײֹסؤ٭ػ٭
: Istio istioctl install istioctl install !"set profile=demo !"context hatena-intern-2021
kubectl label namespace hatena-intern-2021 istio- injection=enabled kubectl get namespace hatena-intern-2021 -o yaml istio-injection enabled
: Istio kubectl apply -f https:!"raw.githubusercontent.com/istio/ istio/release-1.7/samples/addons/kiali.yaml Kiali kubectl apply
-f https:!"raw.githubusercontent.com/istio/ istio/release-1.7/samples/addons/prometheus.yaml Prometheus application istioctl dashboard kiali sign in admin:admin
Kiali
: fault injection 攐㲊ס嚀耆מ䙫㍲氳מ䷚꤃氦榟י䏅ꮶ疗㍱鐧ױ Injecting an HTTP abort fault renderer
service ( Service Temporarily Unavailable) fault %age Kiali application blog service error message istio-proxy log "authority": "renderer-go:50051" response_flags
: fault injection renderer service response 5 Kiali application istio-proxy
log response_flags kubectl delete virtualservices.networking.istio.io [໊લ] fault injection