How do I fix lag on my FiveM server?
First work out whether the lag is server-side or client-side. Server thread hitch warnings in the console point to a slow resource, a slow database query or an overloaded host; low FPS or texture loss on clients usually points to heavy streamed assets or client scripts. Use resmon and the built-in profiler to find the guilty resource, fix or replace it, and only upgrade hardware after that.
Step 1: Identify which kind of lag you have
Players say "lag" for very different problems:
- Rubber-banding and delayed actions for everyone at once usually mean the server main thread is stalling.
- Low FPS or stutter on clients while the server is fine usually means client scripts or assets.
- Lag for some players only often comes down to their connection or distance to the host.
- Textures not loading and invisible roads mean too many or oversized streamed assets.
Check the server console first. Repeated "server thread hitch warning" messages tell you the server itself is struggling.
Step 2: Measure, do not guess
On the client, open the F8 console and run:
resmon 1
This shows CPU time per resource. A well-written resource idles near 0.00 to 0.02 ms. Anything sitting at a high value while nothing happens is a candidate. The resmon glossary entry explains how to read it.
On the server, use the built-in profiler from the server console:
profiler record 500
profiler view
The view shows which resources and events consumed server time during the recording.
Step 3: Fix the usual suspects
- Tight loops. Client loops with
Wait(0)that run checks every frame even when the player is nowhere near the relevant area. Increase the wait when idle. - Slow database queries. Missing indexes on tables like owned vehicles or inventories. oxmysql can warn about slow queries; add indexes on the columns used in WHERE clauses.
- Event spam. Resources triggering server events every frame or every second for every player.
- Oversized assets. Vehicle and clothing packs with huge textures. The server warns about oversized assets at startup; take those warnings seriously.
- Too many resources doing the same job. Two HUDs, two notification systems, three anti-cheats.
Step 4: Check the host
If profiling shows nothing obvious and hitches still appear, look at the machine:
- CPU steal time on a shared VPS
- Disk I/O wait during database writes or backups
- Other services on the same box competing for CPU
See hosting specs for what a healthy setup looks like.
Step 5: Tune the config sensibly
Keep the basics clean in server.cfg:
set onesync on
sv_maxclients 64
sv_enforceGameBuild 3095
Raising sv_maxclients beyond what your scripts can handle makes lag worse, not better. A newer enforced game build adds content but also increases client load, so test it first.
A quick troubleshooting checklist
- Server console clean of hitch warnings at idle
- No resource above a few tenths of a millisecond at idle in resmon
- Database tables indexed on lookup columns
- Oversized asset warnings resolved
- Backups and restarts scheduled away from peak hours
- Duplicate resources removed
Lag is one of the main reasons servers lose players, so it is worth fixing before any promotion push.