Share via


Taking advantage of VSTS Load Testing for WCF Services

In WCF services, it becomes extremely important to test the configuration(Binding,Security,Instancing) and the actual implementation of the service are *optimum* for the expected and higher user loads.

Though Load testing is a very common feature of VSTS,most of the WCF developers are unaware of it.I found this load testing very useful and important in order to uncover any performance bottlenecks in the system.

Along with the user load testing, we can set Performance Counters on the server machines very easily and monitor few important counters. I am putting simple options to get Load testing for WCF running. However, there are various options by which we can configure Load Testing.

1. Create a WCF Service. Enable Performance Counters

<configuration>

<system.serviceModel>

<diagnostics performanceCounters="All" />

</system.serviceModel>

</configuration>

2. Add a Unit Test to a test Project

3. Add Service Reference of the WCF service and make a simple call.Please do not forget to Close the proxy as not closing will lead to timeout exceptions at the client side.

[TestMethod]

public void TestMethod1()

{

ServiceClient client = new ServiceClient();

string result=client.GetData(10);

client.Close();

}

4. Add a Load test in a test Project. Following screen will appear

AddNewLoadTest

5. Choose default option of ”User normal distribution centered on recorded think times”,

6. Click Next

7. Choose Constant User Load . It would be good for a WCF Service, we make constant user loads of 1,5,,50,100,200,400,800 and so on in order to get the breaking point where service is no longer able to handle the load.

8. Choose default option of Based on Total Number of tests click Next

9. Add the above created Unit test to this Load Test

10. Click Next for Computer Sets. We can monitor Performance Counters on the server itself. So just click next

11. Choose Run Settings as Warm up Duration 2 minutes,Run Duration as 10 minutes. You can change these settings in a property window later on. Click Finish

12. Load Test window will appear with all the chosen settings. Click on Run Settings and open Property Window. DONT FORGET TO MAKE “RUN UNIT TEST IN APPLICATION DOMAIN”=TRUE. It is false by default. The load test will not make use of config file if this is false and the test will throw errors.

runsettings2

13. On Server Machines, Go to Start->Run->Perfmon. In The Data Collector Sets->User Defined,right click and select new.

DataCollectorSet2

14. Select recommended option of template and click next. In the right Window, Double click on Performance Counters. Add Performance Counters .

15. For WCF Related Performance Counters such as Request per second or Calls per second,

Click on ServiceModelOperation 3.0.0.0 Category. In the Bottom Window *Select instance of your service*

PerfCat

16. After Adding all the Performance Counters, right click on data collector set and select properties.

StopCondition

17. Click on Stop Condition tab and give duration for which you want to run this data collector set. Now as soon as you will click on start this collector set, logging will be started. And it would be stopped after specified minutes.

18. So, give sufficient time in stop condition to capture the entire run of your load test. (So give duration=Load test Duration + some time say 1 minute)

19. Start the Data Collector set. Start the load test.

Now this is one time activity. For all the next runs with different user loads, you just need to start and stop data collector set+Load test. With all the values logged at the server side, you can easily find out bottleneck in the system for higher loads.