-
1. Re: servlet: how to spawn all processors
peterj Aug 20, 2008 12:07 PM (in response to john_woo)Running your web app across 16 CPUs is not a good idea. Due to CPU cache issues, contention among threads, and various other issues it is usually better to run such apps while affinitized to 2, 3 or 4 CPUs (depening on your app). At least that is what we have found in our testing.
In Linux, you can use the taskset utility to set affinity. I suggest adding this to the script that starts jbossas. -
2. Re: servlet: how to spawn all processors
john_woo Aug 20, 2008 6:41 PM (in response to john_woo)"PeterJ" wrote:
Running your web app across 16 CPUs is not a good idea. Due to CPU cache issues, contention among threads, and various other issues it is usually better to run such apps while affinitized to 2, 3 or 4 CPUs (depening on your app). At least that is what we have found in our testing.
In Linux, you can use the taskset utility to set affinity. I suggest adding this to the script that starts jbossas.
Thanks lots for the info, Peter.
I did try the affinity setting (to 4 cpus for the app), but only 1-2 cpu busy. I guessed b/c all threads running in the same process from the main servlet.
As the app is big one, and it's required to put it in 16-32 cpus machine. I'm still thinking how to make use of 4/8 cpus.
--
John -
3. Re: servlet: how to spawn all processors
peterj Aug 20, 2008 6:49 PM (in response to john_woo)The best way to run on more that 4 CPUs is to run multiple instances of the app server, affinitizing each to its own set of CPUs.
See my LinuxWorld presentation at http://www.linuxworld.com/events/2007/slideshows/A2-johnson.pdf. It is somewhat dated, but does cover affinity management. -
4. Re: servlet: how to spawn all processors
kjkoster Aug 21, 2008 3:52 AM (in response to john_woo)"john_woo@canada.com" wrote:
I did try the affinity setting (to 4 cpus for the app), but only 1-2 cpu busy. I guessed b/c all threads running in the same process from the main servlet.
There is a fair chance that your application is not as thread-able as you think it is. Do you do any manual synchronisation, or do you make heavy use of libraries that do internal synchronisation?
Use JConsole to check that you are not exhausting the Tomcat connector thread pools (or other pools)
Also, check that you are running with the server VM http://www.java-monitor.com/forum/showthread.php?t=18. -
5. Re: servlet: how to spawn all processors
john_woo Aug 21, 2008 9:31 AM (in response to john_woo)"kjkoster" wrote:
"john_woo@canada.com" wrote:
I did try the affinity setting (to 4 cpus for the app), but only 1-2 cpu busy. I guessed b/c all threads running in the same process from the main servlet.
There is a fair chance that your application is not as thread-able as you think it is. Do you do any manual synchronisation, or do you make heavy use of libraries that do internal synchronisation?
Use JConsole to check that you are not exhausting the Tomcat connector thread pools (or other pools)
Also, check that you are running with the server VM http://www.java-monitor.com/forum/showthread.php?t=18.
Thanks lots for the info, kjkoster.
However, the -server or GC option didn't help. As metioned, running in multi-cores is very slow. and 1-2 cpus keep busy, which is not happened in 1-2 cores machine. The only thing I can think of is the JVM, RTSJ. or even 32/64 bits issue.
--
John -
6. Re: servlet: how to spawn all processors
kjkoster Aug 21, 2008 11:07 AM (in response to john_woo)Which leaves the question: are you sure that your application is written such that it does not serialize requests internally? If you have synchronisation bottlenecks you can start as many threads as you like, but only a few may actually be runnable.
You can check samples of the state of your threads using jconsole. If you find that most of them are waiting, blocked on a lock of some kinds it makes no difference how many processors you have.
So, what makes you so sure that all threads in your application are free to run? -
7. Re: servlet: how to spawn all processors
peterj Aug 21, 2008 1:13 PM (in response to john_woo)I just now tried this on my Linux desktop at home and I saw all 4 CPUs in use.
What Linux distro are you running?
How are you verifying that only 2CPUs are in use?
With JBossAS running, get the PID for it (you can find it via "ps -ef | grep java") and post the result from running this command (replacing 9999 with the PID for JBossAS):
taskset -p 9999
If taskset indicates that the java process is affinitized to more than 2 CPUs, then kjkoster is correct in asserting that there is something about your app that is prevent proper parallelization.