When you profile a live Perl application in production, the biggest worry is usually not whether you can pinpoint the problem, but whether the profiling tool itself will drag down your production service. We measured the overhead of OpenResty XRay on a live Perl application in production mode: during active sampling, maximum throughput dropped by less than 0.3% and average latency rose by just 20 microseconds, while the Agent’s overhead is exactly zero when idle. This is possible because, unlike always-on APM agents, it performs no code injection or modification on the target process and only collects data — at low frequency — when a user explicitly starts an analysis; the sections below use point-by-point benchmark data to show its real impact on CPU, memory, and load, as well as on throughput and latency. For the full walkthrough, see the video version at the top of this article.

Test Environment and Performance Baseline

To establish a baseline for comparison, we used the top command to capture system metrics before starting the profiler. As shown below, the target perl process was consuming approximately 49% CPU, the system’s 1-minute load average was 0.87, CPU idle was approximately 87%, and available memory was approximately 2730 MB.

perl process

What Happens to CPU, Memory, and Load During Profiling?

To simulate a real-world diagnostic scenario, we used the OpenResty XRay console to launch a 300-second (5-minute) “High CPU usage” analysis against the Perl process in production mode.

Select production mode

Choosing “production mode” is critical: it is specifically designed for live environments and minimizes performance impact through optimizations such as low-frequency sampling.

The figure below shows the analysis task running in progress.

Analysis in progress, lasting 300 seconds

While the profiler was running, we observed the following subtle changes across system metrics:

  • Target process CPU usage: Rose to ~50%, up approximately 1 percentage point from the baseline.
  • System 1-minute load average: Rose to 1.04, a modest increase from the baseline of 0.87.
  • CPU idle: Dropped to ~85%, barely changed from the baseline of 87%.
  • Available memory: Dropped to ~2725 MB, a reduction of approximately 5 MB — well within normal variance.

Available memory 2725 MB during analysis

Overall, the OpenResty XRay profiler’s impact on system-level resources (CPU, memory, and load) during the sampling period was measurable but minimal, with no meaningful impact on system stability.

How Much Does Profiling Affect Throughput and Latency?

For production services, throughput and latency are the two most critical performance indicators. We ran three sets of comparative benchmarks to evaluate the impact on each. The table below summarizes the results across all three scenarios:

ScenarioMax throughputAvg latency
OpenResty XRay Agent not installed1024 req/s1250 μs
Agent installed, profiler idle1024 req/s (unchanged)1250 μs (unchanged)
Profiler actively sampling1021 req/s (−0.3%)1270 μs (+20 μs)

1. Maximum Throughput

We used a load testing tool to measure the maximum throughput of the server process under three different conditions.

  • Without Agent: 1024 req/s

Maximum throughput without Agent: 1024 req/s

  • With Agent installed but profiler inactive: 1024 req/s (no change)

Throughput unchanged with Agent installed but profiler inactive

  • With profiler active: 1021 req/s

Throughput at 1021 req/s with profiler active

The results show that with the profiler actively sampling, maximum throughput drops to approximately 1021 requests per second — just 0.3% below the baseline.

2. Average Request Latency

We measured the average request latency experienced by clients under high concurrency.

  • Without Agent: 1250 μs

Average latency without Agent: 1250 μs

  • With Agent installed but profiler inactive: 1250 μs (no change)

Latency unchanged with Agent installed but profiler inactive

  • With profiler active: 1270 μs

Latency at 1270 μs with profiler active

The results show that the profiler introduced only 20 μs of additional average request latency.

Conclusion

Through comprehensive measurement of system resources, application throughput, and request latency, we can conclude that the dynamic tracing architecture of OpenResty XRay delivers measurable and predictable performance overhead when conducting real-time diagnostics on production Perl applications — with negligible impact on core business metrics. This establishes it as a profiling tool that can be deployed with confidence as a permanent fixture in production environments.

The overhead introduced by automated analysis on the Insights and Dashboard pages is negligible as well.

Insights and Dashboard pages

If you are troubleshooting an actual high CPU issue in a Perl application, see how flame graphs traced 100% CPU usage to a regex hotspot: analyzing high CPU usage in Perl applications. We ran the same production-mode overhead measurement on other languages as well — see the results for Go, Rust, PHP, and Python applications.

OpenResty XRay vs. Always-On APM Agents

The reason the overhead stays this low is architectural. Traditional APM agents inject code into the target process and collect data continuously, so they impose runtime overhead at all times — whether or not anyone is looking. OpenResty XRay takes the opposite approach: it is non-intrusive and samples only on demand.

Traditional always-on APM agentOpenResty XRay
Data collectionContinuous, always onOn demand, only during a user-initiated analysis
Target processCode injection / instrumentationNon-intrusive, no code modification
Overhead when idlePersistentExactly zero
Overhead while samplingPersistent<0.3% throughput, +20 μs latency

FAQ

How much performance overhead does OpenResty XRay add to a production Perl application?

During active analysis, OpenResty XRay lowers maximum throughput by less than 0.3% (from 1024 to 1021 requests per second) and adds about 20 microseconds of average latency (from 1250 μs to 1270 μs). When the Agent is installed but not actively sampling, throughput and latency are unchanged, and when it is idle the overhead is exactly zero.

Is OpenResty XRay safe to run on a production Perl application?

Yes. The OpenResty XRay Agent is non-intrusive — it performs no code injection or modification on the target process and only collects data when you explicitly start an analysis, at a low sampling frequency. During a 300-second production-mode analysis of a live perl process, the one-minute load average rose only from 0.87 to 1.04 and target-process CPU from 49% to about 50%, so it can be deployed continuously in production.

Does OpenResty XRay slow down my Perl app when it is not actively analyzing?

No. The Agent only collects data while a user-initiated analysis is running. When it is installed but idle, maximum throughput and request latency are identical to having no Agent at all — the performance overhead is exactly zero.

How does OpenResty XRay’s overhead compare to a traditional always-on APM agent?

Traditional APM agents inject code into the target process and run continuously, imposing overhead at all times. OpenResty XRay instead samples on demand at a low frequency, so it adds zero overhead when idle and less than 0.3% throughput impact while actively profiling.

How much CPU and memory does OpenResty XRay use while profiling a Perl process?

While sampling the perl process, target-process CPU usage rose from a baseline of 49% to about 50% (roughly 1 percentage point), CPU idle dropped only from 87% to about 85%, and available memory went from about 2730 MB to about 2725 MB — a change of roughly 5 MB.

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.