Zipkin
A distributed trace collection and query system
A distributed trace collection and query system
Zipkin is an open-source distributed tracing system developed at Twitter. Inspired by Google's Dapper paper, it was started in 2012 and visualizes the path a request takes through multiple services in a microservices environment and analyzes latency.
The core concepts are Trace (the entire request flow), Span (an individual unit of work), and Annotation (a timestamped event). Each Span is linked by a traceId, so even if a single request passes through 10 services, the entire flow can be traced.
The architecture consists of the Collector (data collection), Storage (supports Cassandra, Elasticsearch, and MySQL), the Query Service (search API), and the Web UI (visualization). In each service, an instrumentation library automatically creates Spans and sends them to the Collector.
In practice, it is integrated with Spring Cloud Sleuth and OpenTelemetry for automatic instrumentation. It is essential for P99 latency analysis, generating service dependency maps, and finding the bottleneck of a specific request, and when an incident occurs, you can identify within 5 minutes which service has the problem.
# docker-compose.yml - Zipkin ์๋ฒ ์คํ
version: '3'
services:
zipkin:
image: openzipkin/zipkin:latest
ports:
- "9411:9411"
environment:
- STORAGE_TYPE=elasticsearch
- ES_HOSTS=elasticsearch:9200
depends_on:
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- "9200:9200"
---
# Spring Boot application.yml ์ค์
spring:
application:
name: order-service
zipkin:
base-url: http://zipkin:9411
sender:
type: web
sleuth:
sampler:
probability: 1.0 # ๊ฐ๋ฐ: 100%, ์ด์: 0.1(10%)
---
# OpenTelemetry Java Agent ์ฌ์ฉ ์
# java -javaagent:opentelemetry-javaagent.jar \
# -Dotel.exporter.zipkin.endpoint=http://zipkin:9411/api/v2/spans \
# -Dotel.service.name=payment-service \
# -jar app.jar
Senior: "We got a customer support ticket saying the payment API response is slow. Can you look up the traceId in Zipkin?"
Junior: "Yes, I searched that time window, and there was a 3-second delay in inventory-service. It looks like the DB query needs tuning."
Interviewer: "Do you know the differences between Zipkin and Jaeger?"
Candidate: "Both are distributed tracing tools, but Jaeger is a CNCF project that is Kubernetes-friendly and supports adaptive sampling. Zipkin is lighter and has rich support for various languages, which makes it advantageous for integration with legacy systems."
Take a mock interview on this topic โ WIA SOOM AI Interview ยท Start for free
Reviewer: "sampler.probability is 1.0 โ won't that cause overhead problems in production?"
Developer: "I lowered it to 0.1 in the configuration file for the production environment. It's separated by profile."