11,222 requests/sec with raw Node...
var http = require('http');
http.createServer(function(req, res) {
res.end('done');
}).listen(1337, '127.0.0.1');
=
gobench -c 100 -t 5 -u http://localhost:1337
Requests: 56112 hits
Successful requests: 56112 hits
Network failed: 0 hits
Bad requests failed (!2xx): 0 hits
Successfull requests rate: 11222 hits/sec
Read throughput: 1369156 bytes/sec
Write throughput: 1349088 bytes/sec
Test time: 5 sec
But with an Iron-Router server-side route in Meteor returning the same thing...
Router.route('/test', function() {
this.response.end('done');
}, {
where: 'server'
});
=
gobench -c 100 -t 5 -u http://localhost:3000/test
Requests: 6544 hits
Successful requests: 6544 hits
Network failed: 0 hits
Bad requests failed (!2xx): 0 hits
Successfull requests rate: 1308 hits/sec
Read throughput: 189776 bytes/sec
Write throughput: 164771 bytes/sec
Test time: 5 sec
Is the bottleneck Meteor or Iron-Router?
The bottleneck is a combination of a few things.
When you use a vanilla http
server you're missing out the middlewares used by Meteor and Iron Router (bodyparser & route matching) & route matching kit (meteor side). Also keep in mind Iron Router uses regexp to match routes.
The other thing is in meteor run
mode (that is not the bundled app from meteor build
) has an additional proxy server ontop of the app itself.
There are also a couple of other middlwares to check where to route the file from, (i.e whether its a static asset or not) (including for which architecture (cordova or client).
Additionally the index.html
file has to be generated per runtime in Meteor.
A hint of the Middleware used by Meteor come from the webapp
package: https://github.com/meteor/meteor/blob/devel/packages/webapp/webapp_server.js