Unable to achieve load testing on EJB subject using threading

陌路散爱 提交于 2019-12-25 04:17:24

问题


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.

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.

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?


回答1:


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.

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.

You might find this article interesting Java: What is the limit to the number of threads you can create?




回答2:


100000 is definitely too much. If your thread is CPU intensive then only 1 thread per CPU/core should be enough. On the other hand, if your thread is not CPU intensive, you can have more than 1 thread per CPU/core. You should conduct more test to find out the optimum number of thread.



来源:https://stackoverflow.com/questions/6805961/unable-to-achieve-load-testing-on-ejb-subject-using-threading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!