26
Distributed Tracing How to do latency analysis for microservice-based applications Reshmi Krishna @reshmi9k

Distributed Tracing Velocity2016

Embed Size (px)

Citation preview

Page 1: Distributed Tracing Velocity2016

Distributed Tracing How to do latency analysis for

microservice-based applications

Reshmi Krishna@reshmi9k

Page 2: Distributed Tracing Velocity2016

About Me

Software Engineer

Platform Architect, Pivotal

Women In Tech Community Members

Twitter : @reshmi9kMeetUp : Cloud-Native-New-York

Page 3: Distributed Tracing Velocity2016

Agenda Distributed Tracing

Tracers and Tracing Systems

Zipkin

Incorporating distributed tracing into an existing micro service

Demo

Page 4: Distributed Tracing Velocity2016

From Monolith ….

Customer

Loyalty

Notifications

Payment

Web Frontend

Page 5: Distributed Tracing Velocity2016

To Microservices .

Page 6: Distributed Tracing Velocity2016

Troubleshooting Latency issues When was the event? How long did it take?

How do I know it was slow?

Why did it take so long?

Which microservice was responsible?

Page 7: Distributed Tracing Velocity2016

Distributed Tracing Distributed Tracing is a process of collecting end-to-end transaction graphs in near real

time

A trace represents the entire journey of a request

A span represents single operation call

Distributed Tracing Systems are often used for this purpose. Zipkin is an example

As a request is flowing from one microservice to another, tracers add logic to create unique trace Id, span Id

Page 8: Distributed Tracing Velocity2016

Visualization - Traces & Spans

UITrace Id : 1, Span Id : 1

Account-MicroserviceTrace Id : 1, Parent Id : 2, Span Id : 5

Back-Office-MicroserviceTrace Id : 1, Parent Id : 1, Span Id : 2

Customer-MicroserviceTrace Id : 1, Parent Id : 2, Span Id : 4

Page 9: Distributed Tracing Velocity2016

Dapper Paper By Google

@reshmi9k

@reshmi9k

This paper described Dapper, which is Google’s production distributed systems tracing infrastructure

Design Goals :Low overheadApplication-level transparencyScalability

Page 10: Distributed Tracing Velocity2016

Zipkin

Zipkin is a distributed tracing system

Implementation based on Dapper paper, Google

Aggregate spans into trace trees

Manages both collection and lookup of the data

In 2015, OpenZipkin became the primary fork

Page 11: Distributed Tracing Velocity2016

Initial Zipkin Architecture

Page 12: Distributed Tracing Velocity2016

Tracers

Tracers add logic to create unique trace ID Trace ID is generated when the first request is made Span ID is generated as the request arrives at each microservice Example tracer is Spring Cloud Sleuth Tracers execute in your production apps! They are written to not log too much Tracers have instrumentation or sampling policy

Page 13: Distributed Tracing Velocity2016

Demo : Architecture Diagram

Spring Cloud Sleuth

Collector

Span Store

TransportMq/Http/Log

Spring Cloud Sleuth

Spring Cloud Sleuth

Spring Cloud Sleuth

QueryServerZipkin UI

ZIPKIN

APP

APP

APP

APP

Page 14: Distributed Tracing Velocity2016

Let’s look at some code & Demo

Page 15: Distributed Tracing Velocity2016
Page 16: Distributed Tracing Velocity2016
Page 17: Distributed Tracing Velocity2016
Page 18: Distributed Tracing Velocity2016
Page 19: Distributed Tracing Velocity2016
Page 20: Distributed Tracing Velocity2016
Page 21: Distributed Tracing Velocity2016
Page 22: Distributed Tracing Velocity2016
Page 23: Distributed Tracing Velocity2016
Page 24: Distributed Tracing Velocity2016
Page 25: Distributed Tracing Velocity2016

Summary Distributed tracing allows you to quickly see latency issues in your system

Zipkin is a great tool to visualize the latency graph and system dependencies

Spring Cloud Sleuth integrates with Zipkin and grants you log correlation

Log correlation allows you to match logs for a given trace

Pivotal Cloud Foundry makes integration of your apps and Spring Cloud Sleuth and Zipkin easier

Page 26: Distributed Tracing Velocity2016

Links Dapper, Google : http://research.google.com/pubs/pub36356.html Code for this presentation : https://github.com/reshmik/DistributedTracingDemo_Velocity2016.git Sleuth’s documentation: http://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html Repo with Spring Boot Zipkin server: https://github.com/openzipkin/zipkin-reporter-java.git Zipkin deployed as an PCF :https://github.com/reshmik/Zipkin/tree/master/spring-cloud-sleuth-

samples/spring-cloud-sleuth-sample-zipkin-stream Pivotal Web Services trial : https://run.pivotal.io/ PivotalCloudFoundry on your laptop : https://docs.pivotal.io/pcf-dev/

@reshmi9k