Repository navigation
Design Doc
Main use case
- Master(M) starts, slaves(S) start and register to M. M waits until expected number of slaves are registered.
- M broadcasts a StartCluster message to all S. The message contains the name of the grid product to be used (CacheWrapper) and all needed params.
- Each S receives the StartCluster message, and setups the CacheWrapper. It sends back to the M a confirmation message to confirm that the CacheWrapper was successfully started.
- M blocks until it receives the confirmation message from ALL S.
- M broadcast an PerformWarmup message.
- Each S receives the PerformWarmup message, performs an warm up on the CacheWrapper and sends a message back to the M to confirm warm up is complete.
- M blocks until it receives the confirmation message from ALL S.
- M sends a StartTest message to all S.
- Each S receives the StartTest, runs the test and sends back to the M the result of the tests(e.g. duration, average put time, average get time).
- M blocks until it receives test result from all S.
- M sends a TestFinished message to all S.
- Each S stops the CacheWrapper and exits.
- M generates a report (csv).
- Master exists.
Alternative use case 1 3. One of the S cannot start the CaheWrapper. Sends back a message to the S informing that. 4. M receives confirmation from all slaves and decides (based on a config) that it wants to continue the benchmark. continue with step 7
Alternative use case 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 fwk extension and updating the configuration. The functionality would look something like this: 4.1 M broadcasts an ValidateCluster 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 5.
Alternative use case 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 would 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 User can do this by implementing fwk extensions for: cleaning up the state between runs, start more servers and wait for cluster re size. 10.1 M broadcasts a CleanupState message to all S 10.2 S cleans all owned state 10.3 M broadcasts a StartNodes 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 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.
- in order support high scalability (run tests on 1000 nodes) a master(M) will coordinate the slaves (S) in order to run the benchmark
- NIO should be used on the server, java.net.(Server)Socket does not scale well to this level
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 kick in JIT compiler
- runt 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 being sent to the master.
- generate reports stage, that gathers all reports from previous stage and aggregaes them (e.g. csv file)
- Stop cluster stage, in which all slaves stop their associated CacheWrapper
All stages (but generate report, that 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 weather we should move to next stage.
Report generation is a stage that only happens on the M. Algorithm:
on the Master
for (Stage stage: List<Stage>) {
if (!isDistributedStage(stage)){
stage.executeOnMaster();
continue;
}
stage.initOnMaster();
broadcast(srage); //will serialize the stage object and send it to the S
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);
}
Each stage (StartClusterStage, WarmupStage, RunTestStage) would have to implement the DistributedStage interface:
interface DistributedStage extends Serializable{
//called on server before serializing and sending over
initOnMaster();
initOnSlave();
Resp executeonSlave();
boolean processResponsesOnMaster(List<Rsp>);
}
The response class, sent from slaves to master looks like following:
class Resp implements Serializable {
// has the stage executed successfully on the slave?
boolean isSuccess();
// if !isSuccess, then this method might return the remote exception to be logged on the master
public Throwable getRemoteExcepption();
//from which slave this response is ( 0 <= slaveIndex < slaveCount)
public int slaveIndex();
}
The Resp might be extended for certain stages that need to send more information back to the server. E.g. for RunTestStage we want to send back the average duration for put and get operation on CacheWrapper.
class RunTestResp extends Resp {
long getAveragePutTime();
long getAverageGetTime();
}
there would be a different interface for Master only stages: MasterStage. This does't need to be serializable as it will execute in Master's address space.
interface MasterStage {
initOnMaster();
executeOnMaster();
}
Configuration
an xml file, having the following structure:
<benchmark initSize="2" maxSize="4" increment="1">
<DestroyWrapper runOnAllSlaves="true"/>
<StartCluster/>
<ClusterValidation partialReplication="false"/>
<Warmup operationCount="100"/>
<WebSessionBenchmark numberOfRequestsPerThread="100" opsCountStatusLog="10" numOfThreads="2"/>
<CsvReportGeneration/>
</benchmark>
The config file resides on the M. The parser will create the List and pass it to the algorithm running on M (see prev paragraph). The parsing algorithm looks like follows:
for (stage in list of xml elements) {
Stage stage = newInstance(element.class);
for (property p : stage.properties) {
//this method would look for a seter with name 'name' on object stage, and invoke it.
callSetter(stage, p.name, p.value);
}
}
Adding a new stage means just implementing the DistributedStage(or MasterStage) and adding it to the configuration file at the desired position. Removing or changing the order of stages can be done by changing the order of the stage elements in the config file.
- modularity, there's no dependency between stages
- any number of new stages can be easily created by implementing one of the Stage interfaces
- addition/deletion of stages is simple through configs