简体   繁体   English

Django中的性能,负载和压力测试

[英]Performance, load and stress testing in Django

I am studying the different types of testing for a Django application. 我正在研究Django应用程序的不同类型的测试。 I know how to do functional and unit testing in Django and how to apply different methodologies, but now I am facing a new challenge, I need to know how to do: 我知道如何在Django中进行功能和单元测试以及如何应用不同的方法,但现在我面临新的挑战,我需要知道如何做:

  • Performance testing 性能测试
  • Load testing 负载测试
  • Stress testing 压力测试

I know the difference between them but I dont know which is the best methodology to follow,which are the best packages for do it or simply where I can get some documentation about it. 知道它们之间的区别,但我不知道哪种方法最好,哪种方法最好,或者只是我可以获得一些文档

So my question is, how can I start to do these types of tests in a Django app or where can I get some good documentation about it? 所以我的问题是,我如何开始在Django应用程序中进行这些类型的测试,或者我在哪里可以得到一些关于它的好文档?

Thanks 谢谢

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/ SLA s 负载测试:将系统置于预期负载下,以查看响应时间或吞吐量等性能指标是否符合预期/ SLA
  • Stress testing: is determining system boundaries and/or bottlenecks, ie you start the "normal" load test and increase the load until monitored metrics exceed acceptable thresholds or errors start occurring (whatever comes the 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. 鉴于pythondjango标签,我期望您发现Locust工具很有趣,因为您将能够以某种形式的Python语言编写测试。 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. 您还可以考虑在Grinder中使用Jython (Java绑定Python)语言编写测试,这样您就不必从头学习新工具。 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 close as possible, to wit you need to properly simulate real user using real browser with all related stuff like: 您需要尽可能接近地模仿真实的应用程序使用情况,因此您需要使用真实浏览器正确模拟真实用户以及所有相关内容,例如:

    • cookies 饼干
    • headers
    • cache 高速缓存
    • think times 思考时代
    • AJAX requests AJAX请求
    • 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 increased number of users and see how does you application behave under the load, correlate increasing/decreasing load with changing metrics/resources usage 一旦你完成了测试,并且对它正在做的事情充满信心,你可以用更多的用户运行它,看看你的应用程序在负载下如何表现,将增加/减少的负载与不断变化的指标/资源相关联用法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM