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
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
1.7k
Googleのテストサイズを活用したテスト環境の構築
toms74209200
0
270
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
140
Tuning GraphQL on Rails
pyama86
2
1k
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
110
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
16
4k
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
CSC305 Lecture 13
javiergs
PRO
0
130
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
260
Honoの来た道とこれから
yusukebe
19
3k
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1k
Outline View in SwiftUI
1024jp
1
110
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
BBQ
matthewcrist
85
9.3k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.9k
Become a Pro
speakerdeck
PRO
24
5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
For a Future-Friendly Web
brad_frost
175
9.4k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
790
Code Reviewing Like a Champion
maltzj
519
39k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
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 :)