如何对Web表单文件上传进行压力测试?

时间:2023-01-20 19:33:44

I need to test a web form that takes a file upload. The filesize in each upload will be about 10 MB. I want to test if the server can handle over 100 simultaneous uploads, and still remain responsive for the rest of the site.

我需要测试一个上传文件的Web表单。每次上传的文件大小约为10 MB。我想测试服务器是否可以处理超过100个同时上传,并且仍然对网站的其余部分保持响应。

Repeated form submissions from our office will be limited by our local DSL line. The server is offsite with higher bandwidth.

我们办公室提交的重复表格将受到我们当地DSL线路的限制。服务器位于异地,带宽较高。

Answers based on experience would be great, but any suggestions are welcome.

基于经验的答案会很棒,但欢迎任何建议。

3 个解决方案

#1


8  

Use the ab (ApacheBench) command-line tool that is bundled with Apache (I have just discovered this great little tool). Unlike cURL or wget, ApacheBench was designed for performing stress tests on web servers (any type of web server!). It generates plenty statistics too. The following command will send a HTTP POST request including the file test.jpg to http://localhost/ 100 times, with up to 4 concurrent requests.

使用与Apache捆绑在一起的ab(ApacheBench)命令行工具(我刚刚发现了这个很棒的小工具)。与cURL或wget不同,ApacheBench设计用于在Web服务器(任何类型的Web服务器!)上执行压力测试。它也会产生大量的统计数据以下命令将HTTP POST请求(包括文件test.jpg)发送到http:// localhost / 100次,最多包含4个并发请求。

ab -n 100 -c 4 -p test.jpg http://localhost/

It produces output like this:

它产生如下输出:

Server Software:        
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      4
Time taken for tests:   0.78125 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      100
Total transferred:      2600 bytes
HTML transferred:       0 bytes
Requests per second:    1280.00 [#/sec] (mean)
Time per request:       3.125 [ms] (mean)
Time per request:       0.781 [ms] (mean, across all concurrent requests)
Transfer rate:          25.60 [Kbytes/sec] received

Connection Times (ms)
          min  mean[+/-sd] median   max
Connect:        0    0   2.6      0      15
Processing:     0    2   5.5      0      15
Waiting:        0    1   4.8      0      15
Total:          0    2   6.0      0      15

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%     15
  95%     15
  98%     15
  99%     15
 100%     15 (longest request)

#2


0  

Automate Selenium RC using your favorite language. Start 100 Threads of Selenium,each typing a path of the file in the input and clicking submit.

使用您喜欢的语言自动化Selenium RC。启动100个Selenium线程,每个线程在输入中键入文件的路径,然后单击提交。

You could generate 100 sequentially named files to make looping over them easyily, or just use the same file over and over again

您可以生成100个按顺序命名的文件,以便轻松地对它们进行循环,或者只是一遍又一遍地使用同一个文件

#3


0  

I would perhaps guide you towards using cURL and submitting just random stuff (like, read 10MB out of /dev/urandom and encode it into base32), through a POST-request and manually fabricate the body to be a file upload (it's not rocket science).

我可能会指导你使用cURL并提交随机的东西(比如,从/ dev / urandom读取10MB并将其编码到base32中),通过POST请求并手动制作正文作为文件上传(它不是火箭科学)。

Fork that script 100 times, perhaps over a few servers. Just make sure that sysadmins don't think you are doing a DDoS, or something :)

将脚本分叉100次,可能是在几台服务器上。只要确保系统管理员不认为你正在做DDoS,或者其他什么:)

Unfortunately, this answer remains a bit vague, but hopefully it helps you by nudging you in the right track.

不幸的是,这个答案仍然有点模糊,但希望它可以帮助你在正确的轨道上轻推你。

Continued as per Liam's comment:
If the server receiving the uploads is not in the same LAN as the clients connecting to it, it would be better to get as remote nodes as possible for stress testing, if only to simulate behavior as authentic as possible. But if you don't have access to computers outside the local LAN, the local LAN is always better than nothing.

根据Liam的评论继续:如果接收上传的服务器与连接到它的客户端不在同一个LAN中,那么最好尽可能地获取压力测试的远程节点,如果只是为了模拟尽可能真实的行为。但是,如果您无法访问本地LAN之外的计算机,则本地LAN总是比没有好。

Stress testing from inside the same hardware would be not a good idea, as you would do double load on the server: Figuring out the random data, packing it, sending it through the TCP/IP stack (although probably not over Ethernet), and only then can the server do its magic. If the sending part is outsourced, you get double (taken with an arbitrary sized grain of salt) performance by the receiving end.

从同一硬件内部进行压力测试不是一个好主意,因为你会在服务器上进行双重加载:找出随机数据,打包它,通过TCP / IP堆栈发送它(虽然可能不是通过以太网),以及只有这样服务器才能发挥其魔力。如果发送部件是外包的,则接收端会获得双倍(采用任意大小的盐粒)性能。

#1


8  

Use the ab (ApacheBench) command-line tool that is bundled with Apache (I have just discovered this great little tool). Unlike cURL or wget, ApacheBench was designed for performing stress tests on web servers (any type of web server!). It generates plenty statistics too. The following command will send a HTTP POST request including the file test.jpg to http://localhost/ 100 times, with up to 4 concurrent requests.

使用与Apache捆绑在一起的ab(ApacheBench)命令行工具(我刚刚发现了这个很棒的小工具)。与cURL或wget不同,ApacheBench设计用于在Web服务器(任何类型的Web服务器!)上执行压力测试。它也会产生大量的统计数据以下命令将HTTP POST请求(包括文件test.jpg)发送到http:// localhost / 100次,最多包含4个并发请求。

ab -n 100 -c 4 -p test.jpg http://localhost/

It produces output like this:

它产生如下输出:

Server Software:        
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      4
Time taken for tests:   0.78125 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      100
Total transferred:      2600 bytes
HTML transferred:       0 bytes
Requests per second:    1280.00 [#/sec] (mean)
Time per request:       3.125 [ms] (mean)
Time per request:       0.781 [ms] (mean, across all concurrent requests)
Transfer rate:          25.60 [Kbytes/sec] received

Connection Times (ms)
          min  mean[+/-sd] median   max
Connect:        0    0   2.6      0      15
Processing:     0    2   5.5      0      15
Waiting:        0    1   4.8      0      15
Total:          0    2   6.0      0      15

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%     15
  95%     15
  98%     15
  99%     15
 100%     15 (longest request)

#2


0  

Automate Selenium RC using your favorite language. Start 100 Threads of Selenium,each typing a path of the file in the input and clicking submit.

使用您喜欢的语言自动化Selenium RC。启动100个Selenium线程,每个线程在输入中键入文件的路径,然后单击提交。

You could generate 100 sequentially named files to make looping over them easyily, or just use the same file over and over again

您可以生成100个按顺序命名的文件,以便轻松地对它们进行循环,或者只是一遍又一遍地使用同一个文件

#3


0  

I would perhaps guide you towards using cURL and submitting just random stuff (like, read 10MB out of /dev/urandom and encode it into base32), through a POST-request and manually fabricate the body to be a file upload (it's not rocket science).

我可能会指导你使用cURL并提交随机的东西(比如,从/ dev / urandom读取10MB并将其编码到base32中),通过POST请求并手动制作正文作为文件上传(它不是火箭科学)。

Fork that script 100 times, perhaps over a few servers. Just make sure that sysadmins don't think you are doing a DDoS, or something :)

将脚本分叉100次,可能是在几台服务器上。只要确保系统管理员不认为你正在做DDoS,或者其他什么:)

Unfortunately, this answer remains a bit vague, but hopefully it helps you by nudging you in the right track.

不幸的是,这个答案仍然有点模糊,但希望它可以帮助你在正确的轨道上轻推你。

Continued as per Liam's comment:
If the server receiving the uploads is not in the same LAN as the clients connecting to it, it would be better to get as remote nodes as possible for stress testing, if only to simulate behavior as authentic as possible. But if you don't have access to computers outside the local LAN, the local LAN is always better than nothing.

根据Liam的评论继续:如果接收上传的服务器与连接到它的客户端不在同一个LAN中,那么最好尽可能地获取压力测试的远程节点,如果只是为了模拟尽可能真实的行为。但是,如果您无法访问本地LAN之外的计算机,则本地LAN总是比没有好。

Stress testing from inside the same hardware would be not a good idea, as you would do double load on the server: Figuring out the random data, packing it, sending it through the TCP/IP stack (although probably not over Ethernet), and only then can the server do its magic. If the sending part is outsourced, you get double (taken with an arbitrary sized grain of salt) performance by the receiving end.

从同一硬件内部进行压力测试不是一个好主意,因为你会在服务器上进行双重加载:找出随机数据,打包它,通过TCP / IP堆栈发送它(虽然可能不是通过以太网),以及只有这样服务器才能发挥其魔力。如果发送部件是外包的,则接收端会获得双倍(采用任意大小的盐粒)性能。