01
Where does the lag come from?
Before changing any setting, tell two problems apart:
- Server lag: every player is affected at the same time. Characters rubber-band, doors and props react late, actions take a while to apply.
- One player's low frame rate: only that player is bothered, often in an area full of props or with a heavy HUD. Their computer is struggling, not the server.
The server does most of its work, including physics and the addons' Lua code, on a single core. A machine with many cores can therefore lag while its processor looks almost idle overall: what counts is the load on that one core, and the processor's clock speed.
To measure, the stats command, typed in the server console, shows among other things the processor usage and the server's frames per second. Note it when the server is empty, then at peak time. Be careful: an empty server goes into hibernation and stops running the addons' Think functions, unless sv_hibernate_think 1 is set. A test on an empty server says nothing about the real load.
Also count the entities on the map:
lua_run print(ents.GetCount())
If that number keeps climbing over the hours and never comes down, an addon creates entities without ever removing them.
02
Tickrate and launch line
The tickrate is the number of times per second the server computes the world. It is 66.6666 by default (one tick roughly every 15 ms) and is changed at launch with -tickrate; the official wiki recommends a value between 30 and 128.
./srcds_run -game garrysmod -tickrate 33 +maxplayers 40 +gamemode darkrp +map rp_downtown_v4c_v2
- A higher tickrate makes the game more precise, but each second needs more computation: addons that act on every tick run more often. Do not raise it on a server that already lags.
- A lower tickrate lightens the server, at the cost of a slightly less responsive game. On a very busy roleplay server, it is a trade-off to test, not a cure-all.
Lua auto refresh. Garry's Mod reloads Lua scripts as soon as a file changes on disk. The official wiki notes that this reload can lag the server when it cascades. On a live server, where code is not edited on the fly, add -disableluarefresh to the launch line.
Memory. The standard server is a 32-bit program: it cannot use more than a few gigabytes, whatever the machine's memory. The server's x86-64 branch (installed with -beta x86-64 in SteamCMD) lifts that limit. Binary modules (gmsv_… files) must then exist in a 64-bit version. To install the server, see creating a Garry's Mod server.
03
Badly coded addons: finding the culprit
The most common cause of lag is an addon that does too much work. Things to watch for:
- Functions hooked to
Think or Tick: they run on every server frame. An addon that loops over every player or every entity there, each time, quickly gets expensive.
- Very frequent timers that repeat the same heavy work in a loop.
- Network messages sent in bursts to every player, for example a HUD that receives data on every tick.
- Addons that pile up entities (money printers, pick-up items) without a limit.
FProfiler, a profiling addon written by the DarkRP author (github.com/FPtje/FProfiler), measures the time spent in each Lua function. The FProfiler console command opens its menu; server-side profiling is reserved for superadmins. Start a measurement while the lag is happening, then read the tab listing the functions that take the most time (Bottlenecks) and the one listing the slowest single calls (for spikes): the file paths point to the addon at fault. Remove FProfiler once the investigation is over.
Without a tool, work by halves: remove half of the addons, watch, then start again with the faulty half. Take a backup first. Be wary of paid addons redistributed for free: they are often poorly maintained and sometimes contain backdoors. Replace an abandoned addon rather than keeping it out of habit. To manage Workshop addons, see Workshop addons.
04
Props, entities and cleanup
Every prop is computed by the physics engine, especially when it moves or touches other objects. Hundreds of unfrozen props colliding with each other are enough to lag the whole server.
Per-player limits. Gamemodes derived from Sandbox, including DarkRP, read their limits from sbox_max… variables, set in server.cfg:
sbox_maxprops 50
sbox_maxragdolls 2
sbox_maxvehicles 1
sbox_maxeffects 10
sbox_maxballoons 5
sbox_maxnpcs 0
sbox_maxsents 10
sbox_maxconstraints 100
sbox_maxropeconstraints 20
These values are an example to adapt: Sandbox's default prop limit is 200 per player, a lot for a full roleplay server. The other variables follow the same pattern (sbox_maxwheels, sbox_maxthrusters, sbox_maxlamps…).
Prop protection. On DarkRP, FPP (Falco's Prop Protection) ships with the gamemode: besides protecting each player's props, it has anti-spam settings, to set from its menu before opening. See creating a DarkRP server.
Cleanup. The gmod_admin_cleanup command lets admins clean up the map; each player can remove their own objects with gmod_cleanup. Who counts as an admin is set in your admin tool: see ULX and ULib. A cleanup also wipes players' builds: warn them first. On a TTT server, the map is reset every round, which limits the build-up (see creating a TTT server).
05
Workshop collection and server memory
A heavy Workshop collection is not necessarily the cause of in-game lag, but it weighs on other things:
- startup: the server downloads and loads every item of the collection on each restart;
- memory: models, maps and Lua code stay loaded as long as the server runs;
- code: every addon in the collection that contains Lua runs on the server, whether it is used or not;
- players: the heavier the collection, the longer their first load, and the more of them give up before getting in.
Sort through it regularly: remove unused addons, duplicates and very heavy content packs. If the server's memory use grows over the days and never comes down, an addon holds on to memory without releasing it: track it down as above, and in the meantime schedule a daily restart during off-peak hours. To serve non-Workshop content faster, see web hosting for a GMod server.
06
On a CloudFive server
Since the server depends mainly on one core, the processor's clock speed matters more than the number of cores. Our Garry's Mod hosting plans, from €2 per month, run on AMD Ryzen 9 9950X, with DDR5 memory and NVMe storage, in France and on our own network.
- The console in the customer area at manager.cloudfive.fr is where you run
stats and read Lua errors live.
- Files (
server.cfg, addons) are edited with the file manager or over SFTP.
- DarkRP, the Workshop collection and ULX install in one click; take a backup before removing or adding addons.
- Anti-DDoS Premium is included, with a game-specific profile (see protecting a game server from DDoS).
Monthly, with no commitment, and support in French 7 days a week. To keep control of the whole system, a gaming VPS is also an option: see a Garry's Mod server on a VPS.
07
Frequently asked questions
Why does my Garry's Mod server lag when the processor is barely used?
Because the server does most of its work, physics and Lua code, on a single core. That core can be saturated while the others are almost idle: what counts is its load, and the processor's clock speed.
Which tickrate should I use for a Garry's Mod server?
The default tickrate is 66.6666 and is changed with -tickrate in the launch line; the official wiki recommends a value between 30 and 128. Do not raise it on a laggy server: a lower tickrate lightens the server, at the cost of a slightly less responsive game.
How do I find the addon that makes a GMod server lag?
Install FProfiler, open it with the FProfiler command as a superadmin and start a server-side measurement while the lag is happening: the most expensive functions and their file paths point to the addon. Without a tool, remove addons by halves until you find the culprit.
How do I limit props on a Garry's Mod server?
Set the sbox_max variables in server.cfg, for example sbox_maxprops for props per player, whose Sandbox default is 200. On DarkRP, also set up FPP's anti-spam, and clean the map with gmod_admin_cleanup when needed.
Does a large Workshop collection make the server lag?
It mainly lengthens server startup and the players' first load, and takes up memory. Addons that contain Lua code also run on the server: remove the ones you do not use.