0

I have the following:

 var tempServer=require("./myHttp"); tempServer.startServer(8008,{'/fun1':fun1 , '/fun2': fun2 , '/fun3':fun3 , '/fun4':fun4},"www"); 

which creates a server on localhost:8008.

and if i type in the url line in my browser the following:

 localhost:http://localhost:8008/fun2 

it will call fun2 function and will perform what is needed.

having said that,

how can i write a script function (fun2) which simulates a call for a large number

of requests (say 10000) to tempServer?

any help will be much appreciated!

6
  • You wan't a server to access itself ? Commented Dec 19, 2011 at 1:41
  • no, i just want a script that simulates large number of calls to the server... Commented Dec 19, 2011 at 1:44
  • Yeap, but your fun2 function is called from your tempServer, and should make calls to tempServer. Am I right ? If I am, it doesn't make sense... Commented Dec 19, 2011 at 1:47
  • tempServer can perform this functions,yes. but is there a way to make these function to simulate a request? in other words, call itself? i dont know it can be done... Commented Dec 19, 2011 at 1:54
  • Are you attempting to stress or load test your server? Commented Dec 19, 2011 at 1:56

2 Answers 2

1

You could try this on your laptop, but you would find that your computer will not really be able to create 10,000 requests to a temp server (or anyplace) at the same time. Most modern machines top out around 1000 or so simultaneous connections.

You can create something in code that will certainly do this one connection after another, but this is not the same as a true load test where you ramp up and ramp down the number of requests per second. You will quickly find that this is IO and connection-bound and not a true test for your application.

Your best bet, if you are trying to benchmark/stress your server, is to put your server on a box or service that is internet accessible like nodejitsu or nodester (both free services) and then use another service (free or otherwise) to hit your server's URL. You don't say if this is what you're doing, but this is the usual way to do load and stress testing.

Two companies that I have used in the past are Load Impact and Blitz.io to get the number of simultaneous user requests to your server. for 10,000 users you will need to pay a bit but it's not too large a fee.

You may also want to look into the libraries from New Relic to help you monitor the server/service itself and how it behaves under stress. They have some great capabilities in helping find bottlenecks in applications.

This may be a bit more than what you were looking for, but I hope that it's helpful. If I am off the mark, let me know and I'll be happy to amend this to be closer to what it is you are looking for.

Sign up to request clarification or add additional context in comments.

Comments

0

Are you interested in scripting 10,000 calls to fun2 via http2 or issuing 10,000 requests from fun2 within node?

If it is within Node and as you probably know all the code is written as sequential but the events are executed asynchronously.

Check the EventEmitter for dispatching function calls on evens:

http://nodejs.org/docs/v0.4.7/api/all.html#events.EventEmitter

and see this example as an inspiration for issuing calls in parallel:

http://ricochen.wordpress.com/2011/10/15/node-js-example-2-parallel-processing/

Hope this helps.

Edmon

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.