Abstract: Since implementing microservices, we have encountered many problems. The biggest problem is how to troubleshoot faults. Service-oriented interfaces usually rely on multiple services. The slowness of the dependent interfaces will directly affect the service quality of the interfaces. Slowness caused by this kind of dependence is very common online, but it is not easy to troubleshoot. After all...
Since the implementation of microservices, we have encountered many problems. The biggest problem is how to troubleshoot faults. Service-oriented interfaces usually rely on multiple services. The slowness of the dependent interfaces will directly affect the service quality of the interfaces.
This kind of slowness caused by dependence is very common online, but it is not easy to troubleshoot. The reason is that a large number of log developers track online through logs, which is not very intuitive, and some Company developers cannot see the specific execution status online. Generally speaking, these small probability failures online represent hidden dangers in the system. When the traffic increases, these hidden dangers will be amplified and even directly lead to large-scale online failures. In order to avoid similar things, we need to do a lot of things. The most intuitive is to use Distributed tracing systems for statistical analysis.
We often see experts talking about how to optimize online performance and how to improve performance. In fact, there is an important link that they did not mention. How do they discover low-probability faults? Distributed tracking systems are very common in large Internet companies, but small and medium-sized companies do not have the technical strength to implement this system. From our point of view, even if the traffic is very small, the system is still very important to the company and we need to strengthen it. Only by being able to find problems can we solve them. This is the purpose that I have always implemented.
The specific implementation of the distributed tracking system has certain technical difficulties. It is necessary to achieve performance capture, log writing, log collection, log transmission, log storage, log index, log analysis of logs, final merger display, and require the system to request the system. Able to cope with the impact of large flow systems. For example, each request generates 1k logs per interface, then the QPS 2000 server will generate 2M logs. If a request relies on 5 interfaces, then it will be 10M logs per second. When the online business is more complex and the traffic is larger, time, this value will increase.
large Internet companies have many distributed tracking systems that can bear billions of traffic, but for small companies, this architecture is very affordable. Many of them, such as dependent distributed message systems, distributed storage, and distributed storage,, distributed storage, and distributed storage, and distributed storage, and distributed storage,, and distributed storage, and distributed storage,, and distributed storage,, and distributed storage, and distributed storage,, and distributed storage, and distributed storage,, and distributed storage,, and distributed storage,, and distributed storage,, and distributed storage,, and distributed storage,, and distributed storage. Distributed computing, these alone will use at least 6 or more servers, which is not cost-effective for ordinary small companies.
This time we have two types of open source distributed tracing. One is a stand-alone version for small and medium-sized Internet companies. It can support PV 2000w business systems (such as payment systems). There is also a distributed tracking system that supports distributed billions of PV. Currently, the stand-alone version of Fiery has just been opened (https://github.com/weiboad/fiery). This version is designed for use by small and medium-sized enterprises. The entire project is a Jar package that can be used out of the box. As long as there is Java8 runtime, it can be used directly. , of course the system needs to simply do a burying job. The C++ distributed version relies on many things and requires certain capabilities for operation and maintenance personnel. The stand-alone version will be released later depending on the situation. These core trading systems, which are completely open source and have sensitive data inside, are also fully available.
There are currently multiple methods of distributed tracking on the market, some of which are used internally by the company, and some are small-scale free and large-scale paid services. Common distributed tracing records the performance of each block through statistical methods. The methods we currently provide are not exactly the same as those on the market. We have made a lot of simplifications through continuous experiments, retaining only the functions we think are truly practical. We designed the system for distributed monitoring of key systems. Such as payment system and transaction system.
We record the specific situation, return value, specific performance and other information of each request. Through table analysis, we can quickly discover online dependent interface performance (third-party or unburied interface performance statistics), The performance ranking analysis of the hidden interfaces was also conducted independently. By viewing the analysis table, we can quickly find the slowest interface to request playback and analyze the reasons for slow online performance. Through practice, we have found that in many cases the slowness of the data resources that PHP relies on leads to poor performance of the PHP interface. Therefore, the focus is on relying on resources. Users can add other information according to their own needs, which can reduce a large number of useless logs and make it more frugal.
This open source Fiery mainly has three parts, PHP intrusive point library, streamlined log monitoring push module, and server. These three achieve distributed tracking of a website with a PV of less than 2000w.
The buried point library will generate a Traceid (UUID) at the entrance. This Traceid hides the IP address of the entrance server and the request time. All subsequent logs will be marked with this UUID. After log collection, all relevant logs will be stored according to this UUID. The buried point library will be responsible for receiving the Traceid sent by other requests and sending and maintaining the RPCID during runtime. The RPCID is a hierarchical counter through which we can directly restore the order and hierarchy of the calling relationship and display it to the developer. In addition, if an Exception occurs during PHP operation, it will be captured and recorded by the buried point library for the server to perform deduplication statistics. Finally, these logs will be logged to the local disk of the server. Due to some reasons, when multiple PHP processes write a file at the same time, the order may occasionally occur. We now log the logs based on the process ID plus the project name as the file name.
We have implemented a simple version of Fiery log capture and transmission. This is to simplify the work of operation and maintenance personnel. There are indeed many open sources that provide similar functions, but they need to rely on other environments. There is a certain burden for Wei. We also have an experimental PHP log capture and transmission service, but it is still an experimental function. It is expected that there will be certain defects. Users can participate in debugging and improvement.
We have done a lot of work on Fiery’s server side and built-in Lucene and Rocksdb to index and store requests respectively. We have also done some work on memory statistics. At present, our statistical dimensions are fixed. We only count the responses of local interfaces, dependent interfaces, Mysql, and Curl. We also provide call relationship playback and error log alert deduplication statistics. Through these functions, performance faults and system abnormalities at key points on the line can be quickly discovered. Currently it is only a stand-alone version, and I can further expand it into a simpler distributed mode if needed in the future.
The above services are not just served online. At present, we have made a lot of interesting attempts inside us. For example, the environment of the QA test is connected. After the test is completed , developers can use Traceid to find all the call process, parameters, return conditions, and performance of this request, which can be visually viewed for easy analysis. The same can be done for unit testing before going online. Some time ago, when I posted on Weibo to promote Fiery, someone mentioned that it could be used as a honeypot to view the hacker intrusion process and specific details. Follow-up functions still need to be explored and improved by everyone. This system is designed to fill the gaps in the PHP ecosystem.
The above is the detailed content of A brief introduction to distributed tracing in PHP. For more information, please follow other related articles on the PHP Chinese website!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor