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
「ウチも、gRPC使えますか?」
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
uhzz
October 10, 2021
Programming
350
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
「ウチも、gRPC使えますか?」
uhzz
October 10, 2021
More Decks by uhzz
See All by uhzz
DI コンテナ自動生成ツールを実装してみた / intro-autodi
uhzz
0
950
Goで実現するGraceful Shutdown ~実運用での課題と解決策~ / Go Conference 2025
uhzz
2
1.9k
MCP調べてみました! / Exploring MCP
uhzz
2
4.1k
自動生成されたhttpエンドポイントごとにカスタムミドルウェアを挿入したい話
uhzz
1
3k
Enablement Bootcampを終えて -Enablement Bootcamp for Gopherizing 〜業務で使えるGoを学ぼう〜
uhzz
0
360
安全にQAを行える環境が整いました!- Kyash TechTalk #6 - Kyashの開発をチラ見せ
uhzz
0
900
Goのローカル開発をWorkspacesではじめよう
uhzz
1
1.2k
【Go:パッケージ管理】DepからGo Modulesへ
uhzz
0
1.2k
コードレビューで泣かないためのintSize = 32 << (^uint(0) >> 63)
uhzz
0
280
Other Decks in Programming
See All in Programming
ソフトウェアラスタライザ
fadis
1
260
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
170
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
220
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.9k
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
120
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
My Marp Sample
sinoue0108
0
110
バグを直したら useEffect が消えた
colorful12
3
670
Building a Meta Ray-Ban display app
akkeylab
0
170
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
350
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
220
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.9k
Featured
See All Featured
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
The Curious Case for Waylosing
cassininazir
1
470
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
500
Exploring anti-patterns in Rails
aemeredith
3
470
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
250
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
480
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
280
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
450
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
300
Transcript
「ウチも、gRPC使えますか?」 『dev合宿@トスラブ箱根 和奏林』 2021/10/08 - 09 @_uhzz_
whoami🤔 Reo Uehara / 株式会社フクロウラボ twitter: @_uhzz_ github: uh-zz 箱根は静岡だと思ってました🤔
箱根、楽しんでいますか〜 ここに道中撮った写真を貼る
今日話すこと - gRPC is 何? - gRPCの何が嬉しいの? - サンプル実演会(Rails ×
Go) - まとめ
gRPC is 何?
こんなお悩みはないだろうか 実装言語ごとに、似たような関数を新しく作ってるけど、、、うーん🤔 # メッセージを暗号化 def hash(message) return crypt(message) end //
メッセージを暗号化 func hash(message string) string { return crypt(message) }
こんなお悩みはないだろうか 実装言語ごとに、似たような関数を新しく作ってるけど、、、うーん🤔 # メッセージを暗号化 def hash(message) return crypt(message) end //
メッセージを暗号化 func hash(message string) string { return crypt(message) } そのお悩み、解決できるかもしれません
RPC -Remote Procedure Call- // メッセージを暗号化 func hash(message string) string
{ return crypt(message) } サーバーを超えた、リモートでの関数(手続き)呼び出しのこと! 近年ではHTTP/HTTPSベースかつXML/JSON形式でやりとりするWeb API hash関数を呼び出し
gRPC -GoogleによるRPC- 特定の言語やプラットフォームに依存しない、 サーバー/クライアントのコードを自動生成するフレームワーク https://grpc.io/docs/what-is-grpc/introduction/
RESTなAPIとの違い どちらもWeb APIの一種です! gRPCには、 プロトコル内部でHTTP/2を使って通信するけれど、実装する開発者には HTTPの存在を意識させない 特徴があり、一方RESTには、 「URL+HTTPメソッド」という制約がありつつも、gRPCよりも汎用的に使える ので外部/内部システム問わずに使える という特徴があってどちらも優劣をつけられるものではありません!
gRPCの何が嬉しいの?
gRPCの特徴 - サーバー/クライアントのコードを端末間で分散できる →マイクロサービスに適している - APIの仕様をProtocol BuffersというIDLで作成 →各言語やプラットフォーム向けのコードをIDLから自動生成 - HTTP/2上で動作するため、高い通信効率を発揮
また、通信経路上のコンポーネントすべてがHTTP/2である必要がある →システム内部(マイクロサービス)のAPIに最適
マイクロサービス モジュール同士をAPI経由で組み合わせるアーキテクチャ https://www.ibm.com/blogs/solutions/jp-ja/what-is-microservices/
Protocol Buffers Google社内で10年以上使われている構造化されたデータの独自シリアル方式 言語やプラットフォームに依存しないデータのやり取りができる!! https://grpc.io/docs/what-is-grpc/introduction/
コードの自動生成 protoファイルのアウトプットをProtocol Buffers*でカスタム message Person { required string name =
1; required int32 id = 2; optional string email = 3; } .proto Person john = Person.newBuilder() .setId(1234) .setName("John Doe") .setEmail("
[email protected]
") .build(); output = new FileOutputStream(args[0]); john.writeTo(output); .java Protocol Buffers*による自動生成 ※生成されたコードからロジックを組み立て * `protoc`というProtocol Buffersコンパイラのこと https://developers.google.com/protocol-buffers
HTTP/2 ストリームを多重化させることで、従来のHTTP/1.1よりも高速 https://blog.redbox.ne.jp/http2-cdn.html
サンプル実演会(Rails × Go)
サンプルを用意しました! スマートキャンプさん、ありがとう📛 https://tech.smartcamp.co.jp/entry/2019/03/28/175137
ピンときて、ポン /pingというパスにアクセス pongとレスポンスを返す RailsからGoをgRPC経由で 呼び出します
grpc-sample https://github.com/uh-zz/grpc-sample
まとめ
gRPC、、どうでしたか - RESTの撤廃ではなく、相乗りできる未来がある - protoファイルでAPI定義を一元化できるのは魅力的 - マイクロサービス化にはもってこい - 言語の選択肢をなくさないソリューション なんかよさそう🤔
参考 [OpenStindia](https://openstandia.jp/oss_info/grpc/) [Introduction to gRPC](https://grpc.io/docs/what-is-grpc/introduction/) [Protocol Buffers](https://developers.google.com/protocol-buffers) [HTTP/2の特徴HTTP/1.1との違いについて](https://blog.redbox.ne.jp/http2-cdn.html) [サービス間通信のための新技術「gRPC」入門](https://knowledge.sakura.ad.jp/24059/) [API設計:gRPC、OpenAPI、RESTの概要と、それらを使用するタイミングを理解す
る](https://cloud.google.com/blog/ja/products/api-management/understanding-grpc-openapi-and-rest-and-when-to-use-them) [初めてのgRPC/ Starting gRPC](https://speakerdeck.com/line_developers/starting-grpc) [コピペでできるGoでgRPCサーバ立ててRailsからアクセスする方法](https://tech.smartcamp.co.jp/entry/2019/03/28/175137) [マイクロサービスとは何か -IBM Cloud Blog](https://www.ibm.com/blogs/solutions/jp-ja/what-is-microservices/)