In this tutorial, we’ll show the actual performance impact of OpenResty XRay when tracing Perl applications. We will watch CPU, memory, load average, traffic throughput, latency, etc. when OpenResty XRay is actively sampling and analyzing the target system. OpenResty XRay is a non-invasive diagnostic system based on our own dynamic tracing technology. It has minimal performance overhead. It can analyze running applications in real-time to help pinpoint the root causes of various issues.

Process Performance Before Running Analysis

How will OpenResty XRay’s Agent affect a target Perl application’s performance? Let’s find out in this video.

perlcover.png

First, let’s run the top command to check the process list.

Screenshot

Right now, the Agent of OpenResty XRay is not running any analysis. So its performance impact on the target process are strictly zero. Thanks to dynamic-tracing technologies. It never modifies the target processes in any way.

Screenshot

Look at this process named ‘perl’.

Screenshot

Its CPU utilization fluctuates around 49%.

Screenshot

The last minute load average of the whole system is 0.87.

Screenshot

The current CPU idle percentage is about 87%.

Screenshot

The current available memory is about 2730MB.

Screenshot

Next, let’s instruct OpenResty XRay to actively analyze that Perl process. Then we can see its performance impact on the target process and target system.

Screenshot

Performance Impact When the Analyzer is Running

Open the OpenResty XRay web console in the web browser.

Screenshot

Make sure it is the right machine you are watching.

Screenshot

The production mode is for analyzing online production environments. It tries hard to minimize the performance impact on the target applications and servers. It may take longer to analyze though.

Screenshot

Go to the “Guided Analysis” page.

Screenshot

Let’s select “High CPU usage”.

Screenshot

Click on “Next”.

Screenshot

Select the Perl application.

Screenshot

Select the target process that we saw previously in top.

Screenshot

Let’s start analyzing.

Screenshot

The system will keep performing different rounds of analysis.

Screenshot

It will keep sampling for 300 seconds, or 5 minutes.

Screenshot

Let’s return to the previous terminal window.

Screenshot

We can see the CPU utilization is around 50%. It’s merely 1% higher than what we’ve seen before. So there is no measurable impact on the target process’s CPU usage.

Screenshot

And the last minute load average of the whole process is 1.04, a little higher than the previous value, 0.87.

Screenshot

The CPU idle percentage is about 85%, there is no significant change from the previous value, 87%.

Screenshot

The current available memory is about 2725MB, a decrease of 5MB from before, it’s still within the normal fluctuation range.

Screenshot

Impact Measurement on Throughput and Latency

We measured the maximum throughput of server processes in different cases. Here is what we found.

Screenshot

Without installing the OpenResty XRay Agent, the maximum throughput is about 1024 requests per second.

Screenshot

When the OpenResty XRay agent is installed but not running the analyzers, the request rate remains the same value.

Screenshot

When analyzers are sampling, the request rate is about 1021 requests per second, merely 0.3% lower than when not doing analysis.

Screenshot

It can be seen that running the analyzers for performance analysis has minimal impact on the maximum throughput of the target process.

Screenshot

Now, let’s check out the benchmark showing the impact on request latency during the sampling process. This is what we found in comparison.

Screenshot

Without installing the agent, the average request latency is about 1250 microseconds.

Screenshot

When the agent is installed but the analyzers are not running, the average latency remains unchanged.

Screenshot

When the analyzers are sampling, the latency is about 1270 microseconds. An increase of 20 microseconds.

Screenshot

So, running the analyzers for performance analysis has a minimal impact on the latency as well.

Screenshot

Let’s go back to the web console.

Screenshot

The overhead of automatic analysis in the “Insights” and “Dashboard” page is similarly small and tiny.

Screenshot

What is OpenResty XRay

OpenResty XRay is a dynamic-tracing product that automatically analyzes your running applications to troubleshoot performance problems, behavioral issues, and security vulnerabilities with actionable suggestions. Under the hood, OpenResty XRay is powered by our Y language targeting various runtimes like Stap+, eBPF+, GDB, and ODB, depending on the contexts.

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.