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

2016 gRPC SF Meetup - Applied Context, Metadata, Propagation - Auth, Trace, Monitoring

Ray Tsang
October 18, 2016

2016 gRPC SF Meetup - Applied Context, Metadata, Propagation - Auth, Trace, Monitoring

A talk on gRPC advanced features such as Context, Metadata and how to propagate metadata information across service calls.

Once we understand how it works, we can apply it to authentication, tracing, and performance monitoring, etc.

Ray Tsang

October 18, 2016
Tweet

More Decks by Ray Tsang

Other Decks in Technology

Transcript

  1. @saturnism @googlecloud @grpcio BigQuery Big Data Pub/Sub Dataflow Dataproc Datalab

    Compute Compute Engine App Engine Container Engine Storage Cloud Storage Cloud SQL Cloud Datastore Bigtable Machine Learning Speech API Machine Learning Translate API Vision API cloud.google.com
  2. @saturnism @googlecloud @grpcio Microservices Concerns Concern What you can use,

    e.g. Load Balancing https://github.com/grpc/grpc/blob/master/doc/load-balancing.md Server-side: Lyft Envoy, NGinx, or Client-side: With Central Registry Service Registry (Client Side LB) Consul, Zookeper, Eureka, gRPC LB Health Checking https://github.com/grpc/grpc/blob/master/doc/health-checking.md gRPC Health Check Protocol Or, Expose endpoints Security TLS, Token headers Authorization Token headers Distributed Tracing Zipkin Monitoring Prometheus
  3. @saturnism @googlecloud @grpcio Microservices Concerns Concern What you can use,

    e.g. Load Balancing https://github.com/grpc/grpc/blob/master/doc/load-balancing.md Server-side: Lyft Envoy, NGinx, or Client-side: With Central Registry Service Registry (Client Side LB) Consul, Zookeeper, Eureka, gRPC LB Health Checking https://github.com/grpc/grpc/blob/master/doc/health-checking.md gRPC Health Check Protocol Or, Expose endpoints Security TLS, Token headers Authorization Tokens, JWT, OAuth Distributed Tracing Zipkin Monitoring Prometheus
  4. @saturnism @googlecloud @grpcio Header Greeting Service Client greeting(HelloRequest) POST /…./GreetingService

    Client-ID: GreetingClientV1 … [HelloRequest payload] Client-ID: GreetingClientV1
  5. @saturnism @googlecloud @grpcio Metadata! Greeting Service Client greeting(HelloRequest) Type-safe construct

    for attaching Header/Trailer to the requests Metadata metadata = new Metadata(); metadat.put(key, value); stub = MetadataUtils.attach(stub, metadata); stub.greeting(request); Client-ID: GreetingClientV1 Metadata: { Client-ID: GreetingClientV1 }
  6. @saturnism @googlecloud @grpcio Getting the Metadata Greeting Service Client greeting(HelloRequest)

    On the server side, intercept the call to get the metadata. Client-ID: GreetingClientV1 Metadata: { Client-ID: GreetingClientV1 } Metadata: { Client-ID: GreetingClientV1 }
  7. @saturnism @googlecloud @grpcio How to access? Context! Greeting Service Client

    greeting(HelloRequest) Client-ID: GreetingClientV1 Metadata: { Client-ID: GreetingClientV1 } Metadata: { Client-ID: GreetingClientV1 } Context Client-ID: GreetingClientV1
  8. @saturnism @googlecloud @grpcio So what is Context again? Carries scoped

    values across API call / threads in the same process But NOT across the wire!
  9. @saturnism @googlecloud @grpcio Propagate - MD → Ctx → MD

    Greeting Service Client Context Client-ID: GreetingClientV1 Client 2 Metadata: { Client-ID: GreetingClientV1 } Translation Service Client-ID: GreetingClientV1
  10. @saturnism @googlecloud @grpcio Use Client Interceptor Greeting Service Client Context

    Client-ID: GreetingClientV1 Client 2 Metadata: { Client-ID: GreetingClientV1 } Translation Service Client-ID: GreetingClientV1
  11. @saturnism @googlecloud @grpcio Answer to everything Metadata → Context →

    Metadata Auth Token Deadline Distributed Trace ID
  12. 17 grpc is Open Source We want your help! http://grpc.io/contribute

    https://github.com/grpc irc.freenode.net #grpc @grpcio [email protected]