[Fixed]-Performance, load and stress testing in Django

34👍

Load Testing and Stress Testing are basically performance testing sub-types where:

  • Load testing: is putting the system under anticipated load to see whether performance metrics like response time or throughput match expectations/SLAs
  • Stress testing: is determining system boundaries and/or bottlenecks, i.e. you start the "normal" load test and increase the load until monitored metrics exceed acceptable thresholds or errors start occurring (whatever comes first)

Also, be aware of Soak Testing – when you put the system under a prolonged load to see if it is capable of handling sustained concurrent usage. The majority of bottlenecks are being discovered during Soak Testing phase.


With regards to "how do I":

  1. First of all you need a performance testing tool. Given python and django tags my expectation is that you find Locust tool interesting as you will be able to write your tests in some form of Python language. You can also consider Grinder where you can write tests in Jython (Java bindings for Python) language so you won’t have to learn the new tool from scratch. Other free and open source load testing tools are listed and compared in the Open Source Load Testing Tools: Which One Should You Use?

  2. Next step will be creating a load test scenario. You need to mimic real application usage as closely as possible, to wit you need to properly simulate real users using a real browser with all related stuff like:

    • cookies
    • headers
    • cache
    • think times
    • AJAX requests
    • embedded resources handling (images, scripts, styles, fonts)
  3. Once you have the test and have the confidence regarding it is doing what it is supposed to be doing you can run it with an increased number of users and see how does your application behave under the load, correlate increasing/decreasing load with changing metrics/resources usage

Leave a comment