MaxTPS

MaxTPS

It's happened - NOW OPENSOURCED: https://github.com/ezdiy/MaxTPS

Current maintainers dont have the time to support the plugin atm, NEW MAINTAINERS ARE WELCOME! It's most likely we'll return back to the development in a few months, but there is no point holding back code people are finding useful (and constantly bugging us about it).

Ie, we will give up this project to the first guy who ports it to 1.2 & writes new docs (MaxTPS 2 replaces several parts of minecraft, it also does some more drastic things - like sending far chunks off-server directly from .mca files!)

Forum thread for latest updates/releases (this wiki lags behind!): http://forums.bukkit.org/threads/admn-fix-maxtps-get-maximum-tps-1-2-2-r0.62732

Max TPS is a plugin to reduce server lags on most of larger (50+ man) Bukkit servers.

Although best results are observed in combination with, it works unlike most of the unofficial Bukkit forks aiming at performance.

The performance is maintained by wisely limiting two heavily taxing things in Minecraft:

  • number of loaded chunks. This is achieved by dynamically adjusting view-distance.
  • number of entities spawned

Most of the time, about 20% to 30% performance gains are observed without affecting gameplay much, after that you'l have to resort to dirty tricks such as limiting growth rate and hard mob spawn limits or view distance below 5. Detailed info about things lagging your server are obtained via /lag command, it looks like this:

