如何使用 JMeter 对网站进行负载测试 [英] How to perform load testing for website using JMeter
问题描述
我想在 JMeter 中创建一个脚本来模拟例如100 位用户在 3-4 分钟内访问我们的网站.
I want to create a script in JMeter that simulates e.g. 100 users accessing our site over a period of 3-4 minutes.
我们需要测试我们的应用程序是否可以允许 25.000 个用户/天 - 即每小时 1.100 个.
We need to test whether our application can allow 25.000 users/day - that is 1.100 per hour.
为此,我做了这个 Jmeter 测试:
For that i have made this Jmeter test:
这是结果
这是图表
我想知道这个结果到底告诉我们什么,如果我的测试通过或失败,yahoo.com(我们已经为我们的例子运行了这个测试)是否可以允许 25.000 个用户/天,如果我输入我的标准/要求正确吗?
I want to know what this result is exactly telling us, if my test pass or fails, if yahoo.com (for which we have run this test for our example) can allow 25.000 users/day and if i am inputting my criteria / requirements correctly?
谢谢
推荐答案
1. 我建议使用更好的一些来自 jmeter-plugins 代替:
1. I would advise to use better some custom samplers from jmeter-plugins instead:
- 终极线程组:线程组的更灵活实现允许设置您的负载-测试场景正是你想要的;
- 随时间变化的响应时间/响应时间 vs 线程/ActiveThreads Over Time 监听器:作为 JMeter 的默认图表更具示范性.
- Ultimate Thread Group: more flexible implementation of Thread Group allows to setup your load-testing scenario exactly how you want;
- Response Times Over Time / Response Times vs Threads / Active Threads Over Time listeners: more demonstrative graphs as JMeter's default ones.
2. 除了上面的@Qwe 评论:测试不是单个 HTTP 请求而是用户的事务:每个测试线程应该模拟一种真实用户的浏览活动:登录(如果有的话))、浏览网站、搜索、访问/编辑个人设置、注销等
要模拟真实用户,还要在事务步骤之间添加思考时间"计时器.
2. In addition to the @Qwe comment above: test not the single HTTP request but user's transactions: each test-thread should simulate a kind of real-user browsing activity: login (if any), navigating through the site, search, accessing/editing personal settings, logout, etc.
To emulate real-user add also "think-time" timer between transaction steps.
3. 控制响应,至少如下:
3. Control responses, at least the following:
- 每个用户请求的
- 响应代码(@响应断言);
- duration - 验证非功能性需求对于关键事务(@Duration Assertion).
- response code of each user's request (@ Response Assertion);
- duration - to verify non-functional requirements for critical transactions (@ Duration Assertion).
4. 查看相应的 JMeter 文档:
4. Look into corresponding JMeter documentation:
5. 您可以在此处找到有关 Jmeter 设置和负载测试使用的一些分步指南:
5. Some step-by-step guidelines about Jmeter setup and usage for load-testing you can find here:
- 使用 Apache 对您的应用程序进行负载测试JMeter
- 使用 JMeter
- 有效负载使用 Apache JMeter 进行测试
- 使用 JMeter 进行负载测试:第 1 部分,第 2 部分,第 3 部分
- 使用 JMeter 进行简单的负载测试
- 使用 Apache JMeter 进行负载测试
使用 JMeter 进行性能测试 - 您的第一个 JMeter 测试
- 关于使用 JMeter 对 Web 应用程序进行压力测试的一些想法:第 1 部分,第 2 部分.
UPD.
请查找、使用并随意扩展这个 Awesome JMeter 合集,在 github 上继续.
UPD.
Please find, use and feel free to extend this Awesome JMeter collection continued on github.
这篇关于如何使用 JMeter 对网站进行负载测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!