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

查看:160
本文介绍了在测试中包括图像,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 Request).这些只会使您的测试计划变得混乱.

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.

测试Web服务器提供静态文件的能力几乎没有意义-微软,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天全站免登陆