/lag
05:14:24 [INFO] There are 5739 entities, 152 players, 1405 spawnermobs
05:14:24 [INFO] [############________]/Mem u=6106M f=3792M t=9898M
05:14:24 [INFO] [####################]/Chunks 36722/30000 (122%)
05:14:24 [INFO] [##################__]/1min TPS 18.02 avg, 19.24 abs
05:14:24 [INFO] [###################_]/1sec TPS 19.94 avg, 19.87 abs
05:14:24 [INFO] [##########__________]/VDist 7 = 225 chunks (3 - 15)

BEWARE! To coexist with NoLagg disable mob spawn limits and item stack merging in NoLagg!

Number of chunks in the world

Every player in game is surrounded by loaded chunks, this is so called 'view-distance' in server.properties. This setting affects server performance drastically, first some numbers:

view-distance=1: 9 chunks
view-distance=2: 25 chunks
view-distance=3: 49 chunks
view-distance=4: 81 chunks
view-distance=5: 121 chunks
view-distance=6: 169 chunks
view-distance=7: 225 chunks
view-distance=8: 289 chunks
view-distance=9: 361 chunks
view-distance=10: 441 chunks
view-distance=11: 529 chunks
view-distance=12: 625 chunks
view-distance=13: 729 chunks
view-distance=14: 841 chunks
view-distance=15: 961 chunks

So for 50 people online, there must be 50*961=48050 chunks loaded at the same time if you're using view-distance of 15 (14450 for view-dist 8 etc). This is of course worst-case scenario, sometimes people are closer together than view distance, thus sharing some chunks.

Minecraft processes every chunk loaded, every tick. This imposes hard limit, because best of todays modern CPU/bus architectures seem to be capable of handling 30k chunks per core max, tps goes down the drain quickly after that.

A way around it is to simply never go that high with chunk count - just define maximum number of chunks your server is capable of handling and adjust view distance according to that. So lets assume your server is capable of handling of 15k chunks.

config.yml:

max-dist: 15
min-dist: 3
chunk-limit: 15000
up-interval: 30
down-interval: 300
tps-threshold: 18.5

routine check, 50, 60, 100 and 200 people online:

  • 15000/50 -> 300 chunks per head, switch to view distance 8
  • 15000/60 -> 250 chunks per head, switch to view distance 7
  • 15000/100 -> 150 chunks per head, switch to view distance 5
  • 15000/200 -> 75 chunks per head, switch to view distance 3

Checks if view-dist can be adjusted are done in definable interval, increase every 30 seconds, decrease every 5 minutes.

Try to have up and down intervals as far apart as possible, to prevent oscillations. This is because truly hard limits on chunk count cannot be really imposed, some plugins like them always loaded, some other plugin might be unloading some by force .. we're just playing guessing game, however it works reasonably most of the time.

NEW! Because chunk counts are usually meaningless until significant amount of people are online on the server, view-dist increases are applied ONLY if current TPS is above tps-threshold, likewise decreased when current TPS is below tps-threshold. The aim for defined chunk count still applies, though.

Figuring out the limits of your server

  1. Install this plugin and check /lag routinely.
  2. Try to find the point when TPS starts going down below your taste and try /maxchunks 14000 followed by /viewdist command without arguments to enforce the change immediately.
  3. Keep repeating 2. while decreasing the number until TPS is back to where you want it.

Use /mindist, /maxdist and /viewdist with argument only if you truly understand how it works and the implications!

Limiting number of entities in the world

config.yml:

item-stacking-radius: 3.5
mobs-per-spawner: 30
spawner-check-interval: 30
ticks-per-monster: 1
ticks-per-animal: 400

At this moment, item and experience orb merging is used. Another source of lag are XP traps built by players around mob spawners. Every time a spawner creates a monster, it is added to a list of mobs spawned in that chunk. If the mob count exceeds the limit per chunk, no further monsters are spawned by mob spawners in there. "Natural" mob spawn is not affected by this. Mobs remember which chunk they were born in, and the limit will be replenished whenever they despawn/die.

The check if spawner can be re-enabled is performed every spawner-check-interval. This is because bukkit provides NO MEANS of notification when monster despawns, so we have to count em all once in a while.

NEW: It is now possible to modify number of ticks after which server tries to spawn monster or animal. Increasing ticks-per-monster to 10 or more can reduce server lags under some circumstances (note that this may affect gameplay because mobs spawn at lower pace).

Dependencies/clashes

  • Orebfuscator seems to work fine
  • NoLagg 1.70 and higher appears to work correctly - but disable item stack forming and and spawn limits (MaxTPS implements its own, supposedly better).
  • This plugin is written in Groovy language, it depends on its runtime - McGroovy. It's included in the .zip, just so that you're not surprised.
  • ChunkManager seems to work fine, but set /maxdist 10 to prevent unnecessary overhead (CM ignores view-distance larger than 10)

TODO

This is planned for 1.2 release of bukkit:

  • completely custom, smart random monster spawning can reduce mob count to roughly 1/3
  • try to move Packet51MapChunk completely out of main thread, thus making chunk loads asynchronous

Game commands

  • /lag - shows neatly formatted view of critical server resources (tps, memory usage, view distance, mob counts...)
  • /tps - alias for lag
  • /viewdist - force immediate view distance change
  • /maxdist - set maximum view distance for auto-adjust
  • /mindist - set minimum view distance for auto-adjust
  • /upinterval - interval to try to increase viewdist by 1 (up to maxdist)
  • /downinterval - ditto, but for decrements
  • /chunklimit - number of chunks your server is capable of handling. 5-10k small VPS, 15-25k dedicated, 25-40k big iron
  • /mtreload - reload from config file
  • /stacking - set stacking radius (0 to disable)
  • /spawnerlimit - limit number of mobs per spawner chunk
  • /tpanimal - ticks per animal spawns (400 default = spawn animal every 20 seconds)
  • /tpmonster - ticks per hostile monster spawns (1 default = spawn 20 mobs every second)
  • /threshold - Set TPS threshold for MaxTPS to start affecting view distance. Increases viewdist (up to chunklimit) when current tps is above this number, decreases when current TPS is below this threshold

Permission nodes

All permissions are in the format of tps.commandname, for example tps.lag should be given to everyone, the rest only to administrators.

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of Daniel_Laixer Daniel_Laixer Feb 06, 2014 at 23:36 UTC - 0 likes

    @Joymo: Go

    I was going to try this on my 1.4.7 server. Thans for the info :)

  • Avatar of JoneKone JoneKone Jul 18, 2013 at 08:31 UTC - 0 likes

    @CraftThatBlock: Go

    Do it, after all it's open source

    Yarrr I'm The Pirateking

  • Avatar of CraftThatBlock CraftThatBlock Jun 08, 2013 at 19:42 UTC - 0 likes

    I can update the plugin if needed. Can I be maintainer?

  • Avatar of mlopezv mlopezv May 30, 2013 at 23:44 UTC - 0 likes

    I'd love to have this plugin working for 1.5.2.

    This was the best performance optimizer ever for MC.

  • Avatar of TheAtreidius TheAtreidius Apr 24, 2013 at 05:40 UTC - 0 likes

    Is there an alternative? I would donate if somebody could bring this thing back to life?

  • Avatar of SilvestrusArctoze SilvestrusArctoze Mar 13, 2013 at 10:26 UTC - 0 likes

    PLEASE UPDATE THIS TO 1.4.7 :D

  • Avatar of joehot200 joehot200 Feb 16, 2013 at 19:13 UTC - 0 likes

    Damn, i need this, i would maintain it, but i dont have the time.

    Pretty much left bukkit :( sorry guys.
    If anyone wants to take over any of my plugins, tell me.

  • Avatar of Joymo Joymo Dec 23, 2012 at 17:15 UTC - 1 like

    Now really dead on 1.4.6, until now it had worked.


  • Avatar of seitzbg seitzbg Nov 28, 2012 at 23:30 UTC - 0 likes

    @jakimfett: Where is the update? :)

  • Avatar of kenaston kenaston Nov 28, 2012 at 14:33 UTC - 0 likes

    Great plugin dude! Love the detail you put in to this! Great work!

Facts

Date created
Mar 01, 2012
Categories
Last update
Mar 05, 2012
Development stage
Release
License
All Rights Reserved
Curse link
MaxTPS
Downloads
8,928
Recent files

Authors