Created
October 3, 2010 07:49
-
-
Save JakSprats/608374 to your computer and use it in GitHub Desktop.
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
// A simple web server | |
var http = require("http"), server; | |
server = http.createServer(function (request, response) { | |
response.writeHead(200, { | |
"Content-Type": "text/plain" | |
}); | |
response.write("Hello World\n"); | |
response.end(); | |
}).listen(80); |
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
// A simple web server that generates dynamic content | |
// based on responses from Redis | |
var host = '192.168.1.120', | |
http = require("http"), server, | |
redis_client = require("redis").createClient(6379, host); | |
server = http.createServer(function (request, response) { | |
response.writeHead(200, { | |
"Content-Type": "text/plain" | |
}); | |
redis_client.incr("requests", function (err, reply) { | |
response.write("requests: " + reply + "\n"); | |
response.end(); | |
}); | |
}).listen(80); |
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
#!/bin/bash | |
THRESH_SLEEP=5 | |
RQ_NUM=100000 | |
HOST="192.168.1.157" | |
PORT=80 | |
function conc_node_reqs() { | |
T=0 | |
if [ -n "$1" ]; then | |
T=$1 | |
fi | |
while [ $C -lt $MAXC ]; do | |
if [ $T -gt 0 ]; then | |
while true; do | |
THRESH=$(wc -l /proc/net/tcp |cut -f 1 -d \/) | |
if [ $THRESH -le $T ]; then break; fi; | |
echo " Sleep $THRESH_SLEEP: THRESHOLD: $T is not yet met $THRESH"; | |
sleep $THRESH_SLEEP | |
done | |
fi | |
echo -ne "$C: "; | |
taskset -c 1 ab -n $RQ_NUM -c $C -k http://${HOST}:${PORT}/ 2>/dev/null |grep "Requests per second:" | |
C=$[${C}+${CDELTA}]; | |
done | |
} | |
MAXC=20; | |
C=1; | |
CDELTA=1 | |
conc_node_reqs | |
C=20 | |
MAXC=200; | |
CDELTA=20 | |
conc_node_reqs | |
C=200 | |
MAXC=4000; | |
CDELTA=100 | |
conc_node_reqs 2000 | |
C=4000 | |
MAXC=20000; | |
CDELTA=2000 | |
conc_node_reqs 2000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment