Script to open a webpage many times to test a server-Collection of common programming errors
If you are running an Apache server you could use the Apache benchmark command-line tool.
So let’s say for this instance that your server is running on localhost(127.0.0.1), port 8000. If we want to know whether the concurrent connections can be handled by the server we’d have to have a script that executes for a set amount of (mili)seconds and take the average of that.
So let’s create a JavaScript function for your server that does a 1 second timeout like this:
setTimeout(function() {
console.log("Executed")
}, 1000)
With the Apache command-line tools installed run the following command
ab -n 100 -c 100 http://127.0.0.1:8000
If all goes well you should see the average time it has taken to execute a single script. The results should be somewhere between 1 and 1.1 seconds.
I would assume that you are using NodeJS? If not I would definitely recommend looking into it. Mostly because of it’s non-blocking awesomeness.