Catalogue
Overall architecture directory: ASP. NET core distributed project-Directory
Monitoring directory: Micro-service monitoring Zipkin, skywalking, and log Elk Monitoring series
First. Introduction of Zipkin
Zipkin is a distributed tracking system that helps collect time-series data (collection lookups) needed for latency problems in microservices architectures, collects calls between microservices, and then handles data latency issues between calls.
such as: micro-service invocation of the depth. (Official Document Map)
and dependency graph analysis, which shows the invocation relationship between microservices. Of course, the pictures in my case are showing.
second, the role of Zipkin
1. Full Link Tracking tool (view dependencies)
2. Look at each interface, the execution speed of each service (locating the problem or looking for a performance bottleneck).
Zipkin contains:
Collector (Collector): mainly collects data generated by microservices (collectors are: http, Kafka, RABBITMQ)
UI (Interface): mainly the interface of displaying data
Storage (storage): store data (es, MySQL, memory, Cassandra)
In-memory: for testing only
JDBC (MySQL): The amount of data collected is very large, the query speed will be slow.
Cassandra:zipkin the most initial built-in storage (good extensibility, schema flexibility)
Recommended Elasticsearch: Used for large-scale, data-heavy, storage-form JSON.
API: interface for viewing/retrieving data, mainly used in WebUI
Process Explanation:
1. Transport function: Collect the spans of trace's services and convert them to Zipkin common span
2. Zipkin Core Data structure
Annotation: Used to locate the start and end of a request and calculate the call delay.
Cs:client start, which indicates the client initiated the request, the start of a span
Sr:server receive, indicating that the server received the request
Ss:server send, which means the server finishes processing and sends the results to the client
Cr:client Received, which indicates that the client obtains the service-side return information
Note: Point in time calculation
Sr-cs: Network Latency
SS-SR: Logical processing Time
Cr-cs: The entire process time
Third. ASP. NET Core Deployment Zipkin
1, need to add zipkin distributed tracking system in each micro-service framework
This project will create two new projects one is DEMO1 and the other is Demo2
2. NuGet Package Installation:
Zipkin4net (Tracker)
Zipkin4net.middleware.aspnetcore (Aspnetcore middleware)
3, in the project Startup.cs inside configure method Registration middleware
4, configuration Startup.cs also need to configure Rpctracehandler
That is, add the tracking processor to the httpclient that sent the get/post request, and the ASP. NET core deployment is complete.
5, the above deployment is only demo1 service, so the same way to deploy the DEMO2 project.
6. Now Docker deployment Zipkin
Data storage mode: Memory (test only)
Docker command: Docker run-d-P 9411:9411--name Zipkin Openzipkin/zipkin
Open in the browser after successful deployment, this way I am using a virtual machine, so open the address is 192.168.216.135:9411
7. Deployment Complete
In the control of the ASP. NET core project, we write the interface address called Demo2 Api/values.
8, this Zipkin deployment is in memory, not suitable for the formal environment
Note: Once the amount of data goes up, the Zipkin is easily crushed.
Therefore, other solutions are needed instead.
At present, the landlord I adopt the solution is kafka+zipkin+es. If there is a better solution you can try.
Resources:
Official documents: zipkin.io/pages/architecture.html
Zipkin API Interface: zipkin.io/zipkin-api/#/
asp:787464275 Welcome Dabigatran AC
If you think this article is good or something, you can click on the "Recommend" button in the bottom right corner to support the spirit, because this support is the biggest motivation for me to continue to write and share!
Louieguo
Disclaimer: Original Blog Please keep the original link or at the beginning of the article add my blog address, such as found errors, welcome criticism. General in my article, can not set a reward function, if there are special needs please contact me!
Public number: Welcome to QQ Technology Exchange Group: Welcome Dabigatran