Is PHP Really Slow? Debunking Myths with Real Performance Benchmarks
This article examines common misconceptions about PHP performance, compares it with Go using Workerman, Swoole, and other frameworks, and explains why modern PHP frameworks claim high speed while highlighting JSON handling, coroutines, and asynchronous programming in PHP.
Is PHP performance really poor?
When comparing PHP with other languages, many claim that raw performance numbers are meaningless because the main bottlenecks are usually the database and business logic. However, a benchmark of Workerman shows that Workerman can outperform Go in certain I/O tests.
The original test can be viewed at https://www.workerman.net/a/1337, which compares Go, Workerman, Webman, Swoole, and Swoole with coroutines.
Workerman outperforms Go in stress tests.
Webman short‑connection performance exceeds Go.
Webman's keep‑alive long‑connection is slightly lower than Go.
Swoole short‑connection beats Go.
Swoole keep‑alive is lower than Go.
Both Workerman and Webman surpass Swoole for short and keep‑alive connections.
Overall, Workerman and Webman show strong results in a basic hello‑world I/O test, which, while simple, reveals an interesting phenomenon.
Why do modern PHP frameworks claim high performance?
As web applications demand faster response times and higher concurrency, traditional PHP development faces limitations in handling concurrent requests. New PHP frameworks such as Swoole, Laravel, Yii, and ThinkPHP have introduced extensive performance optimizations, including event‑driven architectures and epoll‑based drivers, to meet these demands.
These modern frameworks also push the PHP language itself forward, resulting in genuine performance improvements over older PHP versions.
PHP itself is evolving; judging it by PHP 5 is outdated.
The PHP ecosystem is changing, with new frameworks focusing on performance.
Execution models have shifted from PHP‑FPM to epoll‑driven runtimes.
Does performance comparison matter?
Comparing Go and PHP reveals several noteworthy points.
JSON handling
Go's JSON parsing is not necessarily faster than PHP's. PHP's JSON functions are implemented in C, making them very fast even under PHP‑FPM, and they allow direct conversion from a JSON string to an array or object without pre‑defining a schema.
Coroutines
PHP supports coroutines via the yield keyword, but the syntax is obscure. Swoole adopts Go‑style go syntax, making coroutine usage in PHP much more approachable.
Asynchronous programming
PHP is fundamentally synchronous; most operations like file_get_contents block the execution thread. Nevertheless, several projects provide asynchronous capabilities, such as Workerman, Swoole, and ReactPHP.
One interesting project under ReactPHP, chemem/asyncify, enables any PHP code to run asynchronously. The usage is straightforward:
use function Chemem\Asyncify\call;
$call = call('file_get_contents', ['foo.txt'])
->then(
function (?string $contents) {
echo $contents;
},
function (\Throwable $err) {
echo $err->getMessage();
}
);Conclusion
Developers love performance comparisons, and PHP developers are especially vocal about them. The PHP ecosystem is vast, leading to diverse opinions on frameworks and performance claims. While some enthusiasts champion Swoole exclusively, others overlook alternative viewpoints.
It is inaccurate to say that PHP is “split” or lagging behind; the language has remained active and continues to evolve. However, many PHP practitioners still lack deep technical expertise, which can affect the quality of performance discussions.
Performance benchmarks can be fun experiments—e.g., a JSON‑parsing speed contest—where PHP may not be the fastest but remains competitive enough for most use cases.
Original article sourced from PHP武器库: https://phpreturn.com/index/a641fb3f399f10.html . If the original author objects, please contact for removal.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
