Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
gRPC入門
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Taiga Sakaguchi
November 19, 2022
Technology
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
gRPC入門
Taiga Sakaguchi
November 19, 2022
More Decks by Taiga Sakaguchi
See All by Taiga Sakaguchi
トランクベース開発のすすめ
taigaskg
0
150
クリーンアーキテクチャのすすめ
taigaskg
0
360
Other Decks in Technology
See All in Technology
AIで仕事のやり方を変える
matsu7874
3
1.1k
Snowflakeで実現する全社横断の顧客の声(VOC)分析・活用基盤@Snowflake World Tour Tokyo 2026
yuto16
0
200
SQL文一行も書けない人事がCortexもろもろを使って人事業務を楽にしてみる
ponponmikankan
1
230
Deployment の 先にある AI Agent 基盤 - kagent vNext、Agent Substrate、Hermes から読み解く Agent Runtime の現在地 / k8s-matsuri-2-ai-agent-platform-amsy810
masayaaoyama
3
220
消えない 動かない 効かない
yama3133
1
120
安心して変更できるWebフロントエンドの作り方
pirosikick
4
1.9k
越境するなら専門用語を使うな高校校歌 / If you wanna cross border, you shouldn't use jargon
vtryo
0
130
The Agent Builder Loop from Daily Work to OSS
minorun365
PRO
3
150
Gitは怖い?共有ワークスペースから始めるSnowflakeチーム開発
coco_se
0
190
株式会社シーエーシー エンジニア向け会社紹介資料
cac
0
57k
Code4Lib JAPANカンファレンス2026 開会挨拶 / Code4Lib JAPAN Conference 2026: Opening Remarks
ykiyota
0
350
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
200
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
820
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
The SEO identity crisis: Don't let AI make you average
varn
0
560
Odyssey Design
rkendrick25
PRO
2
800
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
450
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
We Are The Robots
honzajavorek
0
370
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Automating Front-end Workflow
addyosmani
1369
210k
A Soul's Torment
seathinner
7
3.6k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Transcript
gRPC 入門 Taiga Sakaguchi 1
Sakaguchi Taiga 教員→Web エンジニア 歴3 年 バックエンドエンジニア 都内メガベンチャーに勤務 2
gRPC とは Google によって開発されたRPC フレームワーク 3
RPC とは Remote Procedure Call の頭字語(遠隔手続き呼び出し) ネットワークを通じて別のコンピュータ上で動作するソフトウェア の関数を呼び出すための仕様 4
一般的な関数呼び出し 5
RPC における関数呼び出し 6
RPC の何が嬉しいのか ローカルの関数かリモートの関数かを意識せずにコードを書くこと ができる 7
type Server struct {} type User struct{ ID string }
func (s *Server) GetUser(id string) *User {} type Client struct {} func (c *Client)DoSomething() { u := c.GetUser("userid") } 8
REST だったら type Server struct {} func main() { r
:= gin.Default() r.GET("/user/:id", getUser) r.Run() } func getUser(c *gin.Context) {} type Client struct {} func (c *Client) DoSomething() { resp, err := http.Get("http://user/1") } 9
https://grpc.io/docs/what-is-grpc/introduction/ 10
Protocol Buffers Google により開発 IDL (インターフェース定義言語) 通信や永続化での利用を目的としたシリアライズフォーマット コードやDocs など自動生成できる 11
syntax = "proto3"; service User { rpc GetUser(GetUserRequest) returns (GetUserResponse)
{} } message GetUserRequest { string id = 1; } message GetUserResponse { string id = 1; string name = 2; } 12
サーバー用の生成コード // ... type UserServer interface { GetUser(context.Context, *GetUserRequest) (*GetUserResponse,
error) mustEmbedUnimplementedUserServer() } // ... 13
クライアント用の生成コード // ... type UserClient interface { GetUser(ctx context.Context, in
*GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) } func NewUserClient(cc grpc.ClientConnInterface) UserClient { return &userClient{cc} } // ... 14
ここでクイズ gRPC の「g 」の意味はなんでしょうか? 1. Google 2. Good 3. Great
4. Game 15
ここでクイズ gRPC の「g 」の意味はなんでしょうか? 1. Google 2. Good 3. Great
4. Game 16
gRPC の「g 」はバージョンごとに意味がかわるらしい https://github.com/grpc/grpc/blob/master/doc/g_stands_for.md 17
gRPC のメリット HTTP/2 で通信 Protocol Buffers によるシリアライズ ストリーミング処理 多くの言語に対応(Go, Java,
Kotlin, Node, PHP, Python, Ruby,... ) 18
4 つの通信方式 Unary RPC Server streaming RPC Client streaming RPC
Bidirectional streaming PRC 19
Unary RPC 1 Request - 1 Response 20
Server streaming RPC 1 Request - N Response 例)push 通知など
21
Client streaming RPC N Request - 1 Response 例)データを分割して複数回に分けてアップロード 22
Bidirectional streaming PRC WebSocket のような双方向通 例) チャット 23
gRPC のデメリット PRC の設計に気をつけないと破綻する 実装に時間がかかる ブラウザでのサポートが十分でない 24
gRPC が向いているケース Microservice プライベートなAPI モバイル、IoT 25
ブラウザ - サーバー間で導入するには grpc-web grpc-gateway connect 26
grpc-web 27
grpc-gateway 28
connect https://connect.build/ 29
connect 30
参考 https://grpc.io/ https://zenn.dev/hsaki/books/golang-grpc-starting https://christina04.hatenablog.com/entry/2017/11/13/190000 https://qiita.com/gold-kou/items/a1cc2be6045723e242eb 31
32