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
uhzz
October 10, 2021
Programming
360
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
970
Goで実現するGraceful Shutdown ~実運用での課題と解決策~ / Go Conference 2025
uhzz
2
1.9k
MCP調べてみました! / Exploring MCP
uhzz
2
4.2k
自動生成されたhttpエンドポイントごとにカスタムミドルウェアを挿入したい話
uhzz
1
3k
Enablement Bootcampを終えて -Enablement Bootcamp for Gopherizing 〜業務で使えるGoを学ぼう〜
uhzz
0
370
安全に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
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
410
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
190
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
420
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
3
330
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
0
310
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
630
信頼性の目標を誰も求めてない
shubox
0
490
自分的「カンファレンスの楽しみ方」
syumai
0
190
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
480
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
54
36k
Featured
See All Featured
The Curse of the Amulet
leimatthew05
2
14k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
870
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
990
Designing Experiences People Love
moore
143
24k
Making Projects Easy
brettharned
120
6.7k
Exploring anti-patterns in Rails
aemeredith
3
490
Paper Plane (Part 1)
katiecoart
PRO
1
11k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
370
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
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/)