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
Kenta Suzuki
April 24, 2018
Programming
11k
18
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
フロントエンドエンジニアも知っておきたいgRPC
#roppongijs #2 で話しました
Kenta Suzuki
April 24, 2018
More Decks by Kenta Suzuki
See All by Kenta Suzuki
レガシーアプリケーションのリニューアルにNuxt.jsで戦う #vuefes_reject
suusan2go
9
22k
rescue されない例外?! / A Exception not rescue #megurorb
suusan2go
0
3k
Rails サービスクラス再考 / have a rethink on Rails service class
suusan2go
8
12k
Flutterでアプリ作ってる話
suusan2go
2
3k
Nuxt.js + TypeScript = Great!
suusan2go
8
42k
ポストRailsとしてのKotlin + Spring Boot #m3kt
suusan2go
4
2.3k
gRPC on Spring Boot
suusan2go
0
3.2k
ずっとRubyをやっていたエンジニアがGoに入門して挫折して再挑戦した話
suusan2go
2
5.4k
非SPAなRailsアプリでレールに乗りつつReactを使う話
suusan2go
6
8k
Other Decks in Programming
See All in Programming
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
150
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
140
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
7k
Performance Optimization With LLMs
xleitix
0
200
続・コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions-again
handlename
0
120
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
ActionController meets Protocol Buffers
sorah
1
710
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
140
Groovy as a human and AI friendly programming language
paulk
0
110
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
120
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
11
3.6k
Jetpack Compose Mechanisms
skydoves
3
870
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
450
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
420
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
420
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Why Our Code Smells
bkeepers
PRO
340
58k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
The agentic SEO stack - context over prompts
schlessera
0
980
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Transcript
フロントエンドエンジニアも知って おきたいgRPC #Roppongi.js 2018/04/24 @suusan2go
自己紹介 • Kenta Suzuki / @suusan2go • M3,inc / Software
Engineer • 経験値で言うとこんな感じ ◦ Ruby > JavaScript > Kotlin(ServerSide) > Golang • 半分くらいサーバーサイドエンジニア
みなさんAPIどうやって実装・管理してますか • 前回の#roppongi.jsで聞いたときはSwaggerでやってる人多数 • Swagger Editorで記述してくの結構辛いみたいな話を何人も聞いた • 理想のRESTみたいなの作るのも維持していくのも結構たいへん
gRPC
gRPCとは • HTTP/2を使ったRPCフレームワーク • 2015年にGoogleが公開(ちなみにgRPCのgはGoogleではない) • ProtocolBuffersでインターフェースを定義。そこからクライアント / サーバ の実装を生成出来る
• メルカリさんや、サイバーエージェントさんで事例
Protocol Buffers
gRPCのサーバ(Go Server)
gRPCのクライアント(Node Client)
gRPCの利点 • メソッド名、リクエスト、レスポンスの型だけ決めれば良い ◦ URL、パラメータの渡し方、メソッドどうする?で悩まなくていい • 異なる言語、サーバ間でもType Safeにやり取りできる ◦ Go
/ JS / Java / Ruby / C ++ / Python / Node … https://grpc.io/docs/ • ブラウザでは動かないけどな!
gRPC-Web
• gRPCのクライアントをブラウザで動かせる! • HTTP/*で動く • ブラウザの制限によりgRPCの一部の機能はまだ使えない bidirectional streamingとか https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md gRPC-Web
gRPC-WEBの実装
gRPC-WEBの実装 • improbable社?がgRPCをWEBで使うために 実装した。この実装が本家にも FB。 • TypeScript Generator ◦ (protoファイルからTypeScriptファイル
を作成) • gRPC-Web Client ◦ (Web用のgRPCクライアント実装) • grpcwebproxy ◦ (バックエンドのgRPCの前段に配置) • grpcweb ◦ (Go向けのgRPCサーバwrapper)
gRPC-WEBの実装 • 長らくearly acessということでprivateだった が、2018年の3月頃に再びpublicに? • gRPC公式のWEB実装 • 現在はβリリース! 今日話すのはこっちの話!
(現状の)公式gRPC-Webの構成 • nginxによるproxy ◦ これによりブラウザからのリクエストをgRPCのリクエストに変換して gRPCサーバに送る ◦ 先日envoyというプロキシもgRPC-Webをサポートした • Browserで動作できるJSクライアントを生成するためのモジュール
◦ 最終的にClosure CompilerでJSにコンパイルする
(現状の)公式gRPC-Webの構成 gRPC Server HTTP/* HTTP/2 gRPC-Web gRPC ※独自モジュールを追加 grpc_gateway_module.c
gRPC-Webを使ったアプリケーション • 公式のrepositoryにDockerのサンプルが用意されている • めちゃくちゃ色々ビルドが走るので、ローカル環境で動かすのはなかなか 大変そう ◦ nginxのビルド ◦ protocol
buffersからgRPCコードの生成 C++ / JavaScript ◦ Closure Compilerでのコンパイル ◦ TODO Listくらい作ってやろうと思ってましたがdocker buildが途中で 固まってサンプル動かす所で終わってしまった
None
None
None
今後のgRPC-Webのロードマップ • gRPCで得られるメリットをそのままブラウザにも持ち込める ◦ JSが動かせればよいので、例えばReact Nativeとかでも使えるはず • 現状は素のJSしか生成してくれないのでTypeSafeではないが、 TypeScript supportはWork
In Progress ◦ https://github.com/grpc/grpc-web/blob/master/ROADMAP.md
• binary protobuf encodingなので、Chrome Developer Toolsで確認する のはちょっとしんどい ◦ Non-binary message
encodingがWork In Progress ◦ 上記の解決というよりはパフォーマンスに課題感を感じているらしい ◦ gmailなんかではJSON LIKEなフォーマットが使われているらしい (JSON likeとは・・・) 今後のgRPC-Webのロードマップ
• Proxy層(nginx / envoy)を挟むのがちょっと… ◦ Local Proxyを検討中らしい。要はgRPCのサーバに直接組み込める gRPC-Web用のProxy。nginxなどを立てる必要がなくなる。 • React
/ Vue / Angular でどう使えばいいの? ◦ This is to provide first-class support for gRPC API and gRPC-Web in popular Web frameworks such as Angular. とのこと ◦ メジャーどころは何かしらサポートがありそう 今後のgRPC-Webのロードマップ
ロードマップが全て達成されると… .proto ファイル gRPC Server Local Proxy gRPC Server Local
Proxy HTTP/* HTTP/* HTTP/*
RESTと同じインフラでgRPCが使える! .proto ファイル gRPC Server Local Proxy gRPC Server Local
Proxy HTTP/* HTTP/* HTTP/*
gRPC-Web はオススメ? • TypeScript Support / Non-binary message encoding が実装されたら、か
なりTypeSafeなフロントエンドの開発が実現できそうなので、 結構自分は 期待している • nginxのgRPCサポートなど、周辺のツールやミドルウェアも揃ってきてる印 象ある。Local Proxyが実装されると、REST APIと同じインフラでもgRPCの 恩恵が得られそう!
まとめ • 現状の grpc/grpc-web はβとは言っているものの、なかなかこれでプロダ クト開発していくのはしんどそう • improbable-eng/grpc-web に既に実アプリで使えるツール群が揃ってい るので、プロダクションで使うならまだこちらがオススメという所感です
• 公式?のgrpc-webは The current release is a Beta release, mainly for early adopters to provide feedback on the JS API. とのことなので、みなさん使っ てフィードバックしましょう!
ありがとうございました