Introduction
PHP has long carried the reputation of being “slow,” especially when compared to compiled languages like Go or the V8-powered Node.js. But with PHP 8.5’s JIT (Just-In-Time) compilation, is that reputation still deserved?
In this benchmark, we put four popular languages head‑to‑head on a CPU‑intensive task: recursive Fibonacci calculation and a 1,000,000‑iteration math loop. We test:
- PHP 8.5.2 (both JIT off and JIT on)
- Node.js 22.22.0 (V8 JIT enabled)
- Go 1.23.4 (compiled)
- Python 3.12.3 (interpreted)
All tests run on the same server, with identical workloads, to answer one question: Where does PHP 8.5 with JIT really stand?
Test Environment
| Component | Specification |
|---|---|
| CPU | Intel Xeon Platinum (4 vCores) |
| RAM | 8 GB ECC |
| OS | Ubuntu 24.04 LTS |
| Web Server | Nginx 1.24 (PHP only) |
| Test Tool | Apache Bench (ab) |
| Concurrency | 1 (single request at a time) |
| Requests per Run | 1,000 |
| Warm‑up | 500 requests before each run |
Test Script
All languages executed the same algorithm:
python
# Recursive Fibonacci (n=30)
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
# 1,000,000 iterations of math operations
for i in range(1000000):
result += math.sqrt(i) * math.sin(i)Each HTTP endpoint returned a fixed "OK" string to ensure stable ab testing.
Results
Table 1: Raw Benchmark Data (Requests per second)
| Test Run | PHP 8.5 (JIT off) | PHP 8.5 (JIT on) | Node.js 22 | Go 1.23 | Python 3.12 |
|---|---|---|---|---|---|
| Run 1 | 14.33 | 23.05 | 37.68 | 66.50 | 4.72 |
| Run 2 | 14.33 | 23.06 | 37.34 | 66.63 | 4.72 |
| Run 3 | 14.31 | 23.09 | 37.67 | 66.36 | 4.72 |
| Run 4 | 14.31 | 23.05 | 38.26 | 67.66 | 4.72 |
| Run 5 | 14.35 | 23.08 | 38.20 | 68.61 | 4.72 |
| Average | 14.33 | 23.07 | 37.83 | 67.15 | 4.72 |
All runs completed with 0 failed requests. Results were highly stable with minimal variance.
Table 2: Response Time Comparison (milliseconds)
| Language | Avg Response Time | Relative to PHP (JIT on) |
|---|---|---|
| Go 1.23 | 14.90 ms | 2.9x faster |
| Node.js 22 | 26.44 ms | 1.6x faster |
| PHP 8.5 (JIT on) | 43.35 ms | baseline |
| PHP 8.5 (JIT off) | 69.80 ms | 1.6x slower |
| Python 3.12 | 211.85 ms | 4.9x slower |
Table 3: Performance Summary
| Language | Configuration | req/s | Relative to PHP (JIT on) |
|---|---|---|---|
| Go 1.23 | Compiled | 67.15 | 2.91x |
| Node.js 22 | V8 JIT | 37.83 | 1.64x |
| PHP 8.5 | JIT enabled | 23.07 | 1.00x |
| PHP 8.5 | JIT disabled | 14.33 | 0.62x |
| Python 3.12 | Interpreter | 4.72 | 0.20x |
Analysis
The JIT Effect: PHP’s 61% Leap
The most dramatic finding is the impact of JIT on PHP 8.5:
| Configuration | req/s | Improvement |
|---|---|---|
| JIT disabled | 14.33 | baseline |
| JIT enabled | 23.07 | +61% |
This 61% boost confirms our earlier JIT benchmarks: for CPU‑intensive tasks, JIT is transformative. Without it, PHP trails far behind; with it, PHP becomes genuinely competitive.
Where Does PHP Stand?
With JIT enabled, PHP achieves:
- 61% of Node.js performance (23.07 vs 37.83 req/s)
- 34% of Go performance (23.07 vs 67.15 req/s)
- 4.9x faster than Python (23.07 vs 4.72 req/s)
The gap between PHP and Node.js is now 1.6x – a far cry from the 2-3x differences often cited in older benchmarks.
Go Remains the Performance King
Go’s 67.15 req/s is the clear winner, demonstrating why it’s the language of choice for high‑performance systems. Its compiled nature and efficient runtime handle recursion and loops with minimal overhead.
Node.js: Strong but Surpassed by Go
Node.js’s V8 engine delivers impressive 37.83 req/s – 1.6x faster than PHP JIT. The V8 JIT has been optimized for over a decade, and it shows in recursive workloads.
Python: Expected but Stark
Python’s 4.72 req/s (4.9x slower than PHP) is expected for an interpreted language in CPU‑bound scenarios. Python excels at I/O and rapid development, not number‑crunching.
Should You Switch Languages?
The answer depends on your priorities:
| Priority | Recommendation |
|---|---|
| Maximum performance | Go is the undisputed leader – 2.9x faster than PHP JIT |
| Good performance + ecosystem | PHP 8.5 with JIT delivers solid performance (61% of Node.js) with a massive ecosystem |
| I/O‑bound applications | Node.js remains excellent for async workloads |
| Rapid prototyping | Python is still king, but accept the performance trade‑off |
Key Takeaway for PHP Developers
Enable JIT. The 61% boost alone is reason enough. PHP 8.5 with JIT is no longer a performance outlier – it sits firmly between Node.js and Python, closing the gap with modern runtimes.
For teams already invested in PHP, this benchmark shows that you don’t need to switch languages for performance. With JIT enabled, PHP is competitive for CPU‑intensive tasks.
Frequently Asked Questions
A: V8’s JIT has been refined for over 15 years. PHP’s JIT, introduced in PHP 8.0, is still maturing. The gap will likely narrow in future versions.
A: This benchmark focuses on raw CPU performance per request. Higher concurrency would introduce process‑pool and scheduling variables, making it harder to isolate language performance.
A: Possibly. This test emphasizes recursion, which is a known strength of V8. Different workloads (e.g., array manipulation, object creation) may show different rankings.
A: All languages used similar memory (2-5 MB) for this test. Memory wasn’t a differentiator.
Test Scripts (for Reproducibility)
Important: Run these commands only on your own isolated test server.
PHP Test Route (routes/web.php for Laravel)
php
Route::get('/cpu-test', function () {
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(30);
loopTest(1000000);
return response('OK');
});Node.js Test Server
javascript
const http = require('http');
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n-1) + fibonacci(n-2);
}
function loopTest(iterations) {
let result = 0;
for (let i = 0; i < iterations; i++) {
result += Math.sqrt(i) * Math.sin(i);
}
return result;
}
const server = http.createServer((req, res) => {
fibonacci(30);
loopTest(1000000);
res.end('OK');
});
server.listen(8082);Go Test Server
go
package main
import (
"math"
"net/http"
)
func fibonacci(n int) int {
if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-2)
}
func loopTest(iterations int) float64 {
var result float64
for i := 0; i < iterations; i++ {
result += math.Sqrt(float64(i)) * math.Sin(float64(i))
}
return result
}
func handler(w http.ResponseWriter, r *http.Request) {
fibonacci(30)
loopTest(1000000)
w.Write([]byte("OK"))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8083", nil)Python Test Server (Flask)
python
from flask import Flask
import math
import time
app = Flask(__name__)
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
def loop_test(iterations):
result = 0
for i in range(iterations):
result += math.sqrt(i) * math.sin(i)
return result
@app.route('/')
def cpu_test():
fibonacci(30)
loop_test(1000000)
return 'OK'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8084)Apache Bench Commands
bash
# PHP
ab -n 1000 -c 1 http://phpbenchlab.com:8080/cpu-test
# Node.js
ab -n 1000 -c 1 http://phpbenchlab.com:8082/
# Go
ab -n 1000 -c 1 http://phpbenchlab.com:8083/
# Python
ab -n 1000 -c 1 http://phpbenchlab.com:8084/Conclusion
This benchmark tells a clear story:
- Go remains the performance champion – 67 req/s
- Node.js holds strong second place – 38 req/s
- PHP 8.5 with JIT delivers 23 req/s – 61% faster than JIT off, closing the gap with Node.js
- Python trails at 5 req/s – expected for interpreted languages
The most important takeaway for the PHP community: enable JIT. The 61% boost transforms PHP from a performance underdog to a genuinely competitive option for CPU‑intensive tasks. While Go still leads, PHP 8.5 with JIT has firmly established itself as a viable choice – no longer the “slow language” of legend.
All raw data and methodology are provided. Reproduce this benchmark on your own hardware to validate results.
With this kind of comparison, it’s unclear where the improvement comes from: the server or PHP itself. It would make more sense to show fair single-threaded performance.
“Great question! The article actually already addresses this. In the test, we intentionally set the concurrency level of the ab benchmarking tool to 1, meaning only one request is processed at a time. This was done to eliminate the impact of server‑side concurrent scheduling, ensuring that what we measured is the ‘single‑threaded’ computational performance of the PHP engine itself, rather than the server hardware’s contribution. Therefore, the performance improvement of PHP 8.5 over older versions in the test can indeed be attributed to its own optimizations (especially JIT).”