Skip to content

Design Documentation

rvansa edited this page Mar 20, 2013 · 5 revisions

Use cases

Note: these use cases are outdated. RadarGun has currently many more stages implemented in order to allow resilience and elasticity testing (dynamic changes of the cluster), monitoring and profiling and behaviour checking.

Main use case

  1. Master (M) starts, slaves (S) start and register to M. M waits until expected number of slaves are registered.
  2. M broadcasts a StartCluster message to all S. The message contains the name of the grid product to be used (CacheWrapper implementation) and all needed params.
  3. Each S receives the StartCluster message, and sets up the CacheWrapper. It sends back to the M a confirmation message that the CacheWrapper was successfully started.
  4. M blocks until it receives the confirmation message from all S.
  5. M broadcast an StressTestWarmup message.
  6. Each S receives the StressTestWarmup message, performs an warms up the CacheWrapper instance and sends a message back to the M to confirm warm up is complete.
  7. M blocks until it receives the confirmation message from all S.
  8. M sends a StressTest message to all S.
  9. Each S receives the StressTest, runs the test and sends back to the M the result of the tests (e.g. duration, average put time, average get time).
  10. M blocks until it receives test result from all S.
  11. M sends a DestroyWrapper message to all S.
  12. Each S stops the CacheWrapper and exits.
  13. M generates reports
  14. Master exits.

Alternative behavior 1

  1. One of the S cannot start the CacheWrapper. Sends back a message to M informing that.
  2. M receives confirmation from all slaves and decides (based on a config) that it wants to continue the benchmark. continue with step 7

Alternative behavior 2

In order to make sure that the CacheWrapper was correctly set and that the underlying grid is formed, one might want to add an additional step to check that, before doing the warmup. User can do this by implementing a framework extension and updating the configuration. The functionality would look something like this:

4.1. M broadcasts a ClusterValidation message to all S 4.2. all S perform a custom validation as needed and report to M 4.3. M blocks until all validations are received and proceeds (or not, based on the received messages) to continue with step 5.

Alternative behavior 3

A user realizes that there is a more efficient way of running a benchmark on 2,4,6,8,10,12 slaves: instead of starting cluster on 2 slaves, run tests, stop the cluster and start again with 4 slaves etc, a better approach may be to:

  • run test on 2 slaves
  • clean all the state of the nodes
  • start the CacheWrapper on 2 more slaves and wait for new cluster to form (4 members this time)
  • run test on 4 slaves
  • clean state on all nodes and start again by adding 2 more nodes, etc.

You can do this by implementing framework extensions for:

  1. cleaning up the state between runs
  2. start more servers
  3. wait for cluster re-size

the description below is deprecated 10.1 M broadcasts a ClearCluster message to all S 10.2 S cleans all owned state 10.3 M broadcasts a StartCluster message to all S. Message contains currentClusterSize and number of slaves on which to start CacheWrapper 10.4 all S receive the message. S that have the index < currentClusterSize take no action. Slaves that have index >= currentClusterSize start a new CacheWrapper and confirm startup to M 10.5 M broadcasts an ValidateClusterSize message to all S 10.6 Each S receives the ValidateClusterSize message and confirms new size to the M 10.7 M blocks until all validations are received and proceeds (or not, based on the received messages) with 5.

Architectural consideration

  • in order support high scalability (run tests on 1000 nodes or more) a master (M) will coordinate the slaves (S) in order to run the benchmark
  • NIO should be used on the master node, java.net.(Server)Socket does not scale well to this level

Design

Generally speaking, a benchmark process is sequence of stages:

  • start cluster stage: starts the CacheWrapper on all slaves
  • warmup stage: on each slave execute a set of operations to allow JVM JIT compilers to kick in
  • run test: executes the actual test, on each slave. E.g. a web session simulation test that performs a number of reads and writes on a set of keys, on each node, at the same time, on each slave. At the end of the test reports are sent to the master.
  • generate reports stage, that gathers all reports from previous stage and aggregaes them (e.g. a CSV file) - Stop cluster stage, in which all slaves stop their associated CacheWrapper

All stages (except generate report, which only happens on the M) follow this pattern:

M -> broadcast to all S
S -> execute logic and send ack to M
M wait for all ack. Based on all ack, decide whether we should move to next stage.

Report generation is a stage that only happens on M.

Algorithm

On the Master

    for (Stage stage: List<Stage>) { 
      if (!isDistributedStage(stage)){
        stage.executeOnMaster(); 
        continue;
      }
      stage.initOnMaster();
      broadcast(stage);
      Set<Resp> responses = readRespFromAllSlaves();
      boolean shouldContinue = stage.processResponses(responses);
      if (!shouldCountinue) break;
    }

On the Slaves

    while (masterRunning) {
      Stage stage = readStage();
      Resp resp = stage.executeOnSlave();
      serializeRespToServer(resp);
    }

Implementing stages

Each distributed stage (StartClusterStage, WarmupStage, StressTestStage) has to implement the DistributedStage interface. For convenience you can use the AbstractDistStage as base class. Also, the stage class should be marked with the @Stage annotation. This annotation has required parameter doc: You should provide brief documentation here instead of using JavaDoc or plain comments. This documentation will be provided to the user as the documentation element in XML schema.

Stages usually have several properties that modify the behaviour/parameters of the stage. Each such property is a field (usually private or protected one) marked with the @Property annotation. Similarly to the @Stage, the doc parameter is mandatory as well and its content will be provided in the XML schema. The properties with common types (primitives, strings, enums, collections of those etc.) will be filled in automatically, if you need custom conversion (such as for time) you have to implement the converter and provide its class to the converter paremeter of the annotation. The field name will be used as the XML attribute by default - you can override this by specifying the name parameter. You can also specify deprecatedName as the previously used name for this attribute, if you're refactoring your stages and don't want to break backwards compatibility.

After the stage finishes an instance of DistStageAck is sent from each slave to the master.

DistStageAck might be extended for certain stages that need to send more information back to the server. E.g. for StressTestStage we want to send back the statistic for operations executed on CacheWrapper.

Master-only stages

There is a different interface for stages that only execute on the master. MasterStage doesn't need to be Serializable. The annotation mechanisms are otherwise similar to distributed stages.

Configuration

See benchmark.xml for an example of a RadarGun configuration.

If you want to specify different benchmark configuration, use the -config my-benchmark.xml as an argument to the LaunchMaster.main(...) or master.sh -c my-benchmark.xml if you are running RadarGun using the script.

The configuration file resides on the M. A configuration parser will create a list of stages and pass it to the algorithm running on M, as described above.

Clone this wiki locally