Minecraft Server not using all CPUs

Discussion in 'Systems Administration' started by adambl, Aug 31, 2015.

Thread Status:
Not open for further replies.
  1. Hello, before I start elaborating my problem I want you to know that I am german and my english is not the best But I hope you all understand my problem.

    So I have this VPS:
    12 core Xeaon E5-2620
    14 GB RAM

    I am starting my Minecraft server (Spigot 1.8.8) with a .sh file, which looks like this:
    screen -dmS server1 java -server -Xmx6144m -XX:MaxPermSize=256m -d64 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:parallelGCThreads=4 -XX:+AggressiveOpts -jar server.jar nogui

    So I basically start it over a new screen in the background.

    When there are 10 players only, it begins to lag.
    I wondered why, because my system can handle obviously more than 10 players but when I execute the top command in my linux server it shows me that the java process uses 40 - 80% of my cpu! When there are 20+ players on the server it starts to consume at least 90 % CPU - 180%!!

    But there is also this top line over the list with the processes which says this:
    %Cpu(s): 3.1 us, 1.3 sy, 0.0 ni, 95.4 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st

    So 3.1% of the CPUs are used by a user (me, because there is no other user) and 95.4% are in idle which means that they aren't used! SO I am assuming that the java process of the minecraft server is only using 1 cpu core.

    So here is my question: Can someone please help me to change my startup script (mentioned above) so that the java process is using, lets say 8 - 10 cores? Or is the problem somewhere else? Maybe I should mention that the RAM is only used by 10 % max. So I have given the mc server 6gb and with 20 players it only uses 500mb, this is not the problem i assume.

    I have heard about the taskset command, but if i do taskset -p PID it shows me fff which means in binary 111111111111. That means that the mc server is already using all 12 cores?! But if this is true, why are there then 95% of cpu in idle mode???

    Any help is really appreciated.
    And please try to explain it comprehensible, I am very new to this whole linux thing and want to understand and learn what you suggest!
    • Like Like x 1
    • Funny Funny x 1
  2. The Minecraft server is single threaded, which means it will only utilize one core. Stuff like IO, networking, and other things have been seen to be running in their own thread, but those are very small parts of the server, so it will not make much difference.
  3. So you are telling me that iit is NOT possible to make mc run on multiple cores?! But how do other servers handle it to have 100+ players on their server??? Soo confused...
    • Funny Funny x 1
  4. Yes. The main part of the server will run on a single thread. Small portions of the program is being executed on other threads. Cores don't really matter in the world of Minecraft servers, clock frequency does however.
  5. They manage those amounts with a single core (or completely custom server).
  6. "completely custom server" ? Where can I get some of this? Isn't there a addon/modification for spigot which lets it run on multiple cores?
    • Funny Funny x 1
  7. It's not as simple as that. The entire Minecraft server software is built up around single threaded usage. It's not built for multithreading, so there is not "just a addon" you can download, unfortunately.
    • Like Like x 1
  8. I understand the problem now. Is my only solution to let me serverprovider change my hardware to one big singlecore?? I can't imagine that servers with 100+ players have one big cpu with 24GHz?? There has to be another solution...
    • Funny Funny x 3
  9. Not possible. No cpu in existance has a single core above 5ghz or something like that currently. Most "big" servers optimize their servers to run every efficiently on the single core, also most big servers have multiple Minecraft servers connected by bungeecord to support more players and use more cores.
  10. Youre server is badly configured if you can't manage 100 players. I've helped a server reach 300+ players on a single core.

    On a side-note, Hypixel has had a lot of communication with Mojang developers and have a pretty much completely custom server written from the ground up, powering some of their 1K+ players server. Do not think you'll be getting your hands on this anytime soon.

    If you are desperate for CPU power, I recommend the 1271v3 or an overclocked 4790K if you are extremely pressed.
  11. And how do I optimize my server to run 'efficiently' on one core? Can't I outsource my plugins on multiple cores? This has to be possible, to let the plugins use other cpus then the one, spigot is using.
    • Funny Funny x 1
  12. aha a normal intel i7 4790k? Thats what my pc uses.... I thought the Xeon E5 ones were the best server processors
    • Funny Funny x 1
  13. And I do not think that my server is badly configured, just thirsty plugins; I tested it with timings merged
    • Funny Funny x 1
  14. You have a vps and should get rid of it and go get a dedicated server, while running on a vps you may run into to noisy neighbours, and may experience lag because someone else on the host is doing some heavy I/O task and you're freaking cause you don’t know what’s going on and this list goes on with vps,

    But back to your your question, Linux calculates CPU differently you have 12 cores so you can get up to 1200% CPU or a load average of 12 anything higher means the server is really working. Install htop and that would show you all your cores in fancy little colours, or just run the top command and press 1 after and it would show all the servers core so you get a better idea on what’s going on, now minecraft is a single threaded applications and there really nothing more you can do about that but thanks to bungee that opens the doors to that limitation, you should be scaling out and not up, meaning when building a network you should not be getting the biggest server and put all your servers in one box but instead spread them across multi able boxes.

    Plugins are part of the configuration, find the plugins that are taking the most resources and see if there can be configured to run better or try to find a alternative to it.
Thread Status:
Not open for further replies.