If you need a simple workload that generates HTTP Get/Post requests to multiple URLs, then it's possible to do that very easily in Faban using the fhb command line. All you need to do is to configure the workload using fhb configuration file. The fhb configuration file is essentially a stripped down Faban configuration file. An example is provided at samples/fhb/run.xml.
To control the mix of URLs accessed in the benchmark run, it's possible to assign weights to the URLs. This is similar to an operation mix in a general purpose driver. It's also possible to generate random values for parameters in the request strings by using pre-defined tokens.
We start the fhb driver definition with a runConfig element. The namespace rules for this configuration file is the same as any generic Faban configuration file and is documented in the Faban Harness Developers Guide. The Faban driver part of the configuration file is documented in the Faban Driver Developers Guide. Since almost all of the elements used in the fhb configuration file will use the driver namespace, we declare the driver namespace http://faban.sunsource.net/ns/fabandriver as the default namespace in the root element of the configuration file, which happens to be runConfig. Then you will want to provide your basic run parameters, scale, ramp up, steady state, and rampdown. These parameters override whatever you may have specified in the fhb command line. In the example below, we set a scale of 10 for 10 simulated users.
A Benchmark is defined using the <benchmarkDefinition> element. The benchmarkDefinition element and its child elements are defined by the driver namespace, but since we're using this as a default namespace (above) already, we can omit any namespace aliases for these elements.
The <benchmarkDefinition> element is optional and can be omitted if all default values are accepted.
In the HTTP driver, the definition of the driver is part of the the <driverConfig> element of the fhb config file. The name of the driver is specified in the <driverConfig> element as follows:
At this point of time, only one HTTP driver can be defined in a benchmark.
Operations define the logic to generate load to the severs. All operations for a driver are defined under the driverConfig element with an operation child element.
<!--timing is AUTO-->
<!--override benchmark level requestLagTime-->
<!-- other types can be specified in a similar manner-->
operation requires a name, an HTTP URL, an HTTP request string and
the 90th percentile limit for the response time.
request can be specified either as a GET or a POST. If a GET
is used, then the element must be <GET>
and the CDATA section must start with “?”. If a POST is
used then the element must be <POST>
and the CDATA section should not start with a “?”. You
must specify either a GET
or a POST element. If your request string is empty, you can leave the
value for the GET/POST element empty.
The request string specified in the <get> or <post> elements needs to be in an HTTP get/post format, with each name value pair separated by an “&”. Faban can generate random values (both numbers and strings) for any parameter in the request string. There are two kinds of random value generation supported by faban currently.
1. Random number between X, Y where X < Y.
2. Random string of length between X, Y where X < Y.
The value part of the name-value combination must have either of the following tokens
@@faban.getRandomInt(X,Y)@@ -- for a random number in the range of X, Y
@@faban.getRandomString(X,Y)@@ -- for a random string of length in the range of X, Y.
A mix tells the driver framework the policy or algorithm it should use to select operations. While the Faban driver framework may be extended to support additional mixes over time, currently it supports four mixes:
FlatMix - This mix randomly chooses the next operation to execute based on given probability for the mix.
MatrixMix - This mix maintains the state of execution. It chooses the next operation based on the current operation and a given probability ratio.
FixedSequence - The fixed sequence does what it says. There is no randomness. The operations are call in sequence.
FlatSequenceMix - This mix allows random selection of fixed sequences (as opposed to random selection of an operation in FlatMix).
This mix is specified in the faban config file:
The above defines a FlatMix. Other examples for mix are in the sample faban config file in Appendix D.
Cycle timings tell the driver framework the policy or algorithm to be used for inter-operation times. Currently, three timing characteristics are supported:
cycle timings can be defined at the driver level under the
or at the operation level under the <operation> element. The driver level definition covers all
operations in that
driver. The operation level definition specifies the cycle timings
for only that operation. It also overrides the driver level
definition if there is one, just for the given operation.
The followings example shows specifying the uniform distribution for cycle time at the driver level:
The following example shows specifying the fixed time distribution for cycle time at the operation level:
When putting the configuration file together, we should see the whole config file as shown in the fhb sample faban/samples/fhb/run.xml. The whole configuration file will be like the following:
Modify that according to your needs. You do not need to follow any other steps in this document for defining a driver if your needs are satisfied with a simple HTTP based driver. Then just simply run the workload by calling:
Observe the output from the run and follow the locations in the output. You'll be able to see the run output written to the terminal as well as in the target directories that store the output.