Skip to content

Instantly share code, notes, and snippets.

@einaros
Created December 30, 2011 10:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einaros/73944170aeb88634c599 to your computer and use it in GitHub Desktop.
Save einaros/73944170aeb88634c599 to your computer and use it in GitHub Desktop.
First up: 3.5 MB of postdata where the properties all end up in the same hash bucket
einaros@dumpster:~/crashtest$ time curl -d @postdata_bucketcrash http://localhost:9999
279343: ok
real 0m52.142s
user 0m0.044s
sys 0m0.052s
Second: 3.5 MB of postdata where the properties (mostly) end up in different hash buckets
einaros@dumpster:~/crashtest$ time curl -d @postdata_plain http://localhost:9999
279343: ok
real 0m1.562s
user 0m0.028s
sys 0m0.052s
Conclusion:
For this test, with a relatively small amount of data, parsing the colliding properties takes roughly 33x the time. Generating a significantly larger data set is trivial => keeping a server busy is trivial.
The test application:
var express = require('express');
var app = express.createServer();
app.use(express.bodyParser());
app.listen(9999);
app.post('/', function(req, res) {
res.end(Object.keys(req.body).length + ': ok\n');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment