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.8k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.1k
図で理解する 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
2k
Other Decks in Programming
See All in Programming
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
100
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
350
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
現場で役立つモデリング 超入門
masuda220
PRO
12
2.6k
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
10
2.2k
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.3k
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
僕がつくった48個のWebサービス達
yusukebe
17
16k
hotwire_or_react
harunatsujita
6
2.8k
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
530
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
160
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
430
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
A Philosophy of Restraint
colly
203
16k
How STYLIGHT went responsive
nonsquared
95
5.1k
Music & Morning Musume
bryan
46
6.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
41
9.2k
It's Worth the Effort
3n
183
27k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
280
GraphQLとの向き合い方2022年版
quramy
43
13k
Git: the NoSQL Database
bkeepers
PRO
425
64k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
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 :)