Server lag in FiveM is frustrating because it has many possible causes: a heavy script, a slow database, too many entities, not enough CPU, or sometimes a network problem. The good news is that you can usually find the cause with a methodical approach. This guide walks you through it.
Step 1: Work Out What Kind Of Lag It Is
Different problems feel different. Ask what players actually experience:
- Server hitches. The whole game freezes for a moment, then catches up. This usually means the server main thread was busy.
- High ping for everyone. This points to the network or an attack, not a script.
- Lag for one player only. This is almost always that player's own connection or computer.
- Slow loading and long joins. This points to storage, large streamed assets or a slow database.
- Gets worse with more players. This suggests scripts that scale badly or not enough CPU.
Step 2: Check The Resource Monitor
FiveM has a built-in resource monitor you can open from the client with the resmon 1 console command, and txAdmin shows server performance charts. Use them to find which resources use the most time. Look for resources that take a lot of time while idle, because a script that burns CPU when nobody is using it is almost always badly written.
On the server side, txAdmin also shows when hitches happen and how long the main thread was blocked. Note the time of each hitch so you can compare it with events on your server, such as a restart, a heist or a payday script running.
Step 3: Find And Fix Heavy Scripts
- Remove what you do not use. Every resource has a cost, even if small. Old or duplicate scripts add up.
- Check loops. Scripts that run a loop every frame with no wait are a common cause of client lag. On the server, loops with very short waits that run constantly are just as bad.
- Replace the worst offenders. If one resource uses much more time than similar ones, look for a better-maintained alternative.
- Test one change at a time. Stop a resource, check the monitor, and put it back. Changing ten things at once teaches you nothing.
Step 4: Look At The Database
Most roleplay frameworks save and load data from a database like MariaDB or MySQL constantly. If queries are slow, the server waits, and players see hitches when they use inventories, shops or garages.
- Run the database on fast NVMe storage.
- Make sure the database has enough memory and is not sharing a machine that is already out of RAM.
- Use a maintained database connector and check your logs for slow query warnings.
- Clean up old data, such as abandoned characters or huge log tables, that make queries slower over time.
Step 5: Reduce Entity And Streaming Load
- Limit how many vehicles and peds can exist. Ambient traffic and pedestrians cost server time on busy servers.
- Clean up abandoned vehicles and dropped objects automatically.
- Be careful with large custom MLOs, vehicle packs and clothing packs. Optimize textures and models, because oversized assets slow downloads and loading.
Step 6: Check The Hardware
If your scripts are clean and you still hit limits, the hardware may be too small. Look at the CPU: if the main thread is near its limit, you need faster cores, not more of them. Check memory too, and make sure the system is not swapping. Our guide FiveM Server Requirements by Player Slots gives starting points. If you share a VPS with other customers' heavy load, consider a package with dedicated cores, or move to a bigger VPS package.
Step 7: Rule Out The Network And Attacks
If everyone's ping rises at once while the server's own performance looks normal, the cause may be the network. A DDoS attack can look like server lag. Check your provider's traffic graph, and read how to protect a FiveM server from DDoS if you suspect one.
A Simple Routine That Keeps Servers Healthy
- Restart on a schedule so memory leaks do not build up over days.
- Update your server build and your resources regularly.
- Review the resource monitor once a week, not only when players complain.
- Keep backups before every big change.
- Add scripts one at a time and watch the effect.
The Short Version
Find out which kind of lag you have, measure with the monitor, fix the heaviest scripts, keep the database fast, and only then buy more hardware. Most lag problems come from software, and they are usually cheaper to fix than to cover with a bigger server.