TechEmpower Framework Benchmarks
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();
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
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
Join 4,000+ others and never miss out on new tips, tutorials, and more.