OpenSwoole performance

TechEmpower third party web framework benchmarks result

TechEmpower Framework Benchmarks

Benchmark and get QPS on your own machine

The following code launches ab process and sending 100K request to OpenSwoole HTTP server with 128 connections.

You can get an idea about the QPS supported by the OpenSwoole HTTP server and your machine.

#!/usr/bin/env php
<?php
$wait = new OpenSwoole\Atomic(0);
$pid = pcntl_fork();
if ($pid === 0) {
    $http = new OpenSwoole\Http\Server('127.0.0.1', 9501,OpenSwoole\Server::BASE);
    $http->set(['log_file' => '/dev/null', 'log_level' => OpenSwoole\Constant::LOG_INFO, 'worker_num' => OpenSwoole\Util::getCPUNum() * 2]);
    $http->on('workerStart', function () use ($wait) { $wait->set(1); });
    $http->on('request', function (OpenSwoole\Http\Request $request, OpenSwoole\Http\Response $response) {
        $response->end('<h1>Hello OpenSwoole!</h1>');
    });
    $http->start();
} else {
    $wait->wait();
    System('ab -c 128 -n 100000 -k http://127.0.0.1:9501/ 2>&1');
    OpenSwoole\Process::kill($pid);
}
OpenSwoole\Event::wait();

Test case #1

Testing environment
  • CentOS 7 64bit
  • 8GB Memory
  • 24 Cores
  • Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz
  • PHP 7.1
  • Swoole v1.9.22
Benchmark result
Running 10s test @ http://127.0.0.1:1337/
4 threads and 400 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 3.56ms 2.95ms 218.94ms 98.04%
Req/Sec 27.80k 4.73k 37.95k 87.00%
1108229 requests in 10.03s, 223.00MB read
Requests/sec: 110515.99
Transfer/sec: 22.24MB

Test case #2

Testing environment
  • Ubuntu 16.04 LTS
  • Intel® Core™ i5-4590 CPU @ 3.30GHz × 4
  • 16G Memory
  • PHP 7.1
  • Swoole v1.9.22
Testing result
wrk -t4 -c400 -d10s http://127.0.0.1:1337/
Running 10s test @ http://127.0.0.1:1337/
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.46ms    1.42ms  27.96ms   85.66%
    Req/Sec    75.29k    36.43k  183.55k    72.75%
  3007806 requests in 10.06s, 605.25MB read
Requests/sec: 299103.32
Transfer/sec:     60.19MB