Diagnosing: Can't keep up! Is the server overloaded?
When running a Minecraft server, there are essentially 3 main components that affect server performance. CPU, memory and disk speed.
If the Minecraft server can't perform all the calculations it needs to in time, you'll receive the following message in your server logs, and more than likely players will start to experience lag.
Can't keep up! Is the server overloaded? Running 2977ms or 59 ticks behind
The higher the number of ms and ticks, the more the server is struggling to keep up. This will be affected by the number of players connected to a server as well as what actions they are performing in game.
So let's examine each element controlling a servers performance in depth, starting from in our experience, the most likely to affect server performance.
No 1. reason: CPU
Hands down in our experience this is the most likely reason you'll see this message. A Minecraft server has to make a lot of calculations on the server side, and the CPU is responsible for making all of them. There are 2 approaches here, one is try to increase CPU power, the second is to try and use a more efficient fork of Minecraft, therefore requiring less CPU.
Hosting Providers
If you're using a hosting provider, the best thing you can do is see if you can temporarily bump up your servers CPU from an admin panel. This will allow you to isolate whether CPU was the issue. Once you restart your server, you'll be able to see very quickly whether a lack of CPU performance was the culprit.
Bare in mind hosting providers can share CPU's across multiple customer machines, so we'd highly recommend using a dedicated CPU if that's an option. This will give you much more consistent CPU performance. See this article about having a so called "Noisy Neighbor"!
Running your own Server
If you are running your own server from a physical machine, the same principles apply as when running any intensive software such as shutting down competing processes that are using CPU. Tools to find which processes are using CPU are easy to find with some Googling specific to what operating system you are using. But generally shutting down programs you aren't using should be enough here.
Knowing whether the CPU you have is powerful enough to run a Minecraft server is much more difficult to judge, you'll need to use CPU benchmarking tools as well as speaking with others in the community to confirm this.
Using a Minecraft fork
One final consideration is using a more performant Minecraft fork (we'd highly recommend using PaperMC). This means whatever CPU you are using, the server will have less to do versus the Vanilla Minecraft server software. At Minehost, we use PaperMC as our default server type for this reason.
No 2. reason: Memory
Increasing memory available to the Minecraft server will allow the underlying Java process to run more efficiently by keeping more data in memory.
Similar to CPU, figuring out if this is the bottleneck should be as simple as increasing just the memory allocated to the server, and noticing if this message starts appearing less frequently.
If you are starting your server manually from a download JAR file, you'll need to make sure you allocate more memory to the Java process using the -Xms and -Xmx flags.
Again using a Minecraft fork could be beneficial here as it will use less memory.
No 3. reason: Disk Speed
This is the most unlikely reason you'll receive this message. If you are running your server from anything like a modern machine, it will most likely have an SSD disk, this should be more than enough to not cause a bottleneck in server performance.
If you do believe this could be the problem, you'll need to run disk benchmarking tools, and potentially change the underlying hard drive itself.
Try using Minehost as an automatic hosting platform
At Minehost.io, we are always tweaking our platform to ensure all servers you create automatically have adequate resources to run without any lag. Give us a try if you want to take the stress out of Minecraft hosting!
About Minehost.io
Minehost.io is a free Minecraft server host. Create a server instantly using any world options you can imagine and play with your friends.
Launch your free server now.