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
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
990
Goで実現するGraceful Shutdown ~実運用での課題と解決策~ / Go Conference 2025
uhzz
2
2k
MCP調べてみました! / Exploring MCP
uhzz
2
4.2k
自動生成されたhttpエンドポイントごとにカスタムミドルウェアを挿入したい話
uhzz
1
3.1k
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
一人だけ、Kiroが静止する日
hideg
0
140
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
iOSDCのペンライトを自動制御したい!
akkeylab
0
300
Intent as Code
shoppingjaws
6
1.1k
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
110
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
150
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
180
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
370
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
450
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.6k
AHC070解法紹介
eijirou
0
150
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
The SEO identity crisis: Don't let AI make you average
varn
0
570
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Amusing Abliteration
ianozsvald
1
320
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Designing Experiences People Love
moore
143
24k
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/)