tags:

views:

78

answers:

1

I am new to socket programming and I have written a code for the server using the epoll. Basically it would wait to accept for any client connection and it would send data to the clients if the data is available from other sources.

I need to test on how is the performance of the server when there are multiple requests for the connection and when the server is sending data to multiple clients. The question I have is how could I simulate a concurrent requests of the connection from a number of clients for the server? Do I create multiple threads to request or multiple processes or some other ways to test it?

Thanks.

+6  A: 

I usually create a client program simulating one session with the server, find as many linux boxes nearby and spin up a thousand of them on each machine from a command line like:

 for i in {0..1000} ; ./myprogram serverip & done

In some cases the protocol is text based and the interaction or test is simple, so I don't have to write myprogram but just use netcat, as in running nc serverip < input >/dev/null

If all you need is to test streaming data to your client, I'd start with netcat and work my way from there.

This approach is ok for my needs, I usually don't need to test more concurrency than a handful of thousand clients. If you need more scalability, you'll likely have to write the client simulator using io multiplexing (epoll) as well, having each instance simulate as much interactions as you can - and you'll have to do more controlled tests to find limits of your client .

Don't mix performance testing with functional testing though. While you might get awsome performance in a test environment, a live environment can be very different. e.g. clients will misbehave, they will disconnect at the most inapproriate of times. They might send you malicious data. They might be slow, leading to buildup of internal queues on the server or leving you with thousands of seemingly idle connections (killall -STOP nc while in the middle of sending data to test clients might show you interresting things)

nos
If you're using Linux and ksh shell you could change `{0..1000}` to ` `seq 0 1000` ` (the first notation works only in bash)
jyzuz