Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Practice of distributed Link tracing based on Zipkin

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Author: Ah Fei, Senior Research and Development engineer of Infrastructure of Getui Application platform

01 Business background

With the popularity of micro-service architecture, the system becomes more and more complex, and the single system is divided into many modules. Each module communicates and cooperates with each other through lightweight communication protocols to achieve system functions.

In a single architecture, the call link of a request is very clear. Generally, the load balancer forwards the user request to the back-end service, which carries out business processing, and the required data is obtained from the external storage. After processing the request, it is returned to the user through the load balancer.

In the micro-service architecture, a request often requires multiple modules to work together to process, different modules may also rely on different external storage, and the implementation techniques of each module are not the same. how does a request flow between different modules of the whole system, what is the invocation relationship between the modules in the whole call chain, how long is the processing time of each microservice, and whether the processing result is correct? It is difficult to track, and this information is particularly helpful for the operation and maintenance, performance analysis and fault tracking of the whole system, which leads to a variety of distributed link tracking technologies.

02 status of distributed link tracking

There are many distributed link tracing technologies, some open source and some closed source. Open source has Jaeger, PinPoint, Zipkin, SkyWalking, CAT and so on, closed source has Google Dapper, Taobao's Hawkeye Tracing, Sina's Watchman, Meituan's MTrace and so on. In order to solve the problem of cross-platform compatibility of distributed tracking systems in the industry, CNCF (Cloud Native Computing Foundation) designed the standard of trace and put forward a unified paradigm of distributed tracking system products-OpenTracing,Zipkin also partially supports OpenTracing standards.

03 reasons for choosing Zipkin

In the course of practice, Zipkin is selected for link tracking for the following reasons:

Open source, active community

Support for multiple languages, Nodejs,Lua,Java has open source implementations, and our services are mainly implemented in these three languages

Provide query API to facilitate secondary development

Introduction to the architecture of 04Zipkin

The overall architecture of Zipkin is shown in the following figure:

The overall architecture of Zipkin

(quoted from Zipkin website: https://zipkin.io/pages/architecture.html)

Where:

Instrumented client and Instrumented server need to be integrated into the specific services of the distributed system, collect tracking information, call Transport, and send the tracking information to the Server of Zipkin.

Transport is the interface provided by Zipkin, which supports HTTP, Kafka, Scribe and other communication methods.

Zipkin, namely Zipkin server, mainly consists of four modules:

Collector: used to receive tracking information transmitted by various application services

Back-end storage for Storage:Zipkin, supporting In-Memory, MySql, Elasticsearch and Cassandra

API: provides external query interface

UI: provides external Web interface.

Time sequence diagram of Http Tracing

(quoted from Zipkin website: https://zipkin.io/pages/architecture.html)

The above is the timing diagram of Http Tracing. The user's request / foo is first intercepted by Trace Instrumentationlan, Tags and timestamp are recorded, Trace information is added to Header, and then transferred to the back-end service for processing. After processing, the normal response is intercepted by Trace Instrumentationlan. After recording processing delay, the Response is returned to the caller normally, and the Span of Trace is sent to Zipkin Server asynchronously. The traceId in Span is a unique ID on the entire call link and is used to uniquely identify a call chain.

05 tweets of Zipkin practice

Microservices are deployed based on Kubernetes and Docker, and each microservice corresponds to a set of Pod in Kubernetes.

In the whole micro-service system, the API gateway is developed based on Openresty, which is mainly developed by Lua; the back-end service is mainly developed and implemented by Node.js and Java. When interfacing with Zipkin, different micro-services are implemented in different ways.

The API gateway mainly connects with Zipkin by adding gateway plug-ins (mainly referring to Kong's Zipkin plug-in implementation); the services implemented by Node.js mainly use middleware to interface with Zipkin; and Java services use spring-cloud-sleuth to dock with Zipkin. The overall architecture is shown in the following figure:

The overall architecture of distributed link tracking system based on Zipkin

Among them, Zipkin is also containerized and deployed in Kubernetes clusters, which simplifies the construction and deployment of Zipkin. As shown in the following figure, the call link of the request can be easily tracked through Zipkin, and the processing time of each service in the entire call chain, the response status, and the invocation relationship between services can be easily queried in Zipkin. Zipkin is also very helpful to analyze the performance bottleneck of the whole system and locate the fault.

Web interface of Zipkin

06 summary

As a distributed link tracking system, Zipkin has the advantages of less application intrusion, high community activity and supporting multiple languages. Generally, the implementation based on open source can be docked with Zipkin with a little modification. Therefore, Zipkin is also introduced into the micro-service architecture, using Zipkin to track the invocation relationship of micro-services, performance analysis and fault diagnosis of micro-services. In the future, a push will be based on Zipkin for secondary development to provide a more friendly interface.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report