← Sat, Sep 19 digest

I built the fastest PHP webserver in the world

read article ↗ hn thread ↗

summary

Qbix is a pure PHP web server that achieves superior throughput compared to traditional PHP-FPM or coroutine-based alternatives by utilizing copy-on-write memory management through pcntl_fork(). By loading the framework into a parent process and forking workers, the server reduces the memory footprint per worker to roughly 120KB, allowing thousands of workers to handle blocking I/O without the overhead of a full process restart. This approach enables unmodified PHP applications to scale significantly on minimal hardware without requiring external extensions or containers.

key points

  1. The server leverages the OS kernel's copy-on-write mechanism to share loaded classes across workers, which prevents the massive memory waste seen in PHP-FPM's isolated worker model.
  2. Unlike Swoole, which requires coroutine-aware drivers to avoid blocking, Qbix handles unmodified blocking I/O by simply deploying a massive number of low-cost workers to maintain high throughput.
  3. State safety is maintained between persistent requests using a Reflection-based snapshot system and shimming 28 core PHP functions to reset the environment in 0.03ms.

who should read it

PHP developers and system architects who want to increase application performance and reduce infrastructure costs without rewriting their existing codebases.

discussion skeptical

consensus

Commenters are deeply divided over the project's legitimacy, with a significant portion viewing it as 'LLM slop' due to the AI-generated nature of the code and documentation. While some acknowledge the impressive performance claims and the appeal of reducing stack dependencies, others remain skeptical of its production readiness and the actual utility of its 'post-fork' architecture. The overall sentiment is one of suspicion mixed with curiosity about the performance gains.

top insight

The webserver achieves high concurrency by using a 'post-fork' model where classes are loaded before pcntl_fork(), leveraging OS copy-on-write memory pages to minimize the memory footprint of each worker. This allows it to handle significantly more simultaneous users than PHP-FPM by avoiding the repeated bootstrapping of frameworks on every request. This approach provides the speed of async runtimes like Swoole while maintaining PHP's shared-nothing isolation.

Generated by an LLM from the article and thread. Check the sources before relying on it.