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
240
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
290
Helm Chart を Unit Test する / Unit Testing Helm Chart
daikurosawa
0
1.9k
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
14k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
9.9k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.2k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
23k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
4.9k
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
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Amazon Qを使ってIaCを触ろう!
maruto
0
410
ヤプリ新卒SREの オンボーディング
masaki12
0
130
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
役立つログに取り組もう
irof
28
9.6k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Click-free releases & the making of a CLI app
oheyadam
2
120
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Embracing the Ebb and Flow
colly
84
4.5k
Agile that works and the tools we love
rasmusluckow
327
21k
Become a Pro
speakerdeck
PRO
25
5k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Why Our Code Smells
bkeepers
PRO
334
57k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
What's new in Ruby 2.0
geeforr
343
31k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
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 :)