Created
December 3, 2014 01:34
-
-
Save alevy/7e5d78c11bbbb70be921 to your computer and use it in GitHub Desktop.
MemJS load test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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