Server Optimization

When our server starts to have a higher number of players, plugins or mods, it is important to optimize it to provide the best gaming experience to our users.

1. RAM Memory Usage Optimization

The optimization of our server to reduce the ram memory consumption has a limit. There will be a time when it will be necessary to increase the ram. Consult this article to know how to do it.

Before explaining the methods to optimize ram memory usage it is important that we first understand how ram memory works, without going into too much detail, on Minecraft servers.

1.1. How Our Server Uses RAM

Ram memory is the short-term memory of computer equipment (PCs, cell phones, servers, etc). The ram has a higher speed to store and share data with the processor than hard disks/solid state, so the ram memory has as main utility the storage of data to which an easy and fast access is needed. In the case of Minecraft servers, these data that must be easy and fast to obtain are:

  • Chunks: A chunk is a piece of our world that has as dimensions 16x16 blocks and goes from the bedrock to the last buildable block in the sky. What is stored in ram memory is the state of each entity and block in that specific chunk, and it is done 20 times per second (more about this and how it is related to TPS later).

    Only the chunks that have been visited since the server was turned on will be loaded in ram memory. The rest of the chunks that have been generated, but not loaded, will be stored in the hard disk/solid state, waiting to be loaded.

    It is for this reason that if you use a plugin like Chunky to pregenerate chunks we recommend that, when the process is finished, you restart the server. This way, you will get the benefit of having the chunks pregenerated but without having an exaggerated ram memory usage.

  • Plugin information: Plugin data that is related to players, such as the money a player has. Data that are not related to players, such as the configuration of a plugin, are also loaded.

  • Mod Information: Similar to plugins, mods also have independent data and data related to players or other entities. For example, in a mod that adds new creatures to Minecraft, you will need to keep track of the characteristics of each of those mobs.

  • Mobs

1.2. Ram Memory Usage Optimization Methods

Now that we have seen the main ram usage of our Minecraft server, we can understand much better why certain methods work. Below we will discuss some methods that we have used with our client's servers and have seen an improvement. However, in other articles on optimization you can find other methods that will also be useful.

  1. Restarting the server: This is a simple and widely used solution, especially in other video game servers. To make your life easier we recommend that you install an automatic restart plugin every few hours. An acceptable time interval for a restart is every 24, 12 or 6 hours, depending on whether the average duration of a game session is longer or shorter (we should try to avoid that a player experiences two restarts in the same game session).

    One automatic restart plugin that we recommend, for example, is UltimateAutoRestart, since it includes certain customization options that will make your players' experience before and during the restart a little more pleasant.

    We recommend that you choose a hosting service that has a good processor (such as RetlyHosting) so that the restart does not take forever.

    Restarting the server will help to reduce the amount of data loaded in the server's ram memory.

  2. Set a player limit: As you have seen in the previous section, almost all the information stored in the ram memory increases as the number of players increases, so limiting the number of players that can enter the server can be effective but a bit drastic. We do not recommend this option unless you have tried everything and cannot expand the ram of your server for economic reasons.

  3. Reduce the number of entities: If the number of entities is higher, there is more data to which fast access is required and therefore ram consumption will increase. We recommend the use of a properly optimized plugin for removing entities from time to time.

  4. Reduce the amount of mobs: The same happens with mobs as with entities, so it is recommended to reduce the amount. We recommend the use of the StackMob plugin, which if well configured, will allow you to reduce as much as you want the amount of mobs in the world. With this plugin the mobs will not disappear, but will be gathered into one. Thus, for example, you will be able to see a sheep with a x15 in its name, which will indicate that this sheep really represents 15 of them.

2. Optimization to reduce lag due to low TPS

2.1. What are TPS and what causes them?

The TPS is the Ticks Per Second that the server has at any given time.

The tick is the unit of time in Minecraft, and it is how often the status of everything that is happening in the world is updated. For example, the degree of illumination of a block is updated every 1 tick. If the server is running perfectly, 1 tick is equivalent to 0.05 seconds, or 20 ticks is equivalent to 1 second. This means that if a server is running at 20 TPS, it is running perfectly.

When a server goes slow, and therefore the TPS goes down, it means that there are less status updates (less ticks) per second, and therefore, the elements of the world will go slower.

To understand this, we can make a simile to the FPS (Frames Per Second), where if there is less FPS, the video game or video will be less fluid. In any case, it must be taken into account that FPS and TPS are not the same thing. FPS is caused by the client (the Minecraft game) and TPS is caused by the quality of the hardware running the server. Thus, a better processor will ensure a greater amount of TPS at higher power requirements (when the number of players, plugins, etc. is increased a lot).

2.2. Server Optimization for High and Stable TPS

In this section, although we will discuss some options that can be edited to improve performance, we will mention other articles/guides that we have found that are very comprehensive.

  1. Reduce redstone lag: You can use a plugin like RedstoneDetector to limit the use of redstone. Also, in server.properties you can disable the use of command blocks.

  2. Pregenerate the world: We have already talked about pregeneration in this article, but we have only seen the negative points it has and how to eliminate them. But it also has positive points! Pregenerating the world means that the processor does not have to generate the chunks at that moment, but only collects the information already processed from the hard disk and displays it on the screen. If you don't pregenerate the world, something like this can happen:

  1. Optimize the configuration files: It is advisable to modify the values of certain options in the server configuration files. Although this may vary depending on the software, here are some examples of files with some optimized options:

    1. Bukkit.yml:

spawn-limits:
  monsters: 50
  animals: 8
  water-animals: 7
  water-ambient: 10
  water-underground-creature: 5
  ambient: 1
chunk-gc:
  period-in-ticks: 400
ticks-per:
  animal-spawns: 400
  monster-spawns: 5
  water-spawns: 11
  water-ambient-spawns: 21
  water-underground-creature-spawns: 11
  ambient-spawns: 31
  autosave: 6000
  1. Spigot.yml:

 save-user-cache-on-stop-only: true
    max-tick-time:
      tile: 10
      entity: 20
    mob-spawn-range: 6
    entity-activation-range:
      animals: 16
      monsters: 24
      raiders: 48
      misc: 8
      water: 16
      villagers: 24
      flying-monsters: 24
    merge-radius:
      exp: 4.0
      item: 6.0
    tick-inactive-villagers: false
   nerf-spawner-mobs: true
   arrow-despawn-rate: 300
   trident-despawn-rate: 300

It is possible that these files are not on your server for the reason that your server is using other software (such as Forge). You should first find out what software your server is using and then look for a guide that is dedicated to discuss all the optimization points for that software.

2.3. Complementary Articles

As mentioned in the previous section, we also wanted to mention articles that we have reviewed and found interesting.

  1. Minecraft Server Optimization Guide: Here is a review of all the recommended options to optimize in Paper, Pufferfish and Purpur software (the best in terms of server optimization with plugins).

  2. This list will be expanded as we find other articles.

Última actualización