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
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
subpath importsで始めるモック生活
10tera
0
300
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
100
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
290
Featured
See All Featured
The Language of Interfaces
destraynor
154
24k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Writing Fast Ruby
sferik
627
61k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
A Philosophy of Restraint
colly
203
16k
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 :)