FiveM Server Optimization: A Practical Guide


"The server is lagging" describes a symptom with at least five unrelated causes, and every hour spent optimising the wrong one is wasted. This guide is about measuring first: finding which of client frame rate, server tick, database latency or network is actually the problem, and then fixing that.
Start with resmon
Type resmon 1 in the client console. You get a live table of every running resource with its CPU time in milliseconds. This is the single most useful diagnostic in FiveM and most server owners never open it.
Read it while doing normal things — driving, opening menus, standing in a busy area. A resource that idles at 0.01ms and spikes to 8ms when a menu opens is a different problem from one that sits at 3ms constantly. Note both the idle cost and the peak.
Rough thresholds for a single resource: under 0.05ms idle is fine, 0.1–0.5ms is worth a look, above 1ms sustained is a problem. The numbers add up across forty resources, which is how a server with no single bad script still runs badly.
The three causes behind most complaints
Loops that run when nothing is happening. The classic FiveM performance bug is a while true do ... Wait(0) end loop that checks something every frame regardless of whether it could have changed. A distance check to a marker the player is nowhere near costs the same as one they are standing on. Well-written resources scale their wait time with distance or use events instead of polling.
Database queries in the wrong place. A query inside a loop, or one that runs on every player join without an index, blocks the server tick while it waits. Symptoms are server-side: everyone rubber-bands at the same moment rather than one player having low FPS. Check that the columns you query on are indexed.
Entity count. Every spawned vehicle, prop and ped is network-synchronised. Servers that let vehicles accumulate — no garage return on restart, no cleanup of abandoned cars — reach the entity limit and everything degrades at once. This is why the garage impound question in our garage guide is a performance question as well as a gameplay one.
Separate client lag from server lag
They feel similar to players and need opposite fixes. Ask two questions: does it affect everyone at the same moment, and does it show in resmon?
- One player, high resmon numbers — a client-side resource or that player's hardware.
- Everyone at once, resmon normal — the server tick, usually database or entity count.
- Everyone at once, one resource spiking in resmon — that resource, and you have already found it.
- Everyone, intermittent, no pattern — network or host. Check your provider before your code.
Things worth doing before you profile
- Run a recommended artifact, not the newest. Latest builds are development builds and performance regressions do ship in them.
- Set
sv_maxclientshonestly. It is a ceiling, not capacity. A slot count your hardware cannot serve produces a full server that plays badly. - Remove what you do not use. Every started resource costs something. Servers accumulate test resources that never got removed.
- Check
OneSyncis on the right mode for your player count. The infinity mode exists for large servers and has costs on small ones.
Buying with performance in mind
Idle cost is the number to ask about before you buy, because it is paid constantly by every player. A script that idles at 1ms costs more over an evening than one that spikes to 5ms when a menu opens twice. Every ATY script is written to idle at 0.00ms, which is measurable in resmon on your own server rather than something you have to take on faith.
Where to go next
For the resource-side view of the same problem — what makes an individual script cheap or expensive — read our FiveM resource optimization guide. If you are still assembling the server, the setup guide covers the configuration decisions that affect performance later.
Every ATY script ships with its own setup page in the documentation, and delivery is automatic through Cfx.re Keymaster the moment payment clears. Browse the full catalogue in the store, or open a ticket in our Discord if you get stuck — you talk to the developers who wrote the code.