PreviousBeginningNext

Communicating with the SUT

In most cases, a benchmark written using the Faban driver framework will want to simulate user load to one or more servers. Various mechanisms and protocols exist for such communications. But since a single Faban agent typically simulates multiple users, great care has to be given to the communications layers to ensure that each simulated user actually uses their own separate resources such as socket connections.

Many of the client-side communications libraries do an excellent job at pooling resources. This greatly benefits the performance and address space size of the client program. However, such optimizations usually render the libraries unsuitable for user simulation work, just because of the sharing that happens will not accurately simulate the number of users specified.

The Faban driver framework provides transports for http/https which provide simplified APIs for web access. There are two implementations of transports based on two client libraries:

  1. Sun's java.net.HttpURLConnection, HttpsURLConnection, and related classes.
    This mechanism is lightweight and simple.  However, it lacks support for several more complex features such as redirects between https and http, file uploads, etc. The Sun webservices implementations make use of this library so it is crucial to load this transport when using Sun web services in order to make use of the more accurate timings.
    To instantiate the Sun transport for communicating directly with the server, simply call:
     HttpTransport.newInstance();
    To just use the auto timers and prevent connection sharing, you can also just load the transport implementation as follows:
     static { 
    Class.forName("com.sun.faban.driver.transport.sunhttp.SunHttpTransport");
    }
  2. Apache Commons HttpClient 3.1.
    HttpClient 3.1 (also referred to as HC3.1) is heavier, but also provides a larger feature set such as uploads. Some web services libraries and higher level web page APIs such as HTMLUnit make use of HC3.1. So be sure to load this transport if such APIs are used.
    To instantate the Apache HC3 transport, make the following calls:
     HttpTransport.setProvider("com.sun.faban.driver.transport.hc3.ApacheHC3Transport");
    HttpTransport.newInstance();
    To just use the auto timers and prevent connection sharing, you can also just load the transport implementation as follows:
     static {
    Class.forName("com.sun.faban.driver.transport.hc3.ApacheHC3Transport");
    }

The Faban transports have been implemented in a way to eliminate or minimize resource sharing between simulated users.  A very important feature is also the support for automatic timing. Beyond that, the provided transports also include a host of convenience methods to make communication with the server very easy to implement.

The Faban driver framework still allows for communication protocols not supported by Faban transports but provided by other client libraries. But the developer or user will need to either ensure that resource pooling between threads does not happen or accept the inaccuracy of the simulation. If the target library allows for setting the socket factory, automatic timing may still work by setting the socket factory to TimedSocketFactory. The method to call is commonly named "setSocketFactory." Otherwise, the only option would be to use manual timing. Please see Recording Time for more information about timing.

PreviousBeginningNext