Optimize a server for 100+ players
Scale your FiveM server: OneSync, artifacts, heavy scripts, database and txAdmin metrics.
Optimize a server for 100+ players
Past a hundred concurrent players, default server limits and poorly written client scripts become the bottleneck. Optimization targets three areas: network, server CPU, and the database.
Cause / The problem
Tickrate drops and desync usually come from outdated artifacts, a non-OneSync server, client loops that run every frame (while true do without Wait), or unindexed SQL queries run for each player. The higher the slot count, the more these issues stack up.
Solution
- Enable OneSync in
server.cfg:
OneSync handles entity synchronization natively beyond 32 players.set onesync on set onesync_population true - Update server artifacts (Linux or Windows) from the official Cfx.re site. A recent build fixes memory leaks and improves networking.
- Adjust entity limits carefully: raise
sv_enforceGameBuildonly if a DLC requires it, otherwise the client loads unneeded assets. - Lighten client scripts. Spot loops without
Wait, systematicCitizen.Wait(0)calls, and dozens ofDrawMarkercalls. Use the Resource Monitor to target the heaviest resources. - Optimize the database. Add indexes on the
identifierandownercolumns of players/vehicles tables, and switch to oxmysql (prepared statements + pooling) instead of legacy async MySQL drivers. - Monitor txAdmin. The Metrics tab shows tickrate, CPU and RAM in real time. A tickrate over 30 ms means a resource is hogging the main thread.
Also watch the network: set sv_maxClients 128 is only realistic if the machine has the matching CPU and bandwidth.