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
From PHP and REST to gRPC and Go
Search
Yuriy Tuz
December 04, 2019
Programming
88
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
From PHP and REST to gRPC and Go
Yuriy Tuz
December 04, 2019
More Decks by Yuriy Tuz
See All by Yuriy Tuz
From PHP and REST to gRPC and Go Full
yuriytuz
0
55
Other Decks in Programming
See All in Programming
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
880
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
190
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
270
Event is what happens
moro
2
770
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.2k
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
410
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
130
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
500
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Building AI with AI
inesmontani
PRO
1
1.3k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Making the Leap to Tech Lead
cromwellryan
135
10k
New Earth Scene 8
popppiees
4
2.7k
Designing for humans not robots
tammielis
254
26k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
A designer walks into a library…
pauljervisheath
211
25k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
490
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Transcript
From PHP and REST To gRPC and Go Winnipeg, December
4 2019 Yuriy Tuz Bold Commerce @yuriytuz
#GoTurns10
whoami
Objectives • Personal experience • Why gRPC • gRPC in
GO ◦ Simple implementation
In the beginning • Laravel 4.x / 5.x • PHP
7.x ◦ Introduced types
Back in the day
REST (HTTP + JSON) • Not a bad solution •
Service to service communications • JSON is not type safe in PHP • (De)Serialization performance • Text protocol
Thank you Questions?
REST in Laravel • api.php • Magic • response()->json([???]) •
Docs accuracy
Problem • Technology is driving demand • Languages and platforms
◦ Different dev experience • Software architecture is evolving ◦ Microservices and containers ◦ CI/CD
An Idea
An Idea • Bloated service ◦ 1000+ lines • Hack
Day • How?
No Idea
How/why? • Why split? • Why Go? • Why not
REST (HTTP+JSON)? ◦ No formal contract ◦ Hard to implement correctly
Possible Solution
What do we need? • PHP RPC client • RPC
server
Implementation/Findings • PHP client not fun ◦ Working POC •
First experience with Go • Refactoring • Benchmarks ◦ ~100x faster
time.Now()
Stack • Protocol buffers + gRPC • Thanks Google
Protocol buffers are a language-neutral, platform-neutral extensible mechanism for serializing
structured data. Protocol Buffers
What does this mean? • Serialization mechanism • Interface description
language
Serialization Mechanism • 0a 05 68 65 6c 6c 6f
• 68 65 6c 6c 6f -> hello • 05 -> length of “hello” • 0a is “0000 1010”, so • field_number = 1 • wire_type = 2 (length delimited)
Interface Definition Language message Person { string name = 1;
} Interface for your API
gRPC • Open source messaging system by Google that can
run anywhere • Low latency • Highly scalable • Great for distributed systems • Accurate, efficient, language independent
Adopted by many (and more)
Let’s do it
echo.proto
Let’s generate • protoc --go_out=:. ./echo.proto ◦ Default protobuf generation
• protoc --go_out=plugins=grpc:. ./echo.proto ◦ Client and Server interface ◦ gRPC
Success!
Server
Generated Interface
Server implementation
Server Spin up server
Client
Client interface
Client
So far • Server • Client
New Requirement Logging
gRPC middleware • Server or Client • Few exist in
gRPC ecosystem ◦ Prometheus ◦ Open tracing • https://github.com/grpc-ecosystem/go-grpc-middleware
How?
gRPC middleware
>1 interceptor?
Directory structure • Client & server implementation • echo.pb.go ◦
gRPC generated • echo.proto ◦ API definition
Helpful tools
grpcurl • “curl” for gRPC • Requires server reflection
None
Examples
grpcui • Postman for RPC • Also requires reflection
None
None
Final thoughts The good • Code generation ◦ Less error
prone • API spec • gRPC ◦ HTTP2 + language support • Type safety • Plugins • Dev ramp up speed The bad • Code generation • Model conversions ◦ Nested messages • Hard/scary to get started ◦ Documentation • API versioning
TL;DR • Use gRPC + Go • Generate code •
Implement stubs • Profit
Credits/Useful links • Gopher art by Ashley McNamara ◦ https://github.com/ashleymcnamara/gophers
• gRPC ◦ https://grpc.io/ • Google API Design Guide ◦ https://cloud.google.com/apis/design/ • Protobuf Style Guide ◦ https://developers.google.com/protocol-buffers/docs/style • rpcurl and grpcui ◦ https://github.com/fullstorydev
Questions? @yuriytuz
None