Game Servers Minecraft Lag Solved!
How Minecraft works and What is causing the lag?
Lag in a sense all occurs on one thread, and the next loop cannot start until the current one finishes. A Minecraft world will not update or load, your player and other players can not move and characters and objects including moving things will be frozen. For smooth gaming, each tic should not be longer wait times than 50ms to keeping to a rate of 20 Tics Per Second tps. TPS can go as low as 55.55ms for 18 tps with less or no issues. Any lower than this and you will begin to see lags on your server/game.
Usual causes of Minecraft lag
Many things can cause lag on your Minecraft server but most issues will be down to plugins and misconfigurations for most servers.
Any plugin reading from player files, for example, player movement, damages to a player or objects or interactions. An example would be some PVP flags and plugins which will constantly read from your player file or players files.
FlatFiles are also known as a database: When using a plugin that uses large files to track data it can cause overloading and high memory usage if not coded or configured correctly the compute operation time will slow down the servers tic if not optimized.
Too many operations
When a plugin is carrying out many actions at the same time, commands if you will. Too many actions carried out at the same time will always slow any server down it is inevitably like you are attacking your own server.
This is when a plugin or mod generates structures outside of the resources it is allocated. cascading causes the next part to load, then generate and then continuously loop all over again.
Finding a cause of lag is as easy as using the profiling tools included.
Timings report Spigot – PaperSpigot
To get a detailed timings reports you can use the following command:
Now wait a few minutes then run the command:
This will produce a detailed report and should show a website link for you to click and review the information.
Turn off timings after you are done reading the report/reports.
Timings Reports for Sponge
To get a more detailed timings report use the following command:
/sponge timings on
Wait for 5 minutes then you can proceed with the command:
/sponge timings report
You will be provided with a website link which you should see after running the above command and then you can review and study the information.
Turn off timings report to stop server overloads etc.
/sponge timings off
You can reset the timings to ensure efficiency for your server/game.
/sponge timings reset
Tips to reduce Minecraft server lag
Use the proper arguments for your script file when launching Minecraft. Learn more about the appropriate Java arguments here
You can use LuckPerms that will give you a better database instead of flat file.
Do not use chunk loaders if possible.
Remove any plugins or scripts or edits that cause cascading world generation slowdowns or freezes.
Limit Anti Cheat plugins to ensure they are not overloading your game.
Limit the view distance of players in your server. properties settings.
Remove hostile mobs after a set time scale.
Restart the server daily to clean up issues and to speed up the server.
Do not reload the server, this will cause memory and CPU leaks and more.
It is recommended that you use FastAsync versions of plugins such as WorldEdit and VoxelSniper.
Limit the size of your world so new chunks are not constantly being created, the bigger your world the more power you will need.
Limit the number of plugins you use. Not all plugins are coded very well or tested properly the more plugins you use increases the potential for issues to appear.