在测试中包含静态资源,如图像、css、js 等 [英] include static resources like images, css, js etc in tests

查看:19
本文介绍了在测试中包含静态资源,如图像、css、js 等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用 JMeter 为我的 Web 应用程序创建负载测试.我真的很喜欢这个工具,在看了一些视频后,开始创建测试真的很容易.

I´ve recently started using JMeter to create load tests for my web applications. I really like the tool, and after watching some videos it was really easy to get started with creating tests.

但是有一件事我不清楚.

There´s however one thing that I´m not clear about.

阅读 JMeter 主页,有一个最佳实践"部分.其中包括:

Reading on the JMeter homepage, there´s a "Best practice" section. Among other things, it says:

最重要的事情是过滤掉所有您不感兴趣的请求.例如,记录图像请求是没有意义的(可以指示 JMeter 下载页面上的所有图像 - 请参阅 HTTP 请求).这些只会使您的测试计划变得混乱.

The most important thing to do is filter out all requests you aren't interested in. For instance, there's no point in recording image requests (JMeter can be instructed to download all images on a page - see HTTP Request ). These will just clutter your test plan.

我也在其他页面上看到了这一点,说你不应该在测试中包含对图像或任何其他静态资源的请求.然而,我仍然无法找到一个页面来很好地解释为什么你不应该包含静态资源.

I´ve seen this on other pages aswell, saying that you shouldn´t include requests for images or any other static resources in your tests. However I´ve still not been able to find a single page which gives a good explanation as to WHY you shoudn´t include static resources.

当然,JMeter 不是浏览器,但是对静态资源的请求无疑会影响应用程序的性能?有人可以给我一个很好的解释:-)

Sure, JMeter isn´t a browser, but requests for static resources would no doubt affect performance of your application? Can someone please give me a good explanation :-)

推荐答案

这完全取决于您要测试的内容.

It all depends on what you are trying to test.

一般来说,我使用 JMeter 进行两种类型的性能测试:特定测试,我查看我担心的事情,以及安全网"测试,我测量整个应用程序以确保它确实像我期望的那样工作.

In general, there are two types of performance test I do with JMeter: specific tests, where I look at things that I'm worried about, and "safety net" tests, where I measure the entire application to make sure it does indeed work the way I expect it to.

特定测试几乎总是处理 Web 应用程序的动态方面 - 服务器端代码(.aspx、.php、.jsp 等).这就是大多数应用程序存在瓶颈的地方——运行服务器端脚本的工作量比从磁盘检索 CSS 文件并将其提供给浏览器而无需任何额外处理的工作量高出很多很多倍.如果我正在测试服务器端脚本,我不想同时加载资产 - 因为它们会使测试混乱,并在测试客户端消耗带宽.我不希望我的测试失败,因为我的 JMeter 服务器正在每个线程上下载一个 5MB 的视频文件并消耗所有带宽,而我实际上想要做的是查看服务器每秒可以支持多少登录.

Specific tests nearly always deal with the dynamic aspects of the web application - the server-side code (.aspx, .php, .jsp etc.). This is where most applications have their bottlenecks - the effort to run a server-side script is many, many times higher than the effort to retrieve a CSS file from disk and serve it up to the browser without any additional processing. If I'm testing the server-side scripts, I don't want to also load the assets - because they clutter up the tests, and consume bandwidth at the test client end. I don't want my tests to fail because my JMeter server is downloading a 5MB video file on each thread and consuming all the bandwidth, when what I'm actually trying to do is see how many logins per second the server can support.

测试您的网络服务器提供静态文件的能力几乎没有意义——微软、Apache 团队,无论是谁,在这方面都做得非常出色;除非您有非常具体的顾虑,否则有更好的方法来花费您的测试预算.

There's very little point in testing your webserver's ability to serve static files - Microsoft, the Apache team, whoever, have already done a brilliant job at that; unless you have a very specific concern, there are better ways to spend your testing budget.

安全网测试将整个事情放在一起,以证明它确实按照我的预期工作.通常,我在生产(类似)环境中运行这些,所以我有一个 CDN、生产级硬件和实时"应用程序配置.我通常为此使用基于云的测试服务,因此我可以从不同位置查看性能,并生成足够的负载来对生产级套件施加压力.您可以为此使用 JMeter(我过去使用过一些 JMeter Cloud 服务).它很昂贵,可能需要停机,您只能将其用作安全网.

Safety net tests put the whole thing together to prove that it all really does work the way I expect it. Usually, I run these on a production(like) environment, so I have a CDN, production-grade hardware, and the "live" application config. I usually employ a cloud-based testing service for this, so I can see performance from different locations, and generate enough load to stress production-grade kit. You could use JMeter for this (and there are a couple of JMeter Cloud services I've used in the past). It's expensive, it may require downtime, and you should only do it as a safety net.

这篇关于在测试中包含静态资源,如图像、css、js 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