I'm trying to write a stress test program to bash our web server. I'm trying to use threads to simulate multiple people hitting the server. However, the problem I'm running into is using 1 thread works 99.9% of the time. 2 threads seem to work 10-20% of the time and anything more seems to fail all the time.
我正在尝试编写一个压力测试程序来打击我们的Web服务器。我正在尝试使用线程来模拟多人点击服务器。但是,我遇到的问题是使用1个线程99.9%的时间工作。 2个线程似乎在10-20%的时间内工作,而且任何事情似乎总是失败。
Here's a snippet of my code running, trying to generate threads for testing:
这是我的代码片段运行,尝试生成用于测试的线程:
public static final MAX = 1; // (or 2, or 100 while testing)
<snip>
<snip>
String newParams = "{ bunch, of, test, parameters }";
Callable<String> call1;
ExecutorService pool = Executors.newFixedThreadPool(10);
Future<String> f1;
for (int i = 0; i < MAX; i++) {
// newParams = newParams + slight changes each iteration for each thread;
call1 = new HttpPostClass.HttpPost(url, newParams);
f1 = pool.submit(call1);
}
pool.shutdown();
I don't know if it's because I'm re-using the same Callable/Future objects in the loop or if this is caused by my own ignorance/inexperience of multi-threaded programming that's causing this issue.
我不知道是不是因为我在循环中重复使用相同的Callable / Future对象,或者这是由于我自己的无线/缺乏多线程编程经验导致了这个问题。
Thanks in advance for any help you guys can give me.
提前感谢你们给我的任何帮助。
1 个解决方案
#1
0
If you want to load test a web-server, look at the simple but powerful ab: http://httpd.apache.org/docs/2.2/programs/ab.html
如果您想加载测试Web服务器,请查看简单但功能强大的ab:http://httpd.apache.org/docs/2.2/programs/ab.html
#1
0
If you want to load test a web-server, look at the simple but powerful ab: http://httpd.apache.org/docs/2.2/programs/ab.html
如果您想加载测试Web服务器,请查看简单但功能强大的ab:http://httpd.apache.org/docs/2.2/programs/ab.html