简体   繁体   中英

Python script load testing web page

I want to do a test load for a web page. I want to do it in python with multiple threads. First POST request would login user (set cookies).

Then I need to know how many users doing the same POST request simultaneously can server take. So I'm thinking about spawning threads in which requests would be made in loop.

I have a couple of questions: 1. Is it possible to run 1000 - 1500 requests at the same time CPU wise? I mean wouldn't it slow down the system so it's not reliable anymore? 2. What about the bandwidth limitations? How good the channel should be for this test to be reliable?

Server on which test site is hosted is Amazon EC2 script would be run from another server(Amazon too).

Thanks!

cPython does not take advantage from multiple cores when running multiple threads. It means, that basically, You will only have one core doing the testing job.

There are dedicated tools to do what You want to do. Let me suggest two:

FunkLoad is a functional and load web tester, written in Python, whose main use cases are:

  • Functional testing of web projects, and thus regression testing as well.
  • Performance testing: by loading the web application and monitoring your servers it helps you to pinpoint bottlenecks, giving a detailed report of performance measurement.
  • Load testing tool to expose bugs that do not surface in cursory testing, like volume testing or longevity testing.
  • Stress testing tool to overwhelm the web application resources and test the application recoverability.
  • Writing web agents by scripting any web repetitive task, like checking if a site is alive.

Tsung is an open-source multi-protocol distributed load testing tool

The purpose of Tsung is to simulate users in order to test the scalability and performance of IP based client/server applications. You can use it to do load and stress testing of your servers. Many protocols have been implemented and tested, and it can be easily extended. WebDAV, LDAP and MySQL support have been added recently (experimental).

It can be distributed on several client machines and is able to simulate hundreds of thousands of virtual users concurrently (or even millions if you have enough hardware ...).


If You decide to write Your own tool, You will probably want to use Python's multiprocessing module as it would let You use multiple cores. You should also take a look on Twisted as it would let You easily handle multiple sockets while a limited number of threads. That would be much better than spawning a new thread for each socket.

You work with Amazon EC2, so I would recommend using Tsung. You can rent a dozen of multicore servers for a few hours and run some really heavy load tests with Tsung. It scales very well in this kind of configuration.

As for the bandwidth, it's usually not a problem, but it depends on the application. You will have to monitor all Your resources closely while performing a load test.

too many variables. 1000 at the same time ... no. in the same second... possibly. bandwidth may well be the bottleneck. this is something best solved by experimentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM