无法使用线程对EJB主题进行负载测试 [英] Unable to achieve load testing on EJB subject using threading
问题描述
我发布了这个问题,为什么100000 运行
()调用被更快地压缩到100000 开始
()发现尽管多线程,由于线程管理,100000 开始
实际上需要超过10000 运行
调用。
I posted this question asking why 100000 run
() calls is faster compred to 100000 start
() as i found out that despite multi threading, 100000 start
would actually take longer than 10000 run
calls because of the thread management.
实际上,我试图产生100000个线程来模拟一个我想测试的EJB方法的负载,这似乎是不可能的。有没有办法可以实现这一点?或者是,我需要有多台机器才能实现这种负载。
Actually, i was trying to spawn 100000 threads to simulate a load on an EJB method i wish to test, and it seems not possible this way. Is there a way which i could achieve this? Or is it that i would need to have multiple machines in order to achieve that load.
如果我有一个四核电脑,我应该只是在一次最多4个线程,以防止太重的上下文切换,因为在任何一个时间将会运行4个线程?
Is it true that if i have a quad core pc, i should only spawn at most 4 threads at a time to prevent too heavy context switching because at any one time 4 threads would be run?
推荐答案
如果你有4个内核支持超线程,您只能一次实际加载8个线程。您可以启动比这更多的线程,但是只有8个可以在任何时间激活。这是您正在使用的硬件的限制。
If you have 4 cores which support hyper threading, you can only actually load 8 threads at once. You can start more threads than this, however only 8 can be active at any one time. This is a limitation of the hardware you are using.
我非常怀疑您需要运行10K或100K线程来测试任何系统。大多数系统可以只用一个线程(或非常小的数量)工作饱和,我怀疑你的EJB也不例外。
I very much doubt you need to run 10K or 100K threads to test any system. Most systems can be saturated with work with just one thread (or a very small number) and I suspect your EJB is no exception.
你不能测试一个方法是线程安全通过蛮力测试。您只能通过阅读代码来确定这一点。
You cannot test a method is thread safe via brute force testing. You can only determine this by reading the code.
您可能会发现这篇文章很有趣 Java:您可以创建的线程数是多少?
You might find this article interesting Java: What is the limit to the number of threads you can create?
这篇关于无法使用线程对EJB主题进行负载测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!