All articles

Entity lag: finding the farms, items and mobs slowing your server

How to count entities, find where they pile up, clear them safely, and build farms that do not drag the server down.

By the Cobbly team ·

On most survival servers, when lag builds up slowly over weeks, the cause is entities. An entity is anything in the world that is not a block: players, mobs, animals, villagers, dropped items, XP orbs, arrows, minecarts, boats, item frames, armour stands and paintings. Every one of them is updated every tick, and some of them — villagers and mobs that pathfind — are expensive.

This guide is about finding where they pile up and fixing it without wrecking anyone’s base.

Count them

The execute command can count any entity type and works on every server type. In the console:

  • execute if entity @e — every entity in loaded chunks. It answers with Test passed, count: 1234.
  • execute if entity @e[type=item] — dropped items only.
  • execute if entity @e[type=villager], @e[type=cow], @e[type=experience_orb] and so on for each suspect.

There is no single “too many”, but as a feel for a small server: a few hundred entities in total with players online is normal; a few thousand means something is piling up. Paper also has paper entity list, which lists the counts of every type at once, and Forge and NeoForge have forge entity list and neoforge entity list.

Find where they are

Counts tell you what, not where. To find the place, use a radius around a player: execute as YourName at @s if entity @e[type=item,distance=..64] counts the items within 64 blocks of you. Walk to the farms and bases you suspect and compare. On Paper, paper entity list with an entity type also lists the chunks that hold the most of it, with their coordinates.

The usual culprits

  • Item farms with no collection. Melon, sugar cane, kelp and mob farms that drop items onto the ground instead of into hoppers. Items stay for five minutes each; a fast farm can keep thousands on the floor at once.
  • Mob farms that store mobs. A farm that collects mobs in a holding area instead of killing them builds up hundreds of mobs, all pathfinding.
  • Villager trading halls. Villagers are among the most expensive mobs: they constantly look for beds, workstations and each other. A hall of 50 villagers who can all see each other costs more than most redstone.
  • Animal pens. Breeding cows until the pen is solid. Packed animals also push each other every tick.
  • Item frames and armour stands. Cheap individually, but a decorated base can have hundreds.
  • Abandoned minecarts and boats. Each is an entity forever, even empty.

Clearing them safely

Clearing dropped items and XP is always safe:

  • kill @e[type=item] — all dropped items.
  • kill @e[type=experience_orb] — all XP orbs.

Never run plain kill @e. It kills every entity, including players, named pets, villagers, horses, item frames, armour stands and paintings — and none of it can be undone without a backup. Even @e[type=!player] still kills pets and villagers. Always name the type you mean.

For a crowded animal pen, ask the owner first. kill @e[type=cow,distance=..20] run at the pen (with execute at YourName run …) clears just that area.

Building farms that do not lag

  • Collect into chests. Hoppers or hopper minecarts under every drop point. Items in a chest cost nothing.
  • Kill mobs promptly. A mob farm should kill as fast as it spawns, not store mobs.
  • Lock villagers in. Each villager in its own one-block cell with its workstation, with no line of sight to the others, does far less pathfinding.
  • Keep pens small. Ten to twenty animals breed as well as two hundred.
  • Use a switch. A lever that turns a farm off when nobody needs it saves the whole cost of it.

Game rules and settings that help

  • gamerule maxEntityCramming 24 is the default: more than 24 mobs in one block space start taking suffocation damage. It caps accidental piles. Do not raise it.
  • On Paper, nerf-spawner-mobs, item merge radius and fast despawn for junk items cut entity counts a lot — see Paper performance settings worth changing.
  • A lower simulation distance freezes entities further from players, so remote farms stop costing anything until someone visits. See View distance vs simulation distance.

Check it regularly

Entity lag creeps up. Running execute if entity @e once a week and noting the number is the easiest early warning there is — if it doubles, something new is piling up. Why is my Minecraft server lagging? covers the other causes once entities are ruled out.

Ask on Discord

Other players and the team hang out there - it's usually the fastest way to get unstuck.

Join the Discord

Ready to try it yourself?

Create a free Cobbly server in under a minute — no card, no trial.

Create a server