Upgrade to Pro — share decks privately, control downloads, hide ads and more …

gRPC: Integrating east / west services in high performance!

gRPC: Integrating east / west services in high performance!

During my journey in microservices, it became apparent that the REST standard has been widely used in communication between microservices for a long time. But recently gRPC started to invade its territory. It turns out that there are some good reasons for this.

In this lecture I will present an introduction to gRPC, its main characteristics and the reasons why companies like Google, Netflix and Docker will adopt this flexible and performative means of communication.

Ef3b48913ea26665c25b2ad78e449d16?s=128

Luram Archanjo

June 26, 2020
Tweet

Transcript

  1. Integrating east / west services in high performance! Luram Archanjo

  2. Who am I? • Software Engineer at Sensedia • MBA

    in Java projects • Java and Microservice enthusiastic
  3. Agenda • Microservices • Communication Pattern • gRPC • Questions

  4. Moving to Microservices Feature A Feature B Feature C Monolith

    Microservice Microservice Microservices Microservice
  5. • Communication • Security / Authentication • Network Communication Speed

    • Language Interoperability Challenges with Microservices
  6. Communication Microservice Microservice Microservice Microservice Microservice Microservice Microservice Microservice

  7. Communication Microservice Microservice Microservice HTTP + JSON REpresentational State Transfer

    Microservice Microservice BD
  8. Microservice Communication Microservice Microservice Microservice Microservice Microservice Microservice Microservice Microservice

  9. Communication Patterns

  10. Communication Patterns Microservice Microservice API GATEWAY Microservice Microservice API GATEWAY

    North / South East / West
  11. Communication Patterns Microservice Microservice API GATEWAY East / West Synchronous

    Microservice Microservice API GATEWAY East / West Asynchronous REST
  12. Communication Patterns Microservice Microservice API GATEWAY East / West Synchronous

    REST • Web already built on top of HTTP • Easy to understand • Variety of http implementation in any languages • Loose coupling between client and server
  13. Communication Patterns Microservice Microservice API GATEWAY East / West Synchronous

    REST • Operations are difficult to model • Streaming is difficult to implement • Bi-directional streaming is not possible • Inefficient, textual representation are not optimal for networks
  14. Ok….REST is OK for IPC, but I want to improve!

  15. None
  16. What is RPC and gRPC?

  17. • A high-performance open-source universal RPC framework • Based on

    “Stubby” (Google’s internal RPC system) • Part of Cloud Native Computing Foundation
  18. So what makes gRPC so effective?

  19. • Strongly typed • Rules for making backwards compatible changes

    • Efficient binary data representation for network transmission • Comprehensive style guide Protocol Buffers Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.
  20. Interface Definition Language The API definition and structure of the

    payload messages. syntax = “proto3”; message PersonRequest { string name = 1; int32 age = 2; } message PersonResponse { int32 id = 1; string name = 2; int32 age = 3; } service PersonService { rpc create(PersonRequest) returns (PersonResponse); }
  21. Define once, generates well-structured code for all supported language!

  22. Ruby microservice gRPC server Go microservice gRPC server gRPC Stub

    Java microservice gRPC Stub Python microservice gRPC server gRPC Stub Multiple Language Support
  23. Multiple Platform Support

  24. Works over HTTP 2

  25. History of HTTP HTTP 0.9 1991 HTTP 1 1996 HTTP

    2 2015 HTTP 1.1 16 years without evolution 1999
  26. HTTP 2 • Multiplexing • Bidirectional Streaming • HTTPS •

    Performance HTTP 2 HTTP 1.x
  27. HTTP 2 • Multiplexing • Bidirectional Streaming • HTTPS •

    Performance
  28. HTTP 2 • Multiplexing • Bidirectional Streaming • HTTPS ◦

    SSL/TLS ◦ Token authentication ◦ Channel credentials ◦ Call credentials • Performance
  29. HTTP 2 • Multiplexing • Bidirectional Streaming • HTTPS •

    Performance HTTP 1.1 HTTP 2
  30. Connection options The client sends a single request and gets

    back a single response Unary RPC The server sends back a stream of responses after getting the client’s request message Server streaming RPC The client sends a stream of requests to the server instead of a single request Client streaming RPC The call is initiated by the client calling the method and the server receiving the client metadata, method name, and deadline Bidirectional streaming RPC
  31. Connection options Unary RPC rpc SayHello(HelloRequest) returns (HelloResponse); Server streaming

    RPC rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse); Client streaming RPC rpc LotsOfGreetings(stream HelloRequest) returns (HelloResponse); Bidirectional streaming RPC rpc BidiHello(stream HelloRequest) returns (stream HelloResponse);
  32. Who is using gRPC?

  33. Companies

  34. Community

  35. Why mainly Google and Netflix are using gRPC?

  36. Performance Sources: https://cloud.google.com/blog/products/gcp/announcing-grpc-alpha-for-google-cloud-pubsub

  37. Performance Sources: https://blog.gopheracademy.com/advent-2015/etcd-distributed-key-value-store-with-grpc-http2, https://auth0.com/blog/beating-json-performance-with-protobuf

  38. Flexibility & Summary Source: https://www.infoq.com/presentations/grpc

  39. Where to use gRPC?

  40. Use case gRPC shines as a way to connect servers

    in service-oriented environments Microservices gRPC works just as well in client-server applications, where the client application runs on desktop or mobile devices Client-Server Application gRPC is also a way to offer APIs over the Internet, for integrating applications with services from third-party providers Integrations and APIs Connecting mobile devices, browser clients to backend services Browser-based Web Applications
  41. Thanks a million! /larchanjo /luram-archanjo