Created
May 13, 2014 11:16
-
-
Save stephank/764e3414d57bc3bcb6b3 to your computer and use it in GitHub Desktop.
Redis pub/sub stress test
This file contains hidden or 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
#!/usr/bin/env node | |
var net = require('net'); | |
var host = process.argv[2] || '127.0.0.1'; | |
var port = parseInt(process.argv[3], 10) || 6379; | |
var len = parseInt(process.argv[4], 10) || 3000; | |
var msg = | |
'*3\r\n' + | |
'$7\r\n' + | |
'publish\r\n' + | |
'$6\r\n' + | |
'foobar\r\n' + | |
'$' + len + '\r\n' + | |
(new Array(len + 1)).join('x') + '\r\n'; | |
var s = net.createConnection(port, host); | |
s.on('data', function() {}); | |
s.on('connect', spam); | |
function spam() { | |
setImmediate(function() { | |
s.write(msg, spam); | |
}); | |
} |
This file contains hidden or 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
#!/usr/bin/env node | |
var net = require('net'); | |
var host = process.argv[2] || '127.0.0.1'; | |
var port = parseInt(process.argv[3], 10) || 6379; | |
var msg = | |
'*2\r\n' + | |
'$9\r\n' + | |
'subscribe\r\n' + | |
'$6\r\n' + | |
'foobar\r\n'; | |
var s = net.createConnection(port, host); | |
s.on('data', function() {}); | |
s.on('connect', function() { s.write(msg); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment