This is a creation in Article, where the information may have evolved or changed.
Text: Cross-language distributed tracking System Jaeger usage Introduction and Case "PHP hprose Go"
Objective
With the development of the company, business continues to increase, the module is constantly split, the system between the business calls become more complex, on the location of the line fault caused great difficulties. The entire call chain is opaque, as if the system was blindfolded with a piece of crape, and when the line encounters a fault, the entire technical department falls into a painful whirlpool. At this time distributed tracking system came into being, such as the opening of Crape, let the sun into the dark.
Distributed System call procedure
Opentracing protocol
Opentracing is a set of distributed tracking Protocol, platform, language-independent, unified interface, easy to develop access to different distributed tracking system.
Easy to understand opentracing
A complete opentracing call chain containing Trace + span + infinite Pole classification
- Trace: The Trace object, a trace represents a service or process in the system execution process, such as: Test.com,redis,mysql and other execution process. A trace consists of multiple spans
- Span: Records information about the trace during execution, such as query SQL, requested HTTP address, RPC call, start, end, interval, and so on.
- Infinite Pole classification: The use of infinite-pole classification between services and services, through the HTTP header or request address to the lowest layer, so that the entire call chain together.
Related documents
- Official documents
- Opentracing Semantic Specification (Chinese version)
- Opentracing Semantic Conventions
- Opentracing document Chinese version (translation) Wu Yu
Distributed Tracking System Jaeger
Jaeger is a set of distributed tracking systems developed by Uber that has been used on a large scale in Uber. and joined CNCF Open source organization in 2017-9-13. The Jaeger can be used to visualize the entire chain of calls throughout a distributed system, thus finding and solving problems well:
Role
- Information dissemination under distributed environment
- Distributed transaction Monitoring
- Show cross-process call chain
- Performance optimization
- Positioning problems
Characteristics
- Using UDP to transmit data, compared to HTTP, the advantage is that you do not have to worry about the Jaeger service outage or network transmission problems affecting the normal business. The disadvantage is the loss of packets, affecting the entire call chain.
- Data is serialized via thrift, compared to JSON
Interface |
Thrift/byte |
Json/byte |
Save |
Interface 1 |
987 |
2396 |
About 1.5 times times |
Interface 2 |
1212 |
2916 |
About 1.4 times times |
Interface 3 |
12830 |
18893 |
Approx. 40% |
Interface 4 |
17158 |
22465 |
Approx. 24% |
Interface 5 |
11025 |
14282 |
Approx. 23% |
It can be seen that thrift relative JSON has reduced a lot of space. The size of the data that we collect on our corporate interface is focused on 10~20k, so using thrift will be more advantageous.
Jaeger Official offers a variety of acquisition strategies, users can choose to use as needed
- Constsampler, full-volume collection
- Probabilisticsampler, probabilistic acquisition, one of the default million parts
- Ratelimitingsampler, speed limit acquisition, can only collect a certain amount of data per second
- Remotelycontrolledsampler, a dynamic acquisition strategy, adjusts the acquisition strategy according to the current system's traffic volume
- Go
- Java
- Node
- Python
- Php
The Go,java,node,python client is officially available, and other clients are still open, and the PHP client develops "welcome start" for the individual.
Deployment
Quick Deploy------All in one Docker image
All-in-one is an official uber-packaged image that can be deployed directly, but only for test environments and not for online use because it puts data into memory.
docker run -d -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp \ -p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 jaegertracing/all-in-one:latest
http://localhost:16686 can be used to view Jaeger backstage in the browser
Official examples of use, need go environment
go get github.com/uber/jaegercd $GOPATH/src/github.com/uber/jaegermake install_examplescd examples/hotrodgo run ./main.go all
http://localhost:8080 Browser Open View
Cassandra + Docker deployment, stand-alone mode
Docker RUN-ITD \
--name=cassandra-p9042:9042 \
-v/data/cassandra:/var/lib/cassandra \
Cassandra
Entering a container to create a table space
According to the official script organized a statement jaeger_tables, enter Cassandra, execute the statement can create the required table.
Keyspaces:jaeger_v1_dc
Run Jaeger-query
Docker RUN-ITD--network=bridge \
--name=jaeger-query \
-p16686:16686 \
Jaegertracing/jaeger-query \
/go/bin/query-linux \
--span-storage.type=cassandra \
--CASSANDRA.KEYSPACE=JAEGER_V1_DC \
--cassandra.servers={{Cassandra}}:9042 \
--query.static-files=/go/jaeger-ui/
Run Jaeger-collector
Docker RUN-ITD--network=bridge \
--name=jaeger-collector \
-p14267:14267 \
-p14268:14268 \
-p9411:9411 \
Jaegertracing/jaeger-collector \
/go/bin/collector-linux \
--span-storage.type=cassandra \
--CASSANDRA.KEYSPACE=JAEGER_V1_DC \
--cassandra.servers={{Cassandra}}:9042
Run Jaeger-agent
Docker run \
-ITD--network=bridge \
--name=jaeger-agent \
-P5775:5775/UDP \
-P6831:6831/UDP \
-P6832:6832/UDP \
-P5778:5778/TCP \
Jaegertracing/jaeger-agent \
/go/bin/agent-linux--collector.host-port={{Jaeger-collector}}:14267
Cross-language invocation cases
Beego
go get github.com/astaxie/beego
git clone git@github.com:jukylin/trace_example.gitcd trace_examplebee run trace_example
Php
- Install jaeger-php
- Run hprose.php
cd vendor/jukylin/jaeger-php/examplephp Hprose.php
Trace Result View
Ps
- Uber-distributed tracking technology re-engineering
- Jaeger is still in development, and officials want support from the community.
- Jaeger and Jaeger-php, operating in the company's test environment for 1 months, were released on line in 2017-10-18.
- By choosing a good acquisition strategy, the log data can grow explosively.