In this post I will explain how to use Facilita Forecast Shared Data Server (SDS) to control user ramp-up whilst executing a Load Test.Two occasions come to mind where this may come in useful:
- You need to find a breaking point, but you would like to have fine grained control of user ramp-up. E.g. 100 users in first minute, if it all works fine then keep adding users and pause after each increase.
- You need to first see if system works OK with X users. After that run the actual test, but you don’t want to restart the test.
So let’s first start by setting up SDS at VirtualUser level, this only connects to SDS server once.
We need to add this to VirtualUser.h:
public: // Gets a command for this user from SDS void getCommand(); private: // SharedData server SharedData sharedData;
Next I will initialise a connection in the VirtualUser::pre() method and close this in VirtualUser::post() method:
void VirtualUser::pre() {
try {
// Trying to connect to Shared Data Server
sharedData.connect(getString("SDS_IP", "localhost"), getInt("SDS_Port", 5099));
} catch (FatalCommunicationException e) {
// Connection failed, so we will stop this script
error("Failed to connect to Shared Data Server");
exitVU(false);
}
}
void VirtualUser::post() {
sharedData.close();
}
Now the part that controls the user limit for specific group. We will be using group name as the key and value will be the current limit of concurrent users. We will need to add this as the first script of workflow. It will repeat this cycle for as long as current user’s index is higher than user limit. I put in a 10 second pause between checks, but you can change this to what ever suits you best.
while (true) {
try {
// Getting user limit from SDS fopr this group
string limit = getVU().sharedData.get(getVU().getName());
// Comparing to current user index
if (atoi(limit.c_str()) < getVU().getIndex()) {
writeMessage("Reached user limit (" + limit + ")!");
// Sleeping 10 seconds
pause(10 * 1000);
continue;
}
break;
} catch (Exception e) {
}
}
Using this example there are two issues:
- To stop the tests you need to abort the test if there are still users waiting for user limit to increase. You can stop the test and wait for all other users to stop and after that abort to stop the waiting users. I will talk about how this can be overcome in a future posts [TODO: Insert link here].
- When you lower the user limit, users with indexes over limit will not stop running. See my previous article Using Shared Data Server (SDS) for Test Control – Individual User Control. I shall cover more on this topic later on.


Performance Reliability
Creating a Performant System
Monitoring Cache Performance
The Appetite to Eat Efficiency
Anti Performant Patterns
Twitter
LinkedIn
RSS