FiveM lag almost always comes from three places: CPU-heavy resources, entity/streaming overload, and blocking database queries or hitches. The good news: with resmon and a few rules you can find and fix the worst offenders fast. Here's how to optimize a FiveM server in 2026.
Step 1 — Read resmon
Open the resource monitor in-game with the resmon 1 command. It lists every resource and its CPU time in milliseconds. As a rule of thumb, any single resource consistently above ~0.25-0.50 ms at idle deserves a look, and anything spiking into several ms during normal play is a prime hitch suspect. Aim to keep the total comfortably under ~8 ms.
Optimize in this order: server CPU (scripts) first, then entity streaming, then client assets. Random config tweaks rarely help — measure first.
Step 2 — Throttle your threads
The single biggest cause of high resmon is loops that run every frame (Wait(0)) when they don't need to. Add a dynamic sleep so checks only run fast when the player is actually near something:
-- Bad: burns CPU every frame
CreateThread(function()
while true do
Wait(0)
-- proximity / status check
end
end)
-- Good: sleep when idle, speed up only when needed
CreateThread(function()
while true do
local sleep = 1000
local ped = PlayerPedId()
local near = isPlayerNearPoint(ped) -- your check
if near then sleep = 0 end
Wait(sleep)
end
end)Step 3 — Use async database queries
Blocking, synchronous SQL queries stall the main thread and cause server-wide hitches. Use oxmysql's async/await style instead of synchronous calls in hot paths:
-- Prefer async
local rows = MySQL.query.await('SELECT * FROM users WHERE identifier = ?', { identifier })
-- Avoid heavy synchronous queries inside loops or events that fire oftenStep 4 — Tame entity streaming
- Keep OneSync on so the server authoritatively manages entities.
- Compress oversized vehicle textures (YTD files) — huge textures kill streaming bandwidth.
- Remove abandoned vehicles and props with a periodic cleanup so entity counts stay sane.
- Limit how many props/peds scripts spawn at once.
Step 5 — Profile real hitches
When you get 'server thread hitch' warnings, use the built-in profiler from the server console (not the F8 client console) to capture which resource is responsible during peak load. Fix the top offender, re-measure, repeat. Targeted fixes beat guesswork every time.