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
940
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
890
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
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
250
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
310
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
150
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.9k
VibeCodingからAgenticWorkflowへ
starfish719
0
360
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
210
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
590
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
410
FDEが実現するAI駆動経営の現在地
gonta
2
280
yield再入門 #phpcon
o0h
PRO
0
1k
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
290
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Chasing Engaging Ingredients in Design
codingconduct
0
260
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
480
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
240
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1.1k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
250
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
520
The Limits of Empathy - UXLibs8
cassininazir
1
600
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/)