如何对需要javascript的Web App进行压力测试

时间:2023-01-20 19:38:22

A similar question was already asked ( Performing a Stress Test on Web Application?), but I'd like to test a web application that prevents double-submits and takes some counter-XSRF actions and therefore REQUIRES JavaScripts to be evaluated.

还有一个类似的问题(在Web应用程序上执行压力测试?),但是我想测试一个阻止双重提交并采取一些反XSRF操作的Web应用程序,因此需要评估JavaScripts。

Has anybody done stress tests with web apps that require (and use) JS and any experience to share?

有没有人用需要(和使用)JS和任何经验分享的网络应用程序进行压力测试?

jMeter wouldn't work I guess...

jMeter无法工作我猜...

Thanks!

10 个解决方案

#1


3  

Watir?

Watir is a simple open-source library for automating web browsers. Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page.

Watir是一个用于自动化Web浏览器的简单开源库。 Watir以与人们相同的方式驱动浏览器。它点击链接,填写表格,按下按钮。 Watir还会检查结果,例如页面上是否显示预期文本。

It drives Internet Explorer, but is also functional with Firefox (and Safari to some extent).

它驱动Internet Explorer,但也可以在Firefox(以及某种程度上的Safari)中运行。

#2


3  

The problem with Watir and Selenium RC or any other full browser solution is that they need a full browser :P

Watir和Selenium RC或任何其他完整浏览器解决方案的问题在于它们需要一个完整的浏览器:P

Browsers are very expensive to run, often requiring 300MB or more of RAM. Multiply those requirements by even 100 and you need massive hardware. Fortunately, there is a solution: I recently started a company that does exactly what you're looking for.

浏览器运行起来非常昂贵,通常需要300MB或更多的RAM。将这些要求乘以100即可,您需要大量硬件。幸运的是,有一个解决方案:我最近创办了一家公司,完全满足您的需求。

Check out http://browsermob.com and you can run a limited test (up to 25 users) to get a feel for the app. Feel free to contact us if you have any questions at all!

查看http://browsermob.com,您可以运行有限的测试(最多25个用户)来感受应用程序。如果您有任何问题,请随时与我们联系!

#3


3  

One solution that may be worth pursuing is to run Selenium on Amazon EC2 to provide the scalability you need. There is a tutorial over at Selenium using a sample that ships with Selenium grid. Windows machines are 12.5 cents an hour for a small machine meaning that a 500 machine test is going to cost $62.50 an hour.

可能值得追求的一个解决方案是在Amazon EC2上运行Selenium以提供您所需的可扩展性。在Selenium上有一个教程,使用了Selenium网格附带的样本。对于小型机器,Windows机器每小时12.5美分,这意味着500机器测试每小时的成本为62.50美元。

PROS:

  • Selenium runs in a real browser meaning that your Javascript is executing as it would on a client
  • Selenium在真实的浏览器中运行,这意味着您的Javascript正在客户端执行

  • Low cost - trying to do this on your own hardware would cost significantly more
  • 低成本 - 尝试在您自己的硬件上执行此操作会花费更多

CONS:

  • You would have to establish network connectivity from Amazon to your application
  • 您必须建立从Amazon到您的应用程序的网络连接

#4


2  

The testers I work with use Bad Boy for load testing. I'm fairly certain you can test interactions that use javascript, so you should be able to test stuff like double-submits.

我工作的测试人员使用Bad Boy进行负载测试。我相当肯定你可以测试使用javascript的交互,所以你应该能够测试双提交之类的东西。

#5


2  

As far as your backend is concerned, it doesn't matter what triggers a request whether it's from JavaScript or a load testing tool as long as the request is valid.

就你的后端而言,只要请求有效,触发请求是什么,无论是来自JavaScript还是负载测试工具都无关紧要。

You can create a bunch of fake requests that do lots of different things (hopefully representative of actual usage patterns) and slam your webserver with a load testing tool.

您可以创建一堆虚假请求,这些请求可以执行许多不同的操作(希望能够代表实际的使用模式),并使用负载测试工具来抨击您的Web服务器。

There's a bunch out there:

那里有一堆:

  • jMeter
  • http_load
  • Grinder
  • httpperf

#6


1  

Because JMeter is not a browser, it won't interpret the JavaScript code on the page you GETting:

因为JMeter不是浏览器,所以它不会解释您GETting页面上的JavaScript代码:

JMeter does not process Javascript or applets embedded in HTML pages. [JMeter Wiki]

JMeter不处理嵌入在HTML页面中的Javascript或applet。 [JMeter Wiki]

So, what can you do? You can add WebDriver to JMeter test and by this, evaluate the web pages.

所以,你可以做什么?您可以将WebDriver添加到JMeter测试,然后评估网页。

Web Driver Sampler automates the execution and collection of Performance metrics on the Browser (client-side). A large part of performance testing, up to this point, has been on the server side of things. However, with the advancement of technology, HTML5, JS and CSS improvements, more and more logic and behaviour have been pushed down to the client. This adds to the overall perceived performance of website/webapp, but this metric is not available in JMeter. Things that add to the overall browser execution time may include:

Web Driver Sampler在浏览器(客户端)上自动执行和收集性能指标。到目前为止,性能测试的很大一部分已经出现在服务器端。然而,随着技术的进步,HTML5,JS和CSS的改进,越来越多的逻辑和行为被推送到客户端。这增加了网站/ webapp的整体感知性能,但此指标在JMeter中不可用。添加到整个浏览器执行时间的事情可能包括:

  1. Client-side Javascript execution - eg. AJAX, JS templates
  2. 客户端Javascript执行 - 例如。 AJAX,JS模板

  3. CSS transforms - eg. 3D matrix transforms, animations
  4. CSS转换 - 例如。 3D矩阵变换,动画

  5. 3rd party plugins - eg. Facebook like, Double click ads, site analytics, etc
  6. 第三方插件 - 例如。 Facebook喜欢,双击广告,网站分析等

All these things add to the overall browser execution time, and this project aims to measure the time it takes to complete rendering all this content.

所有这些都会增加整个浏览器的执行时间,而这个项目旨在衡量完成渲染所有这些内容所需的时间。

Official guide: https://jmeter-plugins.org/wiki/WebDriverTutorial/

官方指南:https://jmeter-plugins.org/wiki/WebDriverTutorial/

#7


0  

I've tried Badboy which is OK. The big, fat, heavy tool is SilkTest. It requires a lot of programming to get up and running, but you can get something very solid done!

我试过Badboy,这没关系。 SilkTest是一款又重又重的大型工具。它需要大量的编程来启动和运行,但你可以得到一些非常可靠的东西!

If you only need to stress test request from e.g. IIS log files, I have a custom build tool. I will publish it at CodePlex very soon.

如果你只需要从例如压力测试请求IIS日志文件,我有一个自定义构建工具。我很快就会在CodePlex上发布它。

#8


0  

Selenium RC is another alternative.

Selenium RC是另一种选择。

#9


0  

Also related, check out my recent article on Ajaxian. I think it does a good job of explaining why real browsers do matter and why executing JavaScript is becoming more important for load testing.

还有相关内容,请查看我最近关于Ajaxian的文章。我认为它很好地解释了为什么真正的浏览器很重要以及为什么执行JavaScript对于负载测试变得越来越重要。

http://ajaxian.com/archives/why-load-testing-ajax-is-hard

#10


0  

There's a new tool in this area called k6

这个领域有一个名为k6的新工具

it has a way to access the DOM, and I'm planning to try it in a project.

它有一种访问DOM的方法,我打算在项目中尝试它。

background story:

You can visit this and this blog.

你可以访问这个和这个博客。

maybe it will help.

也许它会有所帮助。

#1


3  

Watir?

Watir is a simple open-source library for automating web browsers. Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page.

Watir是一个用于自动化Web浏览器的简单开源库。 Watir以与人们相同的方式驱动浏览器。它点击链接,填写表格,按下按钮。 Watir还会检查结果,例如页面上是否显示预期文本。

It drives Internet Explorer, but is also functional with Firefox (and Safari to some extent).

它驱动Internet Explorer,但也可以在Firefox(以及某种程度上的Safari)中运行。

#2


3  

The problem with Watir and Selenium RC or any other full browser solution is that they need a full browser :P

Watir和Selenium RC或任何其他完整浏览器解决方案的问题在于它们需要一个完整的浏览器:P

Browsers are very expensive to run, often requiring 300MB or more of RAM. Multiply those requirements by even 100 and you need massive hardware. Fortunately, there is a solution: I recently started a company that does exactly what you're looking for.

浏览器运行起来非常昂贵,通常需要300MB或更多的RAM。将这些要求乘以100即可,您需要大量硬件。幸运的是,有一个解决方案:我最近创办了一家公司,完全满足您的需求。

Check out http://browsermob.com and you can run a limited test (up to 25 users) to get a feel for the app. Feel free to contact us if you have any questions at all!

查看http://browsermob.com,您可以运行有限的测试(最多25个用户)来感受应用程序。如果您有任何问题,请随时与我们联系!

#3


3  

One solution that may be worth pursuing is to run Selenium on Amazon EC2 to provide the scalability you need. There is a tutorial over at Selenium using a sample that ships with Selenium grid. Windows machines are 12.5 cents an hour for a small machine meaning that a 500 machine test is going to cost $62.50 an hour.

可能值得追求的一个解决方案是在Amazon EC2上运行Selenium以提供您所需的可扩展性。在Selenium上有一个教程,使用了Selenium网格附带的样本。对于小型机器,Windows机器每小时12.5美分,这意味着500机器测试每小时的成本为62.50美元。

PROS:

  • Selenium runs in a real browser meaning that your Javascript is executing as it would on a client
  • Selenium在真实的浏览器中运行,这意味着您的Javascript正在客户端执行

  • Low cost - trying to do this on your own hardware would cost significantly more
  • 低成本 - 尝试在您自己的硬件上执行此操作会花费更多

CONS:

  • You would have to establish network connectivity from Amazon to your application
  • 您必须建立从Amazon到您的应用程序的网络连接

#4


2  

The testers I work with use Bad Boy for load testing. I'm fairly certain you can test interactions that use javascript, so you should be able to test stuff like double-submits.

我工作的测试人员使用Bad Boy进行负载测试。我相当肯定你可以测试使用javascript的交互,所以你应该能够测试双提交之类的东西。

#5


2  

As far as your backend is concerned, it doesn't matter what triggers a request whether it's from JavaScript or a load testing tool as long as the request is valid.

就你的后端而言,只要请求有效,触发请求是什么,无论是来自JavaScript还是负载测试工具都无关紧要。

You can create a bunch of fake requests that do lots of different things (hopefully representative of actual usage patterns) and slam your webserver with a load testing tool.

您可以创建一堆虚假请求,这些请求可以执行许多不同的操作(希望能够代表实际的使用模式),并使用负载测试工具来抨击您的Web服务器。

There's a bunch out there:

那里有一堆:

  • jMeter
  • http_load
  • Grinder
  • httpperf

#6


1  

Because JMeter is not a browser, it won't interpret the JavaScript code on the page you GETting:

因为JMeter不是浏览器,所以它不会解释您GETting页面上的JavaScript代码:

JMeter does not process Javascript or applets embedded in HTML pages. [JMeter Wiki]

JMeter不处理嵌入在HTML页面中的Javascript或applet。 [JMeter Wiki]

So, what can you do? You can add WebDriver to JMeter test and by this, evaluate the web pages.

所以,你可以做什么?您可以将WebDriver添加到JMeter测试,然后评估网页。

Web Driver Sampler automates the execution and collection of Performance metrics on the Browser (client-side). A large part of performance testing, up to this point, has been on the server side of things. However, with the advancement of technology, HTML5, JS and CSS improvements, more and more logic and behaviour have been pushed down to the client. This adds to the overall perceived performance of website/webapp, but this metric is not available in JMeter. Things that add to the overall browser execution time may include:

Web Driver Sampler在浏览器(客户端)上自动执行和收集性能指标。到目前为止,性能测试的很大一部分已经出现在服务器端。然而,随着技术的进步,HTML5,JS和CSS的改进,越来越多的逻辑和行为被推送到客户端。这增加了网站/ webapp的整体感知性能,但此指标在JMeter中不可用。添加到整个浏览器执行时间的事情可能包括:

  1. Client-side Javascript execution - eg. AJAX, JS templates
  2. 客户端Javascript执行 - 例如。 AJAX,JS模板

  3. CSS transforms - eg. 3D matrix transforms, animations
  4. CSS转换 - 例如。 3D矩阵变换,动画

  5. 3rd party plugins - eg. Facebook like, Double click ads, site analytics, etc
  6. 第三方插件 - 例如。 Facebook喜欢,双击广告,网站分析等

All these things add to the overall browser execution time, and this project aims to measure the time it takes to complete rendering all this content.

所有这些都会增加整个浏览器的执行时间,而这个项目旨在衡量完成渲染所有这些内容所需的时间。

Official guide: https://jmeter-plugins.org/wiki/WebDriverTutorial/

官方指南:https://jmeter-plugins.org/wiki/WebDriverTutorial/

#7


0  

I've tried Badboy which is OK. The big, fat, heavy tool is SilkTest. It requires a lot of programming to get up and running, but you can get something very solid done!

我试过Badboy,这没关系。 SilkTest是一款又重又重的大型工具。它需要大量的编程来启动和运行,但你可以得到一些非常可靠的东西!

If you only need to stress test request from e.g. IIS log files, I have a custom build tool. I will publish it at CodePlex very soon.

如果你只需要从例如压力测试请求IIS日志文件,我有一个自定义构建工具。我很快就会在CodePlex上发布它。

#8


0  

Selenium RC is another alternative.

Selenium RC是另一种选择。

#9


0  

Also related, check out my recent article on Ajaxian. I think it does a good job of explaining why real browsers do matter and why executing JavaScript is becoming more important for load testing.

还有相关内容,请查看我最近关于Ajaxian的文章。我认为它很好地解释了为什么真正的浏览器很重要以及为什么执行JavaScript对于负载测试变得越来越重要。

http://ajaxian.com/archives/why-load-testing-ajax-is-hard

#10


0  

There's a new tool in this area called k6

这个领域有一个名为k6的新工具

it has a way to access the DOM, and I'm planning to try it in a project.

它有一种访问DOM的方法,我打算在项目中尝试它。

background story:

You can visit this and this blog.

你可以访问这个和这个博客。

maybe it will help.

也许它会有所帮助。