AWS c4.xlarge instance with 32gb EBS, io1 store type with 960 IOPS
Latest 64bit AMI Linux
Default php56 installed with YUM, including opcache,fpm,mbstring
Default nginx installed with YUM, with some configurations
Ensure that php-fpm has process priority
Use epool
2 workers
PHP-FPM setup with TCP connections over port 9000
Static server setup, 5 children
PHP, NGINX - All logging disabled
Composer deps all installed and then autoloader generated with -o
optimizations
These are very important for getting max preformance:
opcache.save_comments=0
opcache.enable_file_override=1
opcache.memory_consumption=1024
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=160000
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.fast_shutdown=1
opcache.enable_cli=0
Framework installs are current latest stable versions of each framework.
Frameworks are installed from composer with 0 modifications. Slim has a custom app file that is included below to load the app classes and do the exact same thing that lumen is doing in its routes.php file.
Tests are executed with AB using the command strings listed below:
ab -t 20 -c 100 -k http://127.0.0.1/
ab -t 20 -c 100 -k http://127.0.0.1/slim.php
Lumen app is executing the following code (default in app/Http/routes.php:
<?php
$app->get('/', function () use ($app) {
return $app->welcome();
});
Slim app is written as below (modified version of the hello world app to make the view data identical in length):
<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/', function () {
echo '<!DOCTYPE html>
<html>
<head>
<title>Lumen</title>
<link href="//fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<style>
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: #B0BEC5;
display: table;
font-weight: 100;
font-family: "Lato";
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 96px;
margin-bottom: 40px;
}
.quote {
font-size: 24px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Lumen.</div>
</div>
</div>
</body>
</html>
';
});
$app->run();
Requests per second: 2696.89 [#/sec] (mean)
Time per request: 37.080 [ms] (mean)
Complete requests: 50000
Failed requests: 0
Requests per second: 2189.81 [#/sec] (mean)
Time per request: 45.666 [ms] (mean)
Complete requests: 43797
Failed requests: 0
AB has a built in default of 50000 requests when using a time based test. IMO, this does not significantly effect the Lumen result, which does hit this limit.
Lumen on hardware that emphasizes CPU workloads is 18.80~% faster then Slim Framework v2 when rendering the exact same view data (taken from lumen).
This generally means nothing outside of epeen boasting though. Average request times differ by 7ms. While not insignificant, your code is likely to be much less preformant then these base classes are(due to you actually doing something), and the design of a framework relative to what you want to do with it is much more important this these type of benchmarks when picking a framework.