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
Introduction gRPC
Search
d-kuro
December 14, 2018
Programming
1
250
Introduction gRPC
18/12/14 - The World Café - Classmethod, Inc.
Lightning Talks
d-kuro
December 14, 2018
Tweet
Share
More Decks by d-kuro
See All by d-kuro
kube-state-metrics Sharding
daikurosawa
0
310
Helm Chart を Unit Test する / Unit Testing Helm Chart
daikurosawa
0
2k
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
15k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
10k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.3k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
23k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
5k
GolangCI を使ってコードの品質を保ちながら快適な Golang 生活を送る話 #gounco / GolangCI
daikurosawa
4
5.8k
Go Cloud を触ってみる / gopher-dojo-lt
daikurosawa
2
2.1k
Other Decks in Programming
See All in Programming
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
700
Jakarta EE meets AI
ivargrimstad
0
230
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
690
talk-with-local-llm-with-web-streams-api
kbaba1001
0
180
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
Criando Commits Incríveis no Git
marcelgsantos
2
170
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
How GitHub (no longer) Works
holman
311
140k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Thoughts on Productivity
jonyablonski
67
4.4k
Site-Speed That Sticks
csswizardry
2
190
Building an army of robots
kneath
302
44k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
A designer walks into a library…
pauljervisheath
204
24k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Transcript
5 LT ͰΘ͔Δ(Θ͔Βͳ͍) 18/12/14 - The World Café - Classmethod,
Inc. Dai Kurosawa / @ponde_m
Introduce
What is
What is gRPC ? • Google ͕ެ։ͨ͠ RPC ͷϑϨʔϜϫʔΫ •
Protocol Buffers ͰαʔϏεͷΠϯλϑΣʔεΛఆ ٛͯ͠ Server, Client ͷίʔυΛࣗಈͰੜͰ͖Δ • Protocol Buffers σϑΥϧτͰͦΕҎ֎ͷσʔλϑΥʔϚοτ͋Δ • HTTP/2 Λ༻ͯ͠௨৴, stream ͳͲͰ͖Δ from: [What is gRPC?](https://grpc.io/docs/guides/index.html)
What is gRPC ? • Google ͕ެ։ͨ͠ RPC ͷϑϨʔϜϫʔΫ •
Protocol Buffers ͰαʔϏεͷΠϯλϑΣʔεΛఆ ٛͯ͠ Server, Client ͷίʔυΛࣗಈͰੜͰ͖Δ • Protocol Buffers σϑΥϧτͰͦΕҎ֎ͷσʔλϑΥʔϚοτ͋Δ • HTTP/2 Λ༻ͯ͠௨৴, stream ͳͲͰ͖Δ from: [What is gRPC?](https://grpc.io/docs/guides/index.html)
Protocol Buffers ??
(͕࣌ؒͳ͍ͷͰ) ோΊΔ͚ͩͰ ͳΜͱͳ͘Θ͔Δ Protocol Buffers ͷ͍ํ
How to use Protocol Buffers in gRPC from: [Go Quick
Start](https://grpc.io/docs/quickstart/go.html)
How to use Protocol Buffers in gRPC from: [Go Quick
Start](https://grpc.io/docs/quickstart/go.html) • protoc ͱ͍͏ίϚϯυͰίϯύΠϧ͢Δͱ֤ݴޠ ͷίʔυΛδΣωϨʔτͰ͖Δ • ରԠݴޠ͍ͬͺ͍ • from: [API Reference | Protocol Buffers] (https://developers.google.com/protocol-buffers/docs/reference/overview)
How to use Protocol Buffers in gRPC from: [Go Quick
Start](https://grpc.io/docs/quickstart/go.html)
How to use Protocol Buffers in gRPC from: [Go Quick
Start](https://grpc.io/docs/quickstart/go.html)
What is gRPC ? from: [What is gRPC?](https://grpc.io/docs/guides/index.html) • ਤʹ͢Δͱ͜Μͳײ͡
શʹཧղͨ͠ ʕ◔ϖ◔ʔ͜͜·Ͱ 2 ͘Β͍
Λ͏ͱԿ͕خ͍͠ͷ ?
Advantage of gRPC • Single Source of Truth ͷ࣮ݱ •
ΠϯλϑΣʔεશͯ protobufs ʹఆٛ͢Δ • protobufs = શͳυΩϡϝϯτ • ܕ͞ΕΔ • ϧʔϧΛकΕલํޓ, ޙํޓʹରԠͰ͖Δ (https://developers.google.com/protocol-buffers/docs/proto3#updating) • ͲͪΒ͔ͱ͍͑ protobufs Λ͏͜ͱʹΑΔخ͠͞ • Protobufs ͔ΒίʔυΛδΣωϨʔτͯ͠։ൃΛߦ͏ • υΩϡϝϯτʹهࡌ࿙Ε͕͋ͬͯ…… Έ͍ͨͳͷ͔Βղ์͞ΕΔ • REST API ઃܭ͔Βղ์
Advantage of gRPC • HTTP/2 ͔ΒಘΒΕΔԸܙ • ߴύϑΥʔϚϯε • HTTP/1
ͷςΩετϓϩτίϧ͔ΒόΠφϦϓϩτίϧʹ • సૹ͢Δσʔλྔ͕খ͘͞ͳΔ • ߴͳσʔλղੳ • 1ͭͷ TCP ଓʹରͯ͠ଟॏϦΫΤετΛૹΔ͜ͱ͕Ͱ͖Δ • ίωΫγϣϯཱ֬ͷΦʔόϔου͕খ͘͞ͳΔ • ํετϦʔϛϯά • GCP ͷ API ͱ͔ͩͱ gRPC ͕׆༻͞Ε͍ͯͨΓ͢Δ • [gRPC Λհͨ͠ Cloud Pub/Sub: ֓ཁ] (https://cloud.google.com/pubsub/grpc-overview?hl=ja)
Ͱ͍͍͜ͱ͔ΓͰ ͳ͍ΜͰ͠ΐ͏ʁ
Disadvantage of gRPC • gRPC ͷ API REST ͷ
API ͱͯ͠ίʔϧͰ͖ͳ͍ • curl ͢ΒͰ͖ͳ͍ • ϑϩϯτΤϯυ͔ΒݺͿʹ……? • gRPC HTTP/2 ͕લఏ • ϩʔυόϥϯγϯάͳͲΛߟ͑ͳ͍ͱ͍͚ͳ͍ • ALB ͷ෦௨৴ HTTP/2 ඇରԠ • CLB ͩͱ L4 ϨΠϠͷϩʔυόϥϯγϯάʹͳͬͯ͠·͏
grpc-gateway • HTTP/1.1 ͷ API ΛఏڙͰ͖ΔϦόʔεϓϩΩγ • protobufs ʹ option
ΛՃ͑Δͱ REST ͱ gPRC ͷΫϥΠΞϯτΛ հ͢Δ Golang ͷίʔυ͕ੜ͞ΕΔ • Swagger ΛδΣωϨʔτ͢Δ͜ͱ͕Ͱ͖Δ from: [grpc-ecosystem/grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway)
gRPC-Web • gRPC ͷΫϥΠΞϯτ͕ϒϥβͰಈ͘ • protobufs ͔Β JavaScript ͷΫϥΠΞϯτΛδΣωϨʔτ •
CNCF ͕ GA Λൃදͯͨ͠ from: [gRPC-Web is going GA](https://www.cncf.io/blog/2018/10/24/grpc-web-is-going-ga/)
gRPC-Web • ͓…… ʁ from: [gRPC-Web is going GA](https://www.cncf.io/blog/2018/10/24/grpc-web-is-going-ga/)
service proxy …… ?
gRPC-Web from: [Envoy and gRPC-Web: a fresh new alternative to
REST] (https://blog.envoyproxy.io/envoy-and-grpc-web-a-fresh-new-alternative-to-rest-6504ce7eb880) • ݱ࣮͜͏ • Local Proxy ΛࠓޙͷϩʔυϚοϓͱͯ͠ݕ౼தΒ͍͠
gRPC-Web from: [ϑϩϯτΤϯυΤϯδχΞ͓͖͍ͬͯͨgRPC] (https://speakerdeck.com/suusan2go/hurontoendoenziniamozhi-tuteokitaigrpc?slide=25) • ͜ͷੈքʹͳͬͯ΄͍͠
gRPC Load Balancing • HTTP/2 1ͭͷίωΫγϣϯͰෳͷϦΫΤετΛૹΔ • L4 ϨΠϠͰϩʔυόϥϯγϯάΛߦ͏ͱίωΫγϣϯ͕அ͞ΕΔ·Ͱಉ͡αʔό ʹϦΫΤετΛૹͬͯ͠·͏
• HTTP/2 ʹରԠͨ͠ proxy ͕ඞཁ from: [gRPC Load Balancing on Kubernetes without Tears] (https://kubernetes.io/blog/2018/11/07/grpc-load-balancing-on-kubernetes-without-tears/)
gRPC Load Balancing • ϦΫϧʔτ͞Μͷϒϩά͕ΊͬͪΌΑ͔ͬͨ from: [EnvoyͱAmazon ECS Service DiscoveryΛར༻ͨ͠gRPCͷෛՙࢄ]
(https://tech.recruit-mp.co.jp/infrastructure/post-17098/)
·ͱΊ • gPRC ͍͍ͧ • ͰԿߟ͑ͣʹ࠾༻Ͱ͖ΔͷͰͳ͘ɺ৭ʑ ߟྀ͠ͳ͚ΕͳΒͳ͍ଟʑ͋ΔͷͰ͔ͬ͠ Γͱௐࠪ, ݕ౼্ͨ͠Ͱ࠾༻͠Α͏ •
gRPC ͷࠓޙʹ͝ظ͍ͩ͘͞
Enjoy gRPC :)