29
©2016 Apigee Corp. All Rights Reserved.

gRPC: The Story of Microservices at Square

Embed Size (px)

Citation preview

Page 1: gRPC: The Story of Microservices at Square

©2016 Apigee Corp. All Rights Reserved.

Page 2: gRPC: The Story of Microservices at Square

©2016 Apigee Corp. All Rights Reserved.

Slideshare slideshare.com/apigee

Apigee Community https://community.apigee.com

YouTube"youtube.com/apigee

Page 3: gRPC: The Story of Microservices at Square
Page 4: gRPC: The Story of Microservices at Square

gRPC: Microservices at Square Manik Surtani Senior Infrastructure Engineer, Square @maniksurtani

Page 5: gRPC: The Story of Microservices at Square
Page 6: gRPC: The Story of Microservices at Square

We <3 JSON/HTTP

Page 7: gRPC: The Story of Microservices at Square

We also <3 monoliths* (*) Not really. http://squ.re/spot

Page 8: gRPC: The Story of Microservices at Square

We preferred microservices

Page 9: gRPC: The Story of Microservices at Square

Java

Go

Ruby

Page 10: gRPC: The Story of Microservices at Square

Java

Go

Ruby

x 500

Page 11: gRPC: The Story of Microservices at Square

Stubby and Sake

● JSON/HTTP for mobile & web client comms ● Replace server comms with Sake ● Stubby DNA ● Implements protobuf services ○ proto2

Page 12: gRPC: The Story of Microservices at Square

Sake Often better warm

● Java ○ Asynchronous comms, blocking APIs ○ Deadline propagation ○ ACLs ○ Integrates with service discovery ○ Distributed tracing ○ Retry logic ● Ported to Go ● Ruby support via a sidecar ○ Based on the Java impl

Page 13: gRPC: The Story of Microservices at Square

Modernizing Sake

● Move networking to Netty ● Open source Sake! ● Move to HTTP/2 ○ Streaming! ● Native Ruby implementations ○ No more sidecars

Page 14: gRPC: The Story of Microservices at Square

ARCWire

● A Google effort ● A proto service based RPC

framework ● Stubby DNA ● HTTP/2 ● Open Source

Page 15: gRPC: The Story of Microservices at Square
Page 16: gRPC: The Story of Microservices at Square

gRPC Features

● Request/response as well as bidirectional streams ● Synchronous and asynchronous ● Backed by non-blocking IO ● Header compression ● Multiplexing requests over a single connection ● Built with mobile clients in mind ○ Better battery life, data usage than JSON/HTTP

Page 17: gRPC: The Story of Microservices at Square

Supported Platforms

Java (inc. Android) Python Go PHP C Ruby C++ Node.js Objective-C C#

Page 18: gRPC: The Story of Microservices at Square

Message format

● Built for protocol buffers * ● Pluggable ● Other serialization formats could be used instead ○ Avro, Thrift, Cap’n Proto, etc.

* http://developers.google.com/protocol-buffers

Page 19: gRPC: The Story of Microservices at Square

Protocol buffers

● Language-neutral, platform-neutral ● Extensible ● Binary, very compact ● Strongly typed ● Versioned ● Easily transformed to JSON for debugging

Page 20: gRPC: The Story of Microservices at Square

Protocol Buffers

Page 21: gRPC: The Story of Microservices at Square

Protocol Buffer Services

Page 22: gRPC: The Story of Microservices at Square

Protocol Buffers

Page 23: gRPC: The Story of Microservices at Square

gRPC Server

Page 24: gRPC: The Story of Microservices at Square

gRPC Server

Page 25: gRPC: The Story of Microservices at Square

gRPC Client

Page 26: gRPC: The Story of Microservices at Square

Adding gRPC to your stack

● Protobuf version control ● Service discovery ● Load balancing ● Security ● Logging ● Metrics

Page 27: gRPC: The Story of Microservices at Square

gRPC performance

● Measured by etcd * ● 120µs round trips, compared to 1.6ms roundtrips for JSON/HTTP ● 3 orders of magnitude?!

* http://bit.ly/etcd_grpc

Page 28: gRPC: The Story of Microservices at Square

©2016 Apigee Corp. All Rights Reserved.

Slideshare slideshare.com/apigee

Apigee Community https://community.apigee.com

YouTube"youtube.com/apigee

Page 29: gRPC: The Story of Microservices at Square

Thank you