‹ BackHN Continuity

Thread

I built the fastest PHP webserver in the world

44 points · 77 comments · EGreg

  1. mschuster91 · · focus · HN ↗
    s/you built/you spent LLM tokens to build/g

    The general idea makes sense. PHP, particularly modern Java-style PHP, is notorious for loading sometimes thousands of files for every single request. I think there's opcache enabled by default, so the load on the filesystem is reduced by quite a bit, but even opcache still needs to do some sort of parsing for each request that comes in.

    1. EGreg · · focus · HN ↗
      Whether the opcache is enabled or not, the vast majority of production PHP code is I/O bound - workers wait for the network or filesystem or database.

      Roadrunner, FrankenPHP and Swoole try to make it evented like Node, but require you to rewrite all your code to use their libraries. For everything from mysql to curl.

      This lets you run your PHP unmodified, in 2 different ways:

      1) with long persistent workers, clearing all statics and globals between requests

      2) if that doesn’t work, eg because your functions have static variables inside etc. then you can use the fork mode, which can still handle 100x as many users as php-fpm due to the amount of RAM each of the workers takes up aa that’s the point!

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.