FiveM Server Performance Optimization
FiveM server performance optimization guide. Resource management, OneSync, database optimization, and client FPS improvements.
Table of Contents
Introduction
FiveM is a multiplayer modification framework running on GTA V. High player counts and complex resources can significantly impact server performance. This guide covers FiveM server performance optimization, resource management, OneSync configuration, database optimization, and client FPS improvements.
System Requirements
| Resource | 32 Slots | 64 Slots | 128+ Slots |
|---|---|---|---|
| CPU | 4 Cores | 6+ Cores | 8+ Cores |
| RAM | 8 GB | 16 GB | 32+ GB |
| Disk | 50 GB SSD | 100 GB NVMe | 200+ GB NVMe |
| Network | 50 Mbps | 100 Mbps | 200+ Mbps |
OneSync Configuration
OneSync is FiveM's advanced synchronization system required for high player counts.
server.cfg
# Enable OneSync
set onesync on
set onesync_enableInfinity true
set onesync_enableBeyond true
# Player limit
sv_maxclients 128
# Network settings
set sv_enforceGameBuild 3095
set sv_pureLevel 2
set sv_scriptHookAllowed 0
# Performance settings
set sv_projectName "REXE FiveM Server"
set sv_hostname "REXE FiveM"
OneSync Modes
| Mode | Description | Player Limit |
|---|---|---|
| off | OneSync disabled | 32 |
| on | Standard OneSync | 64 |
| on + Infinity | Advanced sync | 128+ |
| on + Beyond | Long-range sync | 2048 |
Resource Management
Resource Performance Analysis
set sv_resourceMonitor true
set sv_resourceMonitorInterval 5000
From server console:
resmon 1
Resource Optimization Tips
- Remove unnecessary resources: Disable unused scripts
- Thread usage: Optimize heavy operations with Citizen.Wait instead of Citizen.Wait(0)
- Event optimization: Reduce unnecessary network events
- Native calls: Cache frequently used natives
Optimization Example
-- BAD: Runs every frame
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
end
end)
-- GOOD: Runs at intervals
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000) -- Once per second
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
end
end)
Database Optimization
MySQL/MariaDB Settings
[mysqld]
innodb_buffer_pool_size = 2G
innodb_log_file_size = 512M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
max_connections = 200
query_cache_type = 1
query_cache_size = 128M
oxmysql Optimization
set mysql_connection_string "mysql://user:password@localhost/fivem?charset=utf8mb4&connectionLimit=50"
Query Optimization
-- BAD: Query every time
Citizen.CreateThread(function()
while true do
Citizen.Wait(5000)
local result = MySQL.query.await('SELECT * FROM users WHERE id = ?', {playerId})
end
end)
-- GOOD: Use cache
local playerCache = {}
function GetPlayerData(playerId)
if playerCache[playerId] then return playerCache[playerId] end
local result = MySQL.query.await('SELECT * FROM users WHERE id = ?', {playerId})
playerCache[playerId] = result
return result
end
Client FPS Optimization
Streaming Settings
set sv_streamingMemoryLimit 2048
Network Optimization
set net_statsFile "netstats.log"
set sv_endpointPrivacy true
set rateLimiter_stateBagFlood_rate 75
set rateLimiter_stateBagFlood_burst 150
Port Configuration
| Port | Protocol | Usage |
|---|---|---|
| 30120 | TCP + UDP | FiveM game port |
| 40120 | TCP | txAdmin web panel |
Firewall Rules
sudo ufw allow 30120/tcp comment "FiveM TCP"
sudo ufw allow 30120/udp comment "FiveM UDP"
sudo ufw allow 40120/tcp comment "txAdmin"
sudo ufw reload
txAdmin Configuration
txAdmin is the FiveM server management panel:
# txAdmin comes bundled with FiveM
# Web panel: http://SERVER_IP:40120
Performance Monitoring
resmon 1 # Resource monitor
status # Player list
netgraph 1 # Network graph
Conclusion
FiveM server performance optimization is achieved through resource management, OneSync configuration, database optimization, and network settings. Regular performance monitoring and resource profiling ensure your server runs at peak performance. REXE VDS powerful infrastructure and Path.net DDoS protection keep your FiveM server running securely.
Related Articles
How to Set Up a FiveM Server: Step-by-Step Guide
Complete FiveM server setup guide on REXE VDS: installation, txAdmin configuration, port settings, and performance optimization tips for GTA V roleplay servers.
How to Set Up a Minecraft Server: Paper Installation Guide
Complete Minecraft server setup guide on REXE VDS: Paper/Spigot installation, Java configuration, plugin management, and performance optimization for stable gameplay.
How to Set Up a CS2 Dedicated Server: Complete Guide
Complete CS2 dedicated server setup guide on REXE VDS: SteamCMD installation, GSLT token, server configuration, game modes, and DDoS protection with Path Panel.