Wednesday, January 1, 2014

Performance test with limited bandwidth

    This Q&A from stackoverflow asks an interesting question: how to run performance test when there is no enough bandwidth between a test platform and a server.  In a typical HTTP transaction, the server response can be big, say 1000KB, so it's possible that the bandwidth bottleneck may force the client side to do less transactions and hence generate less load on the server. How do we workaround this limitation?  This question was asked on JMeter, but it applies to other test platforms as well.

    One idea to do this is by performing http transactions in a special way:  send HTTP requests and make server do all the processing to generate the responses but can't to send much of the data in them. This bandwidth conservation idea sounds easy but it is not trivial to implement.  Simply closing a TCP connection after sending a HTTP request may not work, since the server may detect that the TCP connection is torn down and abort the processing. If you close a connection after receiving the first data packet from server,  you may have received too much data since server will send the data in a burst.

   Luckily,  it's fairly easy to implement this idea on NetGend platform because it supports limiting the TCP receive window size (tcpRecvWinSize). This parameter will control how much data a serve can send to a client in a burst.  In addition, we can close the connection upon receiving the first data packet from server.  This is because we can send a HTTP request without doing a full HTTP transaction.  Note that on some test platforms, to send a desired HTTP request, you have to do a full HTTP transaction which involves waiting for the entire HTTP response to come.

    This effectively ensures that the server does all the heavy lifting in generating the responses but can't send too much data to consume the bandwidth.   Here is the simple script:
 function userInit() {  
      tcpRecvWinSize = 100;  //limit tcp window size
 function VUSER() {  
      connect("", 80);  
      msg = createHttpRequest("");  
     In this script, we set the TCP window size to be pretty small and it applies to all TCP connections in this test.  A VUser will connect to the server, create a HTTP request and send it to the server.  Finally it closes the connection upon receiving the first data packet.

     As we talked about in earlier blogs, performance test platform can also be used to do security testing like DDoS, the above script will "torture" a server so much that it can be both a good performance test and a good security test.

No comments:

Post a Comment