Skip to content

Instantly share code, notes, and snippets.

@alevy
Created December 3, 2014 01:34
Show Gist options
  • Save alevy/7e5d78c11bbbb70be921 to your computer and use it in GitHub Desktop.
Save alevy/7e5d78c11bbbb70be921 to your computer and use it in GitHub Desktop.
MemJS load test
var cp = require('child_process');
var children = [];
for (var i = 0; i < 500; i += 1) {
children.push(cp.fork(__dirname + '/test_child.js'));
}
setTimeout(function() {
for (var i = 0; i < children.length; i += 1) {
children[i].send('hello');
}
}, 1000);
var memjs = require('memjs').Client;
client = memjs.create();
var iterations = 100;
function go(err) {
if (iterations > 0) {
iterations -= 1;
client.get('hello', go);
} else {
client.close();
}
}
process.once('message', function(m) {
go();
});
@alevy
Copy link
Author

alevy commented Dec 3, 2014

NOTE: Since the test spawns 500 processes, it can take up about 4GB of RAM, so make sure you have that free. If not, you can reduce the number of processes by modifying the number in the first for-loop in test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment