Stress testing is one of key aspects that developers should take into consideration in order to maximize the performance of Web Service deployments. Windows Communication Foundation (WCF) provides a very extensible framework for monitoring and configuring WCF Services performance profiles. However one key pieces of successful load testing is precisely to execute the correct tests and for that using the correct tools is fundamental. Load tests are typically based on relatively complex algorithms that encompass aspects such as thread management, memory, message throughput, etc. For instance, a typical Web Service test might include sending a thousand messages per second to a Web Service using five threads until the consumed memory hits 1GB. Such algorithms require a detailed knowledge of the Web Service technology as well as the operating system being used.
There are a variety of tools and frameworks to execute load tests algorithms against Web Services. MindReef's SOAPScope remains my favorite (even though my buddy Tim Ewald is not part of the team anymore J) although I always like to consider alternatives especially for Microsoft CS (not J2SE friendlyJ) technologies. Stress testing becomes even more challenging with sophisticated Web Services toolkits such as WCF or Apache Axis2 given that most load tests tools don't support advanced Web Services features such as WS-* protocols or multi-transport and in the few cases they do interoperability becomes a big challenge. Consequently, in order to test those complex Web Services, developers need to base the tests on an interoperable Web service technology which brings me to the topic of this post J.
Lately I've spent some time playing with my favorite BizTalk Server load generation tool (LoadGen) to stress test WCF Services. Until now LoadGen has been mainly considered a BizTalk centric tool with the capability to execute complex load testing algorithms against a variety of adapters and measuring BizTalk specific counters. However the latest version of LoadGen adds support for the WCF adapters included in BizTalk Server R2 which also makes it ideal for testing plain WCF Services J. Let's take the following service as an example.
public interface IMyService
int Add(int param1, int param2);
public class MyService : IMyService
public int Add(int param1, int param2)
return param1 + param2;
In order to test that service using LoadGen we can use the following message that will be embedded in the SOAP body.
Now we can follow the traditional techniques to configure LoadGen. The following configuration file instructs LoadGen to send 500 messages using four threads 50 to our service in a 20 seconds interval.
One of the things that you might have noticed in the load configuration file is that there are no references to the target WCF service. We can specify those settings in the LoadGenConsole.exe.config file as illustrated in the following figure.
<?xml version="1.0" ?>
LoadGen configuration settings....
<add name="loadgenwcfinterceptor" type="WCFTRansport.ActionModifierBehavior.LoadGenBehaviorBindingElement, WCFTRansport.ActionModifierBehavior, Version=188.8.131.52, Culture=neutral, PublicKeyToken=79de3c67dc9393f3"/>
<transport clientCredentialType="None" proxyCredentialType="None"
<message clientCredentialType="UserName" algorithmSuite="Default" />
<endpoint address="http://localhost:8080/WCF/Service.svc" binding="basicHttpBinding"
From the WCF perspective LoadGen is just another client and we can take advantage of all the client configuration options available with WCF.
In order to run the previous configured test we just need to use the LoadGen console passing the test configuration as an argument. The following figure shows a snapshot of the test results displayed in the LoadGen console.
What about performance monitoring?
On the service side we can now use monitoring tool to measure the performance of the server. There are a variety of alternatives to achieve this, the simplest one might be a combination of the WCF native trace listeners and performance counters. The following figure shows a snapshot of my performance monitor while I was executing the previous test.
More complex alternative might involve the use of sophisticated monitoring tools such as System Center, HP Open View, etc.
Support for multiple bindings
The service of our previous example was hosted in an endpoint using the basicHttpBinding WCF binding which makes it highly interoperable from a consumer perspective. However there are a lot of WCF services that use more complex binding to address more sophisticated scenarios. As we explained in the previous section, LoadGen allows to automatically plugging in a client binding configuration on the LoadGenConsole.exe.config which makes it no different from any other WCF client.
Using these feature developers can test any WCF service as long as the policy requirements can be addressed via WCF configurations. Additionally, this means that developers can take full advantage of WCF client side extensibility mechanisms such as custom client behaviors, message-parameter inspectors, binding elements, channels to extend the default capabilities of LoadGen.