PHP Performance Benchmark 2026: 7.4 vs 8.0 vs 8.1 vs 8.2 vs 8.5

Introduction

PHP 7.4 reached its end of life in November 2022, yet many websites and applications still run on this aging version. While security is the primary reason to upgrade, performance is another compelling factor that often gets overlooked.

In this benchmark, we compare the latest PHP 8.5.2 against the final release of PHP 7.4 (7.4.33) using the same CPU‑intensive script from our first benchmark. The goal is simple: quantify the real‑world performance gain you can expect when finally making the leap from 7.4 to 8.5.

For a more recent three-way comparison including PHP 8.5, check out our updated three-version benchmark.

All tests are run on an isolated server with identical configuration – the same hardware, the same PHP‑FPM settings, and the same OPcache configuration (with JIT disabled to keep the focus on engine improvements).

Test Environment

The benchmark was conducted on a dedicated test server with the following specifications:

ComponentSpecification
CPUIntel(R) Xeon(R) Platinum 4-core (vCPU)
RAM8GB ECC
OSUbuntu 24.04.4 LTS
Web ServerNginx 1.24
PHP Versions7.4.33, 8.0.26, 8.1.32, 8.5.2 (latest patches)
PHP-FPMStatic processes, pm.max_children = 100
OPcacheEnabled, JIT disabled
Test ToolApache Bench (ab)
Concurrency1 (single request at a time)
Total Requests1,000 per run
Warm‑up100 requests before each run (results discarded)

The server was restarted between version tests to clear any caches.


Methodology

  1. Test script: The same CPU‑intensive script as in our first benchmark – recursive Fibonacci up to fibonacci(35) (≈18 million function calls) plus 1,000,000 iterations of mathematical operations (sqrt() and sin()). The script outputs only a fixed string "OK" to guarantee identical response lengths for ab.
  2. Each PHP version was tested with 5 independent runs of 1000 requests each at concurrency 1.
  3. For each metric, the highest and lowest values were discarded, and the remaining three were averaged.
  4. All tests targeted the script directly via ab, using separate ports for each version (e.g., :8074 for PHP 7.4, :8085 for PHP 8.5).

Results

Below are the raw numbers from five consecutive runs for each PHP version. The final averages (after removing min and max) are used for comparison.

Table 1: Raw Benchmark Data (Requests per second / Time per request in ms)

Test RunPHP 7.4.33
(req/s / ms)
PHP 8.0.26
(req/s / ms)
PHP 8.1.32
(req/s / ms)
PHP 8.2.28
(req/s / ms)
PHP 8.5.2
(req/s / ms)
Run 11.80/555.3621.83/546.5171.83/545.1301.84/542.2431.86/537.784
Run 21.82/548.4551.82/549.0891.85/540.0721.84/544.6211.86/537.718
Run 31.81/551.3571.84/544.6921.85/541.6031.85/541.5441.86/536.912
Run 41.81/552.7931.83/545.6641.85/541.0221.84/543.1241.85/541.156
Run 51.81/552.4191.83/546.8921.84/542.1641.82/549.4191.85/540.881
Average (after filtering)1.81/552.191.83/546.361.85/541.281.84/543.331.86/538.89

Higher req/s and lower response times are better. Averages are calculated by discarding the highest and lowest values for each PHP version.

Table 2: Performance Improvement Relative to PHP 7.4

PHP VersionAvg Requests/secImprovement vs 7.4
PHP 7.4.331.81–
PHP 8.0.261.83+1.1%
PHP 8.1.321.85+2.2%
PHP 8.2.281.84+1.7%
PHP 8.5.21.86+2.8%

Analysis

With OPcache correctly enabled across all PHP versions, the benchmark results reveal a clear and stable performance progression:

  • PHP 8.0.26 shows a modest +1.1% improvement over the PHP 7.4 baseline.
  • PHP 8.1.32 delivers a more noticeable gain of +2.2%, establishing a new performance tier.
  • PHP 8.2.28 performs similarly to 8.1, with a +1.7% gain.
  • PHP 8.5.2 achieves the best results in this test, with a +2.8% increase in throughput and a 13ms reduction in average response time compared to PHP 7.4.33.

The data exhibits excellent stability, with minimal run-to-run variance (within ±1-2%), confirming a well-controlled and reproducible testing environment. The performance gains, while cumulative and consistent, are modest in this specific CPU‑intensive recursive workload.

This does not mean PHP upgrades are unimportant. Rather, it shows that for certain types of workloads (like deep recursion), the engine optimizations between versions have a limited impact. For real‑world web applications, where PHP execution is mixed with database and I/O operations, industry benchmarks often show significantly larger gains.


Should You Upgrade?

The answer remains a clear YES, but for different reasons depending on your current version:

  • If you’re on PHP 7.4, upgrading to 8.5 gives you a 2.8% performance boost in CPU tasks, plus critical security updates and modern language features. The cumulative gains across 8.x versions are meaningful.
  • If you’re on PHP 8.0 or 8.1, moving to 8.5 offers smaller performance gains but better security, new syntax, and future-proofing.
  • For WordPress users, industry data shows much larger gains (20-40%) in real CMS environments, making the upgrade even more compelling.

Frequently Asked Questions

Q: Why are the gains smaller than industry benchmarks?

A: Our test focuses on a pure CPU‑intensive recursive workload. Real‑world applications mix CPU work with I/O, where PHP 8.x optimizations (like JIT and improved opcache) have a bigger impact.

Q: Did you enable OPcache for all versions?

A: Yes, we verified OPcache was active for every PHP version before testing, ensuring a fair comparison.

Q: Will my old PHP 7.4 code run on PHP 8.5?

A: Most code will run with minor adjustments. Test your application thoroughly in a staging environment before upgrading production.


Test Scripts (for Reproducibility)

Important: Run these commands only on your own isolated test server. Never load‑test a production site.

PHP Benchmark Script (test.php)

<?php
set_time_limit(0);
function fibonacci($n) {
    if ($n <= 1) return $n;
    return fibonacci($n-1) + fibonacci($n-2);
}
function loopTest($iterations) {
    $result = 0;
    for ($i = 0; $i < $iterations; $i++) {
        $result += sqrt($i) * sin($i);
    }
    return $result;
}
fibonacci(35);
loopTest(1000000);
echo "OK";
?>

Apache Bench Commands


# Test PHP 7.4 (adjust port)
ab -n 100 -c 1 https://phpbenchlab:8074/test.php > /dev/null 2>&1
ab -n 1000 -c 1 https://phpbenchlab.com:8074/test.php
# Test PHP 8.0 (adjust port)
ab -n 100 -c 1 https://phpbenchlab:8080/test.php > /dev/null 2>&1
ab -n 1000 -c 1 https://phpbenchlab.com:8080/test.php
# Test PHP 8.1
ab -n 100 -c 1 https://phpbenchlab:8081/test.php > /dev/null 2>&1
ab -n 1000 -c 1 https://phpbenchlab.com:8081/test.php
# Test PHP 8.2
ab -n 100 -c 1 https://phpbenchlab:8082/test.php > /dev/null 2>&1
ab -n 1000 -c 1 https://phpbenchlab.com:8082/test.php
# Test PHP 8.5
ab -n 100 -c 1 https://phpbenchlab:8085/test.php > /dev/null 2>&1
ab -n 1000 -c 1 https://phpbenchlab.com:8085/test.php

All raw data and methodology are provided. Reproduce this benchmark on your own hardware to validate results.

Leave a Comment