Distributed service call tracking and chain Zikpin

Trace the distributed services generated by the call chain system

In service, if the dependencies between services and service complex, a service if there are some problems, it is difficult to track down the cause, in particular, calls between services and service time.

In the micro-services system, with business development, the system will become more and more, then call the relationship between the various services will become more complex . An HTTP request invoked a number of different micro-processing services to return the final result, in the course of this call, you may experience network delays because of a service error is too high or send request failed, this time, the monitoring of call requests it is particularly important. Spring Cloud Sleuth provides a distributed service link monitoring solutions

Call the relationship between the link service and service means: a series of multiple services call a process chain relationships

SpringCloud Zipkin 与Sleuth

Zipkin is an open source distributed tracking system by Twitter Open Source company, it is committed to regular data collection services, in order to solve the delay problem micro-service architecture, including data collection, storage, search and show. Each service zipkin reporting timing data, for example, each time the user request the service processing time and the like, can be easily monitored bottlenecks present in the system. zipkin will generate a UI according to the dependency graph by calling Zipkin relationship.

Spring Cloud Sleuth provides a link between the service call tracking. By Sleuth can clearly understand what a service request through the service, each service takes a long process. So that we can easily clarify the relationships among micro-calling service. In addition Sleuth can help us:

Time-consuming analysis: you can easily understand each sampling time-consuming request by Sleuth, to analyze what the service calls time-consuming;

Visualization Error: uncaught exception for the program, you can see the integrated Zipkin service interface; Link Optimization: call for more frequent service, you can implement some optimization measures for these services.

Spring Cloud Sleuth Zipkin may be combined, to send information to Zipkin, using the memory to store information Zipkin utilizing Zipkin Ui to display data.

Zipkin build service tracking system

After the Spring Boot version 2.0, it has been deprecated official build their own customized, but directly compiled to provide a jar package.

Note: zipkin official website has provided customized, using the official jar run.

Start:

The default port number for the service to start zipkin

java -jar zipkin.jar default port number; 9411

Access Address: http://127.0.0.1:9411/zipkin/

Specify the port number 8080 start start zipkin Service

java -jar zipkin.jar --server.port=8080

Access address: http: //192.168.18.220: 8080

Specify the access rabbitmq start

java -jar zipkin.jar --zipkin.collector.rabbitmq.addresses=127.0.0.1

Zipkin build integrated asynchronous transfer RabbitMQ

1, start RabbitMQ

2, start Zipkin (Zipkin automatically creates a queue)

3, a queue starts to form an asynchronous transfer ZipkinClient

Service Tracking Principle

In order to fulfill the request tracking, when a request is sent to the inlet end of a distributed system, you only need to track the service request to create a framework for the CD track identity, while at the time of the internal circulation of a distributed system, the framework always deliver the unique identification, until returned to the requestor until the Trace ID, the unique identifier is previously mentioned. By recording Trace ID, we will be able to log all requests process associate. In order to count the delay time of each processing unit when the request arrives at the respective service components, or processing logic reaches a certain state, it starts to mark by a unique identifier, and the specific process ends, the identification is mentioned hereinbefore the Span ID. For each Span, it must have a beginning and end of the two nodes, by recording the start and end timestamps Span Span, and you can count the time delay of the Span, in addition to the time stamp record, it can contain some other metadata, such as the event name, request information, etc.

TranceId role is to serve the entire micro call chain process guaranteed to be unique.

Each time a record request Spanid.

Micro service, TranceId with Spanid transfer request will be placed in the header. Trancdid each request are the same, but Spanid every request will once again generate one. TranceId a combination of multiple Spanid up, to get the whole micro-service call dependence.

SpringCloud2.x introduction of new knowledge

 

 

 

Official website: https: //zipkin.io/pages/quickstart.html 

Guess you like

Origin www.cnblogs.com/ming-blogs/p/10987951.html