Python脚本负载测试网页
我想对网页进行测试加载。我想在 python 中使用多线程来完成它。 第一个 POST 请求将登录用户(设置 cookie)。
然后我需要知道服务器可以容纳多少个用户同时执行相同的 POST 请求。 所以我正在考虑生成在循环中发出请求的线程。
我有几个问题: 1. CPU 是否可以同时运行 1000 - 1500 个请求?我的意思是它不会减慢系统速度从而不再可靠吗? 2. 带宽限制如何?为了使该测试可靠,渠道应该有多好?
托管测试站点的服务器是 Amazon EC2 脚本将从另一台服务器(亚马逊也是)运行。
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cPython 在运行多个线程时不会利用多核。这意味着,基本上,您将只有一个核心来执行测试工作。
有专门的工具可以做您想做的事。让我建议两个:
FunkLoad 是一个功能和负载 Web 测试器,用 Python 编写,其主要用例是:
它可以帮助您查明您的服务器的瓶颈,并提供详细的信息
绩效评估报告。
例如容量测试或寿命测试。
应用程序的可恢复性。
一个网站还活着。
Tsung 是一个开源多协议分布式负载测试工具
如果您决定编写自己的工具,您可能需要使用 Python 的 多处理模块 因为它可以让您使用多个核心。您还应该看看Twisted,因为它可以让您轻松处理多个套接字,同时处理有限数量的线程。这比为每个套接字生成一个新线程要好得多。
您使用 Amazon EC2,因此我建议使用 Tsung。您可以租用十几台多核服务器几个小时,并使用 Tsung 运行一些非常重的负载测试。在这种配置中它可以很好地扩展。
至于带宽,通常不是问题,但这取决于应用程序。在执行负载测试时,您必须密切监视您的所有资源。
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:
your servers it helps you to pinpoint bottlenecks, giving a detailed
report of performance measurement.
like volume testing or longevity testing.
the application recoverability.
a site is alive.
Tsung is an open-source multi-protocol distributed load testing tool
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.
变量太多。 同时 1000...不。在同一秒……可能。带宽很可能是瓶颈。这个问题最好通过实验来解决。
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.