There is currently no way of setting the CPU affinity
for a service. Which is to say, that the service should
run only on a set of CPUs and not all of them. You
can't change it from the task manager for services as
it says access denied. So when the service is started
(or registered), it should registered to run only on a
set of CPUs. Please check NT Wrapper / FireDaemon which
provide this facility.
I really needs this. I need to limit my Java program to run on a certain number of cores.
If the wrapper runs as a command line tool this is easy I just use the "cmd.exe /C start /affinity 1,2 myprogram.exe" but that is not possible with running as a service.
I suggest having a new property.
wrapper.affinity=1,3
If that is present you will start java using "cmd.exe /C start /affinity 1,3 java.exe".
I would definitely like to see this as an added feature. Multi-core processors are the norm now, and when an application does not really use multi-core functionality, it actually slows the process by switching cores based on priority and processor load. In the case of an application like Tomcat, running it on a single core will most likely improve performance.
Example:
wrapper.affinity=<integer-bitmap></integer-bitmap>
My employer has an application that is based on a 3rd party application running in Tomcat. The 3rd party vendor wants use to use a single-cup license to get better performance, but the only way at this time to set the affinity is the start command, and that is not acceptable for a windows service.
So, I believe there is a growing need for this feature. BTW: Yet Another Java Service Wrapper has added this feature already.