How to Reduce Lag and Optimize Your Minecraft Server
Lag on a Minecraft server can have several causes, such as insufficient RAM or CPU capacity, large numbers of chunks and entities, or resource-intensive plugins, mods, farms, and redstone contraptions. In this guide, we cover the most important ways to reduce lag on your Minecraft server.
Tip Do only certain players experience low FPS or high ping? The problem is probably with their computer or internet connection. With server lag, mobs, redstone, and players respond slowly for everyone.
Check CPU and RAM Usage
Check the CPU and RAM usage in the game panel while the lag is occurring.
RAM usage can increase during gameplay as terrain, chunks, entities, and other data are loaded. Java also often keeps allocated memory available for reuse. High RAM usage therefore does not necessarily indicate a problem. If RAM usage reaches the limit, the server may eventually crash or restart. The console may then show messages such as OutOfMemoryError or Cannot allocate memory.
Does the CPU or RAM continually reach the limit during normal use? Consider upgrading to a larger plan. Follow our guide on upgrading your service.
Note An upgrade only helps when the available CPU or RAM is the limiting factor. If a resource-intensive plugin, mod, farm, or configuration is causing the problem, investigate the underlying cause as well.
Lower the View Distance and Simulation Distance
The view-distance setting determines how many chunks are loaded around each player. The simulation-distance setting determines the distance within which entities, redstone, fluids, and other game mechanics are updated. Lower values reduce CPU and RAM usage.
- Log in to the game panel and go to your Minecraft server.
- Stop the Minecraft server if it is still running.
- Open the Files page.
- Click the
server.propertiesfile. - Find
view-distance=andsimulation-distance=.
Tip UseCtrl+Fon Windows and Linux orCmd+Fon macOS to find the settings more quickly.
- For example, use the following recommended settings:
view-distance=7
simulation-distance=7- Save the file and start the Minecraft server.
Note A lowerview-distancemeans players cannot see as far. A lowersimulation-distancecan affect farms, redstone contraptions, and mobs.
Select an Optimized Startup Command
- Log in to the game panel and go to your Minecraft server.
- Stop the Minecraft server if it is still running.
- Open the Settings page.
- Open the drop-down menu under Startup Command.
- Select an optimized startup command.
- Start the Minecraft server.
Use Optimized and Up-to-Date Server Software
If you use Vanilla server software or Forge without mods, we recommend changing your Minecraft server software to Paper or Purpur for better performance.
Do you use Forge, NeoForge, Fabric, or a modpack? Continue using the required mod loader and check whether a newer stable version is available. Keep your Minecraft server, plugins, and mods up to date as well:
Find the Cause of High CPU Usage
A resource-intensive plugin, mod, entity, or task can slow down the entire Minecraft server. Paper 1.21 and newer include the spark profiler by default. Run the following command through the console while the server is lagging:
spark tpsA well-performing Minecraft server runs at around 20 TPS. If the MSPT consistently exceeds 50 milliseconds, processing each tick takes too long and server lag occurs.
Next, create a five-minute profile:
spark profiler start --timeout 300When the profile is complete, a link to the report appears. Check which plugins, tasks, entities, or worlds use the most processing time. Update the cause, adjust its configuration, or remove unused components.
Tip Is spark unavailable? Install a compatible version of spark for your server software and Minecraft version.Limit Resource-Intensive Farms, Entities, and Redstone
Check areas with large numbers of animals, villagers, monsters, items, minecarts, hoppers, or redstone clocks. Limit farms that run continuously and disable unused chunk loaders.
Pre-Generate Frequently Used Parts of the World
Does lag mainly occur when players travel quickly or explore new areas? Pre-generate the terrain with a plugin or mod such as Chunky. The server will then only need to load those chunks when players visit them later.
Create a backup first and only generate the area players are expected to use. Run the process when no players are online and monitor storage usage.
Note Pre-generating terrain temporarily puts a heavy load on the server and can use a large amount of storage. Set an appropriate radius and, if needed, a world border.
Schedule Automatic Restarts
A periodic restart releases temporary memory and can limit gradually increasing memory usage caused by plugins, mods, and loaded data. For example, schedule an automatic restart every night during off-peak hours.
Follow our guide on scheduling automatic restarts for your Minecraft server.
Note Automatic restarts do not fix a persistent CPU or RAM shortage or resource-intensive plugins, mods, or contraptions.
Check the Results
Apply one optimization at a time, then test the Minecraft server under similar conditions. Does the server continue to lag? Create a spark profile while the lag is occurring and include the link when contacting ConsulHosting support.