How can I run a Minecraft Server on multiple CPU cores?
I am working on setting up a Minecraft server on a machine I have at home. This particular machine has two quad-core CPUs running at 2.0Ghz so I would like to take advantage of the number of cores and run a server with 4 or 6 of the cores. My server of choice is CraftBukkit, the latest version of which is craftbukkit-1.4.7-R1.0 and launched with a start-up script of:
"C:\Program Files\Java\jre7\bin\java.exe" -Xms1G -Xmx8G -jar craftbukkit-1.4.7-R1.0.jar"
The Minecraft Wiki says:
Minecraft servers, as of 1.1.0, can use multiple cores, so now they will not sit idle.
but does not really expand on this.
My questions, then:
- Is it possible to set the number of cores the server uses?
- How do I do it - via start-up options, or other methods?
- Is it really worth it and would it make that much of a difference with a lot of players?
Solution 1:
If you use the JDK instead of the JRE then you can use the following command line to force the JDK to use all available cores for optimising Java itself (source):
-server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=7 -XX:+AggressiveOpts -Xms1G -Xmx8G -jar craftbukkit-1.4.7-R1.0.jar
As you are clearly using Windows, have you considered YAMS? (Full disclosure: I made it). YAMS will do all this for you.
Solution 2:
Thanks for trying man, but a process in java needs specific triggers for a thread to split - it has to be coded that way.
You can get some practical examples here : https://beginnersbook.com/2013/03/multithreading-in-java/
While Minecraft has a decently robust developed multicore support on the client side, it lacks it on the serverside. Anything above 3 cores won't be used, unless new itterations introduces a command blockchain with automatical threadsplitting - making the dedicated server code more scalable than it's been since release.