Why Your FiveM Server Is Lagging (And How to Actually Fix It)
If you run a FiveM server, you’ve probably dealt with this: players complaining about lag, rubberbanding, desync — and you have no idea what’s causing it. You restart the server, maybe it helps for an hour, then it’s back.
I’ve been optimizing FiveM servers for years now, and the problem is almost always the same few things. Let me walk you through them.
1. Wait(0) Loops — The Silent Killer
This is by far the most common performance issue I see. A Wait(0) inside a while true do loop means that code runs every single frame. At 60 FPS, that’s 60 executions per second, per player, for every script that does this.
Most leaked or cheap scripts from forums are riddled with these. The script “works” but it’s silently eating your server’s CPU.
How to spot it: Open your client scripts and search for Wait(0). If it’s inside a loop that doesn’t need to run every frame (like checking if a player is near a marker), that’s your problem.
How to fix it: Replace Wait(0) with an adaptive wait. Check distance first — if the player is far away, wait 1000ms. If they’re close, wait 100ms. Only use Wait(0) when they’re actively interacting with something.
-- Bad
while true do
Wait(0)
local coords = GetEntityCoords(PlayerPedId())
-- check distance to marker
end
-- Good
while true do
local coords = GetEntityCoords(PlayerPedId())
local dist = #(coords - markerCoords)
if dist > 50.0 then
Wait(2000)
elseif dist > 10.0 then
Wait(500)
else
Wait(0)
-- draw marker, handle interaction
end
end
2. Too Many Entities
Every vehicle, ped, and object on your server consumes memory and network bandwidth. OneSync has to synchronize all of them to every connected player.
I’ve seen servers with 800+ entities running and the owner wondering why it lags with 40 players. The math doesn’t work. As a rough guide:
- Under 300 total entities: Healthy
- 300-500: You’ll start noticing issues at higher player counts
- 500+: You’re going to have problems regardless of player count
How to fix it: The biggest culprit is usually vehicle spawning scripts that don’t clean up after themselves. Check if your garage script, car dealer, or police vehicle script actually deletes vehicles when they’re not needed. Also look at persistent peds from job scripts.
3. Unoptimized Database Queries
If you’re using MySQL.Sync or oxmysql:executeSync, you’re blocking the entire server thread while waiting for the database to respond. Every other script and every player’s actions freeze until that query finishes.
How to fix it: Switch to async queries. MySQL.Async or the async variants of oxmysql. This lets the server keep running while the query processes in the background.
4. Resource Count Bloat
Every resource has overhead. Each one registers handlers, runs threads, and consumes memory. I regularly see servers running 200+ resources when they could accomplish the same thing with 80.
How to fix it: Audit your resources folder. Remove anything you’re not actively using. Combine small utility scripts where possible. You don’t need 5 different notification resources.
5. No Performance Monitoring
This is the real issue. You can’t fix what you can’t see. Running resmon in-game gives you a snapshot, but it doesn’t show you:
- How performance changes over time
- What happens when player count increases
- Which specific script started causing issues after an update
- Historical data to compare before and after changes
This is exactly why I built FivePulse. It gives you a health grade, shows your top problems ranked by actual CPU impact, and tells you exactly what to fix. You install one resource, paste an API key, and within 60 seconds you can see exactly what’s wrong.
Start With the Biggest Impact
Don’t try to fix everything at once. Find your worst offender and fix that first. In my experience, fixing the top 3 performance issues usually improves server performance by 40-60%. The rest is diminishing returns.
If you want to know exactly where to start, try FivePulse for free — it’ll rank your problems by impact so you know which one to tackle first.
Want to find your server's problems automatically?
FivePulse scans your server and tells you exactly what's wrong — with copy-paste fixes.
Try FivePulse Free