DEV Community

klsoft
klsoft

Posted on • Edited on

Benchmark testing of FrankenPHP vs RoadRunner vs Swoole in Yii 3

FrankenPHP, RoadRunner and Swoole all use workers to handle incoming requests much more quickly. Now, let's look at how many requests each web server can process per second.

Testing environment: 13th Gen Intel® Core™ i7-1355U × 12, 16 GB

Testing tool: wrk

Prepare the FrankenPHP testing application.

{
    // ...
    "require": {
        // ...
        "yiisoft/yii-runner-frankenphp": "^1.0"
    },
}
Enter fullscreen mode Exit fullscreen mode
  • In your application root create worker.php.
  • Replace the contents of the docker/dev/Caddyfile with the following:
{
    skip_install_trust

    frankenphp {
    }
}

{$SERVER_NAME::80} {
    encode zstd br gzip
    php_server {
        root /app/public
        worker {
            num 12 # number of workers
            max_threads 12 # number of threads
            match *
            file /app/worker.php
        }
    }
}
Enter fullscreen mode Exit fullscreen mode
  • Replace the contents of the docker/dev/.env with the following:
APP_ENV=prod
APP_DEBUG=false
SERVER_NAME=:80
Enter fullscreen mode Exit fullscreen mode
  • Set DEV_PORT in the docker/.env:
DEV_PORT=8080
Enter fullscreen mode Exit fullscreen mode
  • Run make composer update.
  • Run make up.

Run benchmark testing:
./wrk -t12 -c1000 -d30s http://localhost:8080

Prepare the RoadRunner testing application.

Run benchmark testing:
./wrk -t12 -c1000 -d30s http://localhost:8080

Prepare the Swoole testing application.

return [
    // ...
    'klsoft/yii3-swoole' => [
        'swooleServerSettings' => [
            'reactor_num' => 12, // number of threads
            'worker_num' => 12 // number of workers
        ]
    ],
];
Enter fullscreen mode Exit fullscreen mode
  • Run docker compose up -d.

Run benchmark testing:
./wrk -t12 -c1000 -d30s http://localhost:9501

Results

FrankenPHP vs RoadRunner vs Swoole benchmark testing result

Top comments (0)