FiveM: latency and hitching (optimization)
Reduce server lag by optimizing the tick rate, OneSync and resource-heavy scripts.
FiveM: latency and hitching (optimization)
A smooth FiveM server keeps a stable tick rate above 30 Hz. Hitching and latency appear when a resource blocks the main thread or the network saturates.
Cause / The problem
The “server thread hitch warning” messages indicate that a script takes too long to run on a single cycle (tick). Common causes: loops that are too heavy, synchronous SQL queries in the main thread, too many synchronized entities, or an undersized OneSync configuration.
Solution
- Identify the slow resources. In the txAdmin console, the “Hitch time: XXXms” warnings are often followed by the name of the offending script. Also use the
profilecommand to generate a per-resource CPU report. - Optimize SQL queries. Replace
MySQL.Sync.fetchAllcalls (blocking) withMySQL.Async.fetchAll. Add indexes on frequently filtered columns (identifier,citizenid). - Reduce network load. Check
sv_maxclients: a 128-slot server with 30 players does not need to be configured at 128. Lower it to 64 if that is your real peak. - Limit your resources. Beyond 150 active resources, startup and tick performance degrade. Disable what you do not use (
stopin the console, comment out theensure). - Enable OneSync Infinity (
onesync on) for better network load distribution than in legacy mode. - Monitor the tick rate via the
sr_maxSnapshotscommand or a txAdmin dashboard: a healthy server stays above 30 Hz, ideally 60 Hz.
Aim for a server FPS above 30 on average. Below that, players feel the lag even with a good ping.