Professional Documents
Culture Documents
Microservices Summit
Varun Talwar
Borg
Kubernetes
Stubby
LEARNINGS FROM
STUBBY
Key learnings
1. HTTP/JSON doesnt cut it !
2. Establish a lingua franca
3. Design for fault tolerance and provide control knobs
4. Dont fly blind: Service Analytics
5. Diagnosing problems: Tracing
6. Load Balancing is critical
1 HTTP/JSON doesnt cut it !
18
Deadline Propagation
withDeadlineAfter(200, MILLISECONDS)
40 ms 20 ms 60 ms
90 ms 20 ms
Gateway
etc
20
Cancellation?
Active RPC
Active RPC
Automatically propagated.
23
BiDi Streaming - Slow Client
Request
Responses
CANCELLED
UNAVAILABLE
RESOURCE_EXHAUSTED
Response
Requests
CANCELLED
UNAVAILABLE
RESOURCE_EXHAUSTED
27
Metadata helps in exchange of useful information
Stats layer export data to varz and streamz, and provides stats to many
monitoring systems and dashboards
5 Diagnosing problems: Tracing
1/10K requests takes very long. Its an ad query :-) I need to find out.
Take a sample and store in database; help identify request in sample which
took similar amount of time
I didnt get a response from the service. What happened? Which link in the
service dependency graph got stuck? Stitch a trace and figure out.
Where is it taking time for a trace? Hotspot analysis
What all are the dependencies for a service?
5 Load Balancing is important !
For anything more advanced, move the burden to an external "LB Controller", a
regular gRPC server and rely on a client-side implementation of the so-called
gRPC LB policy.
gRPC LB
1) Control RPC
client LB Controller
2) address-list
In summary, what did we learn
Contracts should be strict
Common language helps
Common understanding for deadlines, cancellations, flow control
Common stats/tracing framework is essential for monitoring, debugging
Common framework lets uniform policy application for control and lb
gRPC Java
gRPC Go
http://www.grpc.io/blog/principles
gRPC GoLang
Service Service
gRPC
Stub
Java
Service gRPC gRPC
Stub Service
gRPC
Stub gRPC
Service
gRPC
Python Stub C++
Service Service
DATA Frame
Header Compression.
Unary RPCs where the The client sends a The client send a Both sides send a
client sends a single request to the server sequence of messages sequence of messages
request to the server and gets a stream to to the server using a using a read-write
and gets a single read a sequence of provided stream. stream. The two
response back, just like messages back. Once the client has streams operate
a normal function call. The client reads from finished writing the independently. The
the returned stream messages, it waits for order of messages in
until there are no more the server to read them each stream is
messages. and return its response. preserved.
Messaging applications.
Moving objects.
Sport results.
48
Performance
Pluggable
http://www.grpc.io/blog/principles
Client Server
interceptors interceptors
Request
Client Server
Response
Auth & Security - TLS [Mutual], Plugin auth mechanism (e.g. OAuth)
Proxies
Basic: nghttp2, haproxy, traefik
Advanced: Envoy, linkerd, Google LB, Nginx (in progress)
Service Discovery
etcd, Zookeeper, Eureka,
Monitor & Trace
Zipkin, Prometheus, Statsd, Google, DIY
More lessons
1. Server reflection
2. Health Checking
3. Automatic retries
4. Streaming compression
5. Mechanism to do caching
6. Binary Logging
a. Debugging, auditing though costly
7. Unit Testing support
a. Automated mock testing
b. Dont need to bring up all dependent services just to test
8. Web support
Some early adopters
Mobile Apps
Thank you!
Thank you!
Twitter: @grpcio
Site: grpc.io
Group: grpc-io@googlegroups.com
Repo: github.com/grpc
github.com/grpc/grpc-java
github.com/grpc/grpc-go
Q&A
Why gRPC?
1m+ QPS - unary, 3m+ streaming Auth, Transport, IDL, LB 2-3X gains
(dashboard)
https://blogs.oracle.com/jag/resource/Fallacies.html
Direct RPCs :
Microservices
On Other
GCP
Prem Cloud
How is gRPC Used?
Direct RPCs :
Microservices
On GCP Other
Prem Cloud
Google APIs
RPCs to
access APIs
Your APIs
How is gRPC Used?
Direct RPCs :
Microservices
Mobile/Web
RPCs
On Other
GCP Cloud
Prem
Your
Mobile
/Web
Apps
Google APIs
RPCs to
access APIs
Your APIs
What are the benefits?
Layered
http://www.grpc.io/blog/principles
Transport API
Layered Architecture
RPC Client-Side App RPC Server-side Apps
HTTP/2
gRPC (http://grpc.io):
HTTP/2 transport based, open source, general purpose
standards-based, feature-rich RPC framework.
Bidirectional streaming over one single TCP connection.
Netty transport provides asynchronous and non-blocking I/O.
Deadline and cancellations propagation.
Client- and server-side flow-control.
Layered, pluggable and extensible.
Supports 10 programming languages.
Build-in testing support.
Production-ready (current version is 1.0.1) and growing ecosystem.
Migration.
Testing.
Swagger / OpenAPI
tooling.
Protocol Structure
Request <Call Spec> <Header Metadata> <Messages>*
Response <Header Metadata> <Messages>* <Trailing Metadata> <Status>
Generic mechanism for attaching metadata to requests and responses
Commonly used to attach bearer tokens to requests for Auth
OAuth2 access tokens
JWT e.g. OpenId Connect Id Tokens
Session state for specific Auth mechanisms is encapsulated in an
Auth-credentials object