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?
2 Solutions collect form web for “How can I run a Minecraft Server on multiple CPU cores?”
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
Is it possible to set the number of cores the server uses?
- Yes, it is possible, but not through a method you might be considering.
Everything runs through a process on the Task Manager, so you are able to
see how much CPU power (in %) the process is taking, which cores it is applicable to use, and how much RAM (memory) the particular process (program) is using.
I have not touched Bukkit much, so I cannot tell you exactly what you’ll need to do,
but if you were to do this via Vanilla (the original MC server application) methods,
you can find the process it is under (e.g. Minecraft itself uses the process ‘javaw.exe’)
and right-click the specific task and choose “Set Affinity…” This will allow you to choose which cores you would like to run the server. I’m not sure if it works with multiple processors (as what I’m seeing your situation is). I feel that will need to be a “see for yourself” kind of thing.
How do I do it – via start-up options, or other methods?
The method I am describing to you is:
Go to Task Manager (any means: Ctrl+Alt+Del, Start > Run > taskmgr.exe, etc…)
Find the process your server application is running, (there are various ways to do this as well, I’m not familiar with an “easy way” aside from right-clicking the program inside of Task Manager’s ‘Applications’ tab and clicking on “Go To Process”)
Once you have located the process, right-click it and you will see near the bottom of the window, “Set Affinity…”
Change the cores and which processors you would like your server program to use.
Is it really worth it and would it make that much of a difference with a lot of players?
- From my understanding, Minecraft uses the CPU to load the world, and utilizes RAM for anything player-based (mixing CPU and RAM for world interactions), so I would say that your best bet is to have powerful processors and a lot of RAM. RAM will get you farther for more players than CPU will, but a better CPU will support more world interactions from the players, and keep your world from generating “clunky chunks” (half of a mountain abruptly into plains, etc) as you have more people explore the world at once and interact with it.
If anyone finds something wrong about my post, feel free to correct me. I’m only going from my assumptions and experience from running my own server for approx. half of a year.