What is fastest? HTML, Lua, Node.js, or PHP

I installed in a server OpenResty and PHP-FPM.

OpenResty is very interesting because Lua is integrated with Nginx.

This is Nginx configuration for Lua:

location /lua {
        default_type text/html;
        content_by_lua 'ngx.say("<p>Hello</p>")';
}

And for PHP-FPM:

location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

This is a little program with Express:

var express = require('express');
var app = express();
app.get('/', function (req, res) {
  res.send('<p>Hello</p>');
});
var server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});

I used Apache HTTP server benchmarking tool for tests:

ab -k -n 50000 -c 2 -e lua.csv http://192.168.0.55/lua
ab -k -n 50000 -c 2 -e html.csv http://192.168.0.55/index.html
ab -k -n 50000 -c 2 -e node.csv http://192.168.0.55:3000
ab -k -n 50000 -c 2 -e php.csv http://192.168.0.55/index.php

All pages show same content:

<p>Hello</p>

And these are the results:

fastest_lua_graph_00

fastest_lua_graph_01

And the winner is Lua!!!

Published on in Systems