Salesforce Site Load Testing

The easiest way to simulate thousands of users on your Site

There is many ways to identify unit response time and behaviour of any page hosted on your site. But what is the system behaviour and response time when you get lots of simultaneous visits? To identify this before this can occur with real visitors, you will have to simulate the traffic.

There is a really simple tool avaible in the cloud. loader.io allows you to do real-time load testing by defining the concurrent requests and duration. Before using this tool, you first have to get in touch with Salesforce, because this could be an infrigment to Salesforce MSA ( http://www.salesforce.com/assets/pdf/misc/salesforce_MSA.pdf ): Your Responsibilities - "You shall not interfere with or disrupt the integrity or performance of the Services". Violating this term may cause termination of your contract (closing your org). That's why you have to log a case and get Salesforce approval.

Once Salesforce.com is aware of your planed test and you got the approval, then you can start. Get an access to loader.io, an email is required, you will have to confirm your registration by clicking a link inside an email sent to you. This takes 20 seconds. Then you can start creating a new Test. Click on the blue button "New Test", enter the URL of your Salesforce Site, define the duration (I suggest that it should be less than 30 seconds, enough to start a load testing), define the concurrent connections (it means: how many people will load this page simultaneously), leave the timeout to 10 seconds, put a comment to remember the goal of the test and Start the test. You have spent 1 minute to configure your test!

You will be redirected to a verification screen: you cannot load-test a website that is not yours. This will take time to configure Salesforce accordingly. Create a VisualForce Page and put the expected content in the page (ex : loaderio-4d370194132243c2a33ab1f3196574c0 ). Add the apex:page tag like this:

<apex:page contentType="text/plain">loaderio-4d370194132243c2a33ab1f3196574c0
</apex:page>

As we cannot create a ".txt" extension for a VisualForce page, will we have to name the page "myLoaderIO" and do some URL Rewriting.
Add the myLoaderIO page to your Site.

Create an apex class with the following code, and add it as the URL Rewrite class in your Site configuration page.

global class yourClass implements Site.UrlRewriter {
	String verifyLoaderIO='loaderio-4d370194132243c2a33ab1f3196574c0';
	String LoaderIOVisualForcePageName='myLoaderIO'; //The Name of your VF Page
	global PageReference mapRequestUrl(PageReference myFriendlyUrl){
		//Maps a user-friendly URL to a Salesforce URL.
		String url = myFriendlyUrl.getUrl();
		if(url.startsWith('/'+verifyLoaderIO)){
			return new PageReference('/'+LoaderIOVisualForcePageName);
		}
		return null;
	}
	global PageReference[] generateUrlFor(PageReference[] mySalesforceUrls){
		List<PageReference> myFriendlyUrls = new List<PageReference>();
		for(PageReference mySalesforceUrl : mySalesforceUrls){
			String url = mySalesforceUrl.getUrl();
			if(url==LoaderIOVisualForcePageName)
				myFriendlyUrls.add(new PageReference(verifyLoaderIO+'/'));
		}
		return myFriendlyUrls;
	}
}
Ensure everything is working by displaying the expected URL in your browser: http://yourcompany.force.com/loaderio-4d370194132243c2a33ab1f3196574c0/
Salesforce URL rewriting cannot manage periods in rewritten URLs, that's why we cannot certify our Site with a .html or .txt file. We have to prefer the first proposed solution which is a directory access (ending with /)
Now you will see in real time the progression, through an interactive graphic on loader.io page. After the test has run, you can see the impact on your Site limits, in the related list of your Site detail page "24-Hour Usage History".
A test has a huge impact on bandwidth consumption and Request Time (CPU usage), prefer running it on a sandbox.
View on loader.io