grpc 101 - devfest belgium 2016
TRANSCRIPT
GRPC 101by Alex Van Boxel (@alexvb)
Alex Van BoxelSoftware Architect @ Vente-Exclusive.com
Google Cloud Developer Expert
Remember RPC
History: CobraSpec # pages
Part 1: CORBA Interfaces 532
Part 2: CORBA Interoperability 236
Part 3: CORBA Component Model 380
History: DCOMOh, my... If you think COM is scary...
D-COM
History: RMIQuite OK... but interop?!
History: SOAPInterop, but XML
Sooo, slow
WS-* (dead-star)
RESTResource Oriented
JSON over REST
Successful model
So why RPC again?!
Microservices
GRPC Remote ProcedureCall
GRPC@google everything build with RPC
Comes from 4 generations of RPC
Stubby 1,2,3
10^10 RPC calls per second
Google and Square
SimplePerformant and ScalableInteroperable and Extensible
Protobuffer 3IDLHTTP/2
Protocol BufferStructured representation of Data
IDL: Interface Defenition Language
Binary format
Well-Know Types
Proto: Code Generation
Proto: LanguagesJava, C++, Node.JS, Ruby, Python, ObjectiveC, Go, PHP
Proto: Messagessyntax = "proto3";
message SearchRequest { string query = 1; int32 page_number = 2; int32 result_per_page = 3; }
Proto: Servicesservice SearchService { rpc Search (SearchRequest) returns (SearchResponse); }
Proto: Optionspackage grpc.health.v1; option csharp_namespace = "Grpc.Health.V1";
option java_multiple_files = true; option java_package = "io.grpc.health.v1"; option java_outer_classname = "HealthProto";
HTTP/2
HTTP/2Binary
Multiplexing
HTTP/1 vs HTTP/2
HTTP/2Binary
Multiplexing
Secure
HTTP/1 TLS keys
HTTP/2Binary
Multiplexing
Secure
Streaming
HTTP/2: StreamingServer Side Streaming
Client Side Streaming
Bi-Directional Streaminf
Standard ErrorsGRPC_STATUS_CANCELLED Client application
cancelled therequest
GRPC_STATUS_DEADLINE_EXCEEDED Deadline expiredbefore serverreturned status
GRPC_STATUS_RESOURCE_EXHAUSTED Flow-controlresource limitsreached
GRPC_STATUS_UNAUTHENTICATED Unauthenticated:credentials failedto get metadata
GRPC_STATUS_CANCELLED Client applicationcancelled therequest
...
HTTP not to be confused...Semantics, no it's not REST
You won't �nd the GET/POST/DELETE/PATCH
Not everything is a resource
Code session
Gravity RPC
GRPC: Unique Features
ExtensibleFrom the ground up
Extensible
Binding through Context
Context
Deadlines
Cancel
Versioning Strategies
Versioningmessage Blip { google.protobuf.Timestamp timestamp = 1; BlipType blip_type = 2; Coordinate coordinate = 3; Planet planet = 4; Missle missle = 5; }
Proto message �elds are tagged
Versioningmessage Blip { google.protobuf.Timestamp timestamp = 1; BlipType blip_type = 2; Coordinate coordinate = 3; Planet planet = 4; Missle missle = 5; Base base = 6; }
Extend messages by adding unique tags
Versioningmessage Blip { google.protobuf.Timestamp timestamp = 1; BlipType blip_type = 2; Coordinate coordinate = 3; Planet planet = 4; Base base = 6;
reserved 5; reserved "missle" }
Reserve �eld names and tags for deprecation
Versioningpackage grpc.health.v1; option csharp_namespace = "Grpc.Health.V1";
option java_multiple_files = true; option java_package = "io.grpc.health.v1"; option java_outer_classname = "HealthProto";
Using package names to introduce big changes
First Class Microservice ProtocolSimplePerformant and ScalableInteroperable and ExtensibleLanguage Support