Skip to content

Instantly share code, notes, and snippets.

@dborsatto
Created July 20, 2018 10:25
Show Gist options
  • Save dborsatto/43e7ae37aa5d88d666b109aeff92c117 to your computer and use it in GitHub Desktop.
Save dborsatto/43e7ae37aa5d88d666b109aeff92c117 to your computer and use it in GitHub Desktop.
var http = require('http');
var app = function (req, res) {
res.writeHead(200, {
'Content-Type': 'application/text'
});
res.end('Hello World');
};
var server = http.createServer(app);
server.listen(1337, function() {
console.log("Server running at http://127.0.0.1:1337");
});
<?php
$http = new swoole_http_server("127.0.0.1", 1337);
$http->on('start', function ($server) {
echo "Swoole http server is started at http://127.0.0.1:1337\n";
});
$http->on('request', function ($request, $response) {
$response->header('Content-Type', 'application/text');
$response->end("Hello World");
});
$http->start();
# Node 10.7
$ node index.js
$ 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 15.91ms 3.62ms 52.44ms 71.28%
Req/Sec 5.75k 449.16 6.70k 81.00%
228929 requests in 10.00s, 44.10MB read
Socket errors: connect 0, read 306, write 0, timeout 0
Requests/sec: 22881.62
Transfer/sec: 4.41MB
# PHP 7.1
$ php index.php
$ 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 6.34ms 6.62ms 99.25ms 89.06%
Req/Sec 16.09k 3.88k 28.68k 69.85%
642395 requests in 10.08s, 104.76MB read
Socket errors: connect 0, read 232, write 0, timeout 0
Requests/sec: 63710.90
Transfer/sec: 10.39MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment