Minecraft server high CPU usage - data doesn't agree
Hi there - new to Linode, Linux, and server usage in general.
What I'm working with:
Linode 2GB: 1 CPU, 50GB Storage, 2GB RAM
Minecraft One Click App (though also had a CentOS 7 with minecraft setup before)
My summary page on the cloud.linode.com dashboard is showing my CPU usage as always 99%-100% once I get my minecraft server turned on (note I've also tried this on CentOS 7 with a manually setup vanilla minecraft server, and seen the same CPU usage). I even got an email notification about high CPU usage.
Where things don't add up is when I check out CPU usage via CLI. When running top I get 10%-30% CPU when no one is connected and the server is basically idle, and when I connect it's usually 25-75% with spikes towards 100%. This is before even trying to get my few friends to login (I don't expect more than 5 people to connect ever).
Everything I've read, even documentation from Linode, says I should be able to run this server, with this few people, on the size I have, and even the smaller one (Nanode I believe?).
So what should I believe, what I'm being told by the server while I'm in via SSH, or the summary page? I'm worried I'll get a nasty-gram from Linode about my CPU usage being constantly pegged at 100%.
I was also hoping to teach myself LAMP and get a small website setup, and eventually run modded minecraft instead of vanilla, but it looks like this can barely run a vanilla minecraft server? Did I misunderstand what I was reading? Do I need a beefier linode?
Thanks!
9 Replies
If you’re running 1.14.2 there’s been some performance issues that they’re trying to patch for. I run 4GB plan and I get a notification once in a while about high CPU usage.
There’s currently a pre-release for 1.14.3 which may address more performance issues. I’m waiting to see myself if the issue clears up once the new update comes out.
[@LouWestin] (/community/user/LouWestin) Okay, thank you for the info about the performance issues on the current release.
Any ideas about the difference in CPU usage I'm seeing on the linode summary page vs. actually logging into my server?
Hey there,
We encourage you to use the following to review your system performance.
Shows the IO and CPU %steal on the Linode and prints the output every second for 10 seconds to capture fluctuation:
$ iostat 1 10
Checks for processes in a D state that might either be caused by the steal or may cause steal:
$ for x in
seq 1 1 30
; do ps -eo state,pid,cmd | grep "^D"; echo "-"; sleep 2; done
Shows resource usage as well as any processes that might be using up a large amount of CPU:
$ top -bn 1 | head -15
It's also not uncommon for users to have resources that aren't allocated to their disks. You can check what percentage of your plan's available resources are properly allocated here:
https://cloud.linode.com/linodes/LINODEID
/advanced
If you have resources that are not allocated, you may want to resize your disk to take advantage of them.
If you are still confused or have questions, please feel free to open up a Support Ticket so we can look at your Linode in particular. We don't want to send any nasty grams either and we're happy to help 24/7.
Sincerely,
Tara T
Linode Support Team
Following up on what @LouWestin mentioned, the high CPU usage does seem to stem from a bug in the 1.14 release of Minecraft Java Edition. The host sees that one core is maxed out all the time, while the guest does not.
I found that the older 1.13 release does not have this issue. Should you decide to use 1.13, simply follow the instructions in this guide. You'll see the graph displayed in your Linode's dashboard are much closer to what you see in the outputs of top
and ps
commands.
That said, the CPU graph can get close, but they will never be 100% the same as you see within the Linode. This is because they represent usage from the host perspective. Where the VM is not aware of the underlying energy used to run it, is where your graph can vary from what you see internally.
Unfortunately this is apparently a known, unique issue with whatever tools Linode uses to monitor resource usage by virtual machines. I have had a similar experience, where my server is at 5-10% usage and yet the dashboard graph has shown 100% constantly, on 1.13, 1.14 and 1.15. I'm not sure how it could be a Minecraft bug (in 1.14 or otherwise) since I can only find information about this occurring on Linode guests… In any case, if they tell you there's a problem with your resource usage, remind them that this is a known issue and the actual CPU usage isn't nearly 100%.
That's correct @sopwerdna — you can find more details on this in our post here:
Following the logic in this issue tracker comment related to this matter, @bigzaphod posted a partial solution that will pause the Minecraft Java process while no players are connected — you can find full details on how to install this script in their post here:
Otherwise, we do have internal guidance on this issue, so absolutely let us know if you're running Minecraft if we reach out to you about high CPU usage. When you do, it would be helpful to also include outputs from the commands suggested above by @Ttaylor to confirm that this bug is responsible for the misreported CPU usage.
I've just found a more recent Minecraft bug report where some commenters have discovered a simple but effective workaround that helps when running Minecraft versions 1.14 - 1.16 in Linode.
TLDR: Append the following kernel parameters via your bootloader, then reboot:
highres=off nohz=off
For example, in Debian, edit /etc/default/grub
to include the above in the GRUB_CMDLINE_LINUX=
setting line, run update-grub
(unless you're using Linode's "grub2" kernel) and reboot.
Basically, as noted by @bthompson above, the problem seems to have been introduced in Minecraft 1.14. They apparently changed how the server idles, in a way that reacts poorly in Linux, especially when running as a guest VM. The issue causes the high-resolution tick-less timers used by modern kernels to spawn endless interrupts, as fast as the system can generate them, which in turn causes tens of thousands of context switches per second.
This excessive amount of time spent during context switches is sensed (arguably correctly!) by Linode's charts as CPU usage by your node. The kernel isn't doing any meaningful work, but it's definitely spending lots of time responding to the timers.
Note that top
and other CPU monitors within your node don't treat these interrupts and the associated context switches as CPU usage. However, you can monitor the interrupts and context switches via vmstat 1 10
(ignoring the first line of output).
The kernel parameters above disable the high-resolution timers, and reverts to the older jiffies-based system. You can confirm the clock sources by running this before and after the workaround:
cat /sys/devices/system/clocksource/clocksource0/available_clocksource
This should now include (among others) refined-jiffies
and jiffies
in the output. Also, vmstat
should show a substantial reduction in the number of context switches.
Applying this workaround has dramatically lowered my CPU usage while Minecraft is idle, from about 15% to about 1%. Even better, the Linode CPU graph now agrees with the guest CPU metrics, rather than showing a near-constant 99.8% usage.
I hope this helps.
Hi there,
just want to share with you my results after following @null 's suggestions.
Before adding highres=off nohz=off
to GRUB_CMDLINE_LINUX=
top
and Linode's analytics where basically in agreement, i.e. constant ~100%.
After changing the settings for GRUB_CMDLINE_LINUX=
and rebooting, I am seeing dramatic reduction in CPU% according to top
but Linode's analytics is still showing ~100%.
When I cat /sys/devices/system/clocksource/clocksource0/available_clocksource
I am NOT seeing refined-jiffies
and jiffies
, so perhaps I am still missing something.