Load Testing of Web API

In this article, I will explain about load testing of Web API step-by-step. Load testing is referring to a single functional service request to response time taken.

To create a Web API Create WEB API Using Repository Using Visual Studio 2013.

For unit testing of a Web API: Unit Testing of Web API.

Step 1: Right-click on the UnitTestProject project then select Add - > Load Test.

Step 2: Select Load Pattern. By default the user count is 25 users. Change it to 50.

Load Pattern 

Step 3: Click "Next" to select the Test Mix Model.

 Test Mix Model

Step 4: Here we have 4 types of the Test Mix Model. By default, based on the total number of tests is selected. Click "Next". Add Test in the Test mix.

Add Test in Test mix 

Add Network types.


Step 5: Click "Next". Enter the values for the load test duration.


Step 6: Click "Finish" to complete.

Step 7: Add one more Load Test with user count 100.

Step 8: Open LoadTest1.loadtest from the Solution Explorer and run the Load Test.


Step 9: After runningd the test we get the resultsas in the following for 50 users.


For 50 users, the average test time is 0.000023 (seconds).

Similarly, after running Load Test 2 then we get the result as in the following for 100 users.


For 100 users the average test time is 0.0000075 (seconds).

Thus, we find the conclusion that the most common performance issues that tend to come up with are not problems with API themselves, but with some back-end database or may have some other process running on it at a given time, for example backup, has a network issue or requires tuning. But these issues are due to changes in the environment or only at a given time. A single load test run a few days before final acceptance often fails to identify these issues or the issues occur in the production server at some later date.