Mythbusting “PHP is rarely the bottleneck,” data shows 40% of time spent in PHP

PHP Performance

In discussions about PHP performance optimizations and micro-optimizations, there is often someone hand-waving the discussion down with, “PHP is rarely the bottleneck; I/O is.”

But is that really true?

Our data shows otherwise: across 1240 production projects, the average time spent in PHP is 40.3%.

For 34% of these projects, they even spent more than 50% of their time in PHP, not in I/O.

So, PHP often is the bottleneck, and depending on the framework, the effect is even higher.

Our data source

Tideways collects PHP performance data from hundreds of customers, with thousands of projects and services.

See how much time your own application spends in PHP.

Start your free 14-day Tideways trial

We can’t use all of these projects. To get reliable results, we filtered them:

  • Must be a production environment on the Tideways project.
  • Must have more than 10k requests every day for 30 days.
  • Must not have compiling and autoloading take more than 10% of the request, because that suggests that OPcache is incorrectly sized or even disabled. In that case, the project would skew the result.
  • Must only include data from web context, meaning serving requests through a web server. CLI projects and services are excluded.

This left us with 1240 projects.

For the historical view and weekly report, we aggregate the collected monitoring data to a daily average, for the total response and for all layers, such as SQL, HTTP, Redis and more. This allows us to compute the daily ratio of PHP processing and I/O as part of the total response time.

The data can be segmented by framework or application, and the biggest ones with significant numbers to include are Symfony, Laravel, Magento 2, Shopware 6, Oxid, WordPress

The data

E-commerce and CMS apps require heavier PHP processing

There is a clear difference in performance between framework-based applications and those “off-the-shelf” e-commerce or CMS systems.

Magento 2, Shopware 6, and WordPress sites are on average close to 50% of PHP computation and 50% I/O.

In comparison, the frameworks like Symfony 2 and Laravel are both close to 35% of PHP time and 65% of I/O.

This shows that you pay a price for the flexibility of plugin-based systems where you install additional third-party code for adding features. They need to provide generic abstractions and call hooks in many places. A specialized application can skip these usually.

Use a Profiler to find PHP Bottlenecks

The most significant factor for performance is your application architecture and the code you write. Tideways—our production-ready PHP profiler—helps you pinpoint bottlenecks in your application code by continuously profiling the production environment at low overhead.

About the author

  • Benjamin

Benjamin
Founder & CEO

I am the founder and CEO of Tideways. I started the company over 10 years ago with the mission to move the PHP ecosystem forward, starting with performance. As managing director, I work across product, strategy, and the day-to-day of building a developer-focused SaaS business.

I’m a core contributor to the Doctrine open-source project and a founding board member of the PHP Foundation, which reflects my long-standing commitment to the PHP ecosystem. I particularly enjoy working at the intersection of application performance, developer experience, and the open-source community that makes PHP what it is. Outside of work, I enjoy board games, hiking, and coffee.