FiveM Server Optimization: Complete Performance Guide 2025
 
 To optimize a FiveM server for 32+ players in 2025, enable OneSync Infinity for better player sync, limit active resources to under 150, use optimized ESX/QBCore frameworks, allocate minimum 6GB RAM with 3.5+ GHz CPU, configure sv_maxclients properly, and implement lazy-loading for database queries. These optimizations maintain stable 50ms server timing even with heavy roleplay scripts.
Running a smooth FiveM server with 32+ players requires careful optimization. This guide covers everything from basic setup to advanced performance tuning—helping you achieve stable 50ms server timing even with heavy resource usage.
Why Server Performance Matters
Poor server performance directly impacts player experience:
- ⚠️ High Latency → Players experience lag and delays
- ⚠️ Frame Drops → Stuttering gameplay
- ⚠️ Crashes → Server instability and player loss
- ⚠️ Resource Failures → Scripts stop working correctly
💡 Goal: Maintain server timing under 10ms during normal gameplay, under 50ms during high activity.
Server Requirements by Type
Choose the right resources for your server style:
| Server Type | RAM | CPU | Storage | Players | 
|---|---|---|---|---|
| Minimal RP | 4GB | 2 vCPU | 20GB NVMe | 16-24 | 
| Medium RP | 6GB | 3 vCPU | 30GB NVMe | 24-32 | 
| Heavy RP | 8GB+ | 4+ vCPU | 50GB+ NVMe | 32-48 | 
| Public Server | 12GB+ | 6+ vCPU | 100GB+ NVMe | 48-128 | 
⚠️ Critical: FiveM is CPU-intensive. A fast CPU (high single-core performance) is more important than RAM for most servers.
OneSync Setup & Configuration
What is OneSync?
OneSync allows more than 32 players on your server and improves synchronization efficiency.
OneSync Types:
- Legacy — Basic support, up to 48 players
- Infinity — Advanced support, up to 1024 players (experimental)
Enabling OneSync
Edit your server.cfg:
# Enable OneSync Infinity
set onesync on
# Player slot configuration
sv_maxclients 48
sv_enforceGameBuild 2802
# Performance tweaks
set sv_scriptHookAllowed 0
set sv_enableNetworkedPhoneExplosions false💡 Pro Tip: Start with
sv_maxclientsat your target -4. If you want 48 players, set it to 44 initially and scale up.
Resource Management
Audit Your Resources
Run this command to see resource performance:
resmonWhat to look for:
- ⚠️ Any resource using >10ms consistently
- ⚠️ Resources with high memory usage (>100MB)
- ⚠️ Resources causing frequent warnings
Optimize Heavy Resources
Common Performance Drains:
- 
Vehicle Spawners - Limit spawned vehicles
- Implement cleanup scripts
- Use streaming instead of pre-loading
 
- 
Inventory Systems - Optimize database queries
- Reduce update frequency
- Use client-side caching
 
- 
HUD/UI Resources - Minimize NUI updates
- Reduce draw calls
- Optimize CSS/animations
 
Resource Loading Best Practices
server.cfg order matters! Load resources in this sequence:
# 1. Framework first
ensure es_extended
# or
ensure qb-core
# 2. Core dependencies
ensure oxmysql
ensure pma-voice
# 3. Essential resources
ensure policejob
ensure ambulancejob
# 4. Optional/heavy resources last
ensure realistic_vehicle_failure
ensure custom_hud✅ Best Practice: Group similar resources and use comments to organize your
server.cfgfor easier management.
Database Optimization
MySQL/MariaDB Configuration
Optimize your database for FiveM workloads:
my.cnf/my.ini settings:
[mysqld]
# Connection pool
max_connections = 500
connect_timeout = 10
# Performance Schema (disable for production)
performance_schema = 0
# Buffer pool (set to 50-70% of available RAM)
innodb_buffer_pool_size = 4G
# Log file size
innodb_log_file_size = 512M
# Query cache (if MySQL 5.7)
query_cache_type = 1
query_cache_size = 64M⚠️ Important: Restart MySQL after config changes for them to take effect.
Database Query Optimization
Common Issues:
❌ Bad: Fetching all data then filtering in Lua
-- Don't do this!
local result = MySQL.Sync.fetchAll('SELECT * FROM users')
for i=1, #result do
    if result[i].identifier == playerID then
        -- process
    end
end✅ Good: Filter in the database query
-- Do this instead!
local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier', {
    ['@identifier'] = playerID
})Add Indexes to Frequently Queried Columns
-- Example: Index on commonly searched columns
ALTER TABLE users ADD INDEX idx_identifier (identifier);
ALTER TABLE owned_vehicles ADD INDEX idx_owner (owner);
ALTER TABLE player_inventory ADD INDEX idx_item (item_name);💡 Pro Tip: Use
EXPLAINbefore queries to see if they’re using indexes efficiently.
Server.cfg Optimization
Network Settings
# Reduce entity transmission rate
set onesync_distanceCullVehicles true
set onesync_distanceCullPlayers true
# Rate limiting
set sv_fpsLimit 100
# Network thread priority
set sv_prioritizeNetThread trueMemory Management
# Increase limits for large servers
set sv_filterRequestLimit 1000
# Memory cleanup
set sv_scriptHookAllowed 0Convars for Performance
# Disable unnecessary features
set sv_enableNetworkedSounds false
set sv_enableNetworkedPhoneExplosions false
# Optimize vehicle handling
set onesync_enableInfinity 1
set onesync_enableBeyond true
# Connection optimization
set steam_webApiKey "your_key_here"
set sv_authMaxVariance 1
set sv_authMinTrust 5💡 Pro Tip: Keep a backup of your working
server.cfgbefore making major changes!
Lua Script Optimization
Common Performance Mistakes
❌ Expensive Operations in Loops
Bad:
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0) -- Runs every frame!
        local playerPed = PlayerPedId()
        local coords = GetEntityCoords(playerPed)
        -- Heavy operation every frame
    end
end)Good:
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1000) -- Only once per second
        local playerPed = PlayerPedId()
        local coords = GetEntityCoords(playerPed)
        -- Much better!
    end
end)❌ Not Caching Frequently Used Values
Bad:
-- Calling native every time
if IsPedInAnyVehicle(PlayerPedId(), false) then
    local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
endGood:
-- Cache the values
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) then
    local vehicle = GetVehiclePedIsIn(playerPed, false)
endUse Distance Checks
Only run code for nearby players:
local myCoords = GetEntityCoords(PlayerPedId())
for _, player in ipairs(GetActivePlayers()) do
    local targetPed = GetPlayerPed(player)
    local targetCoords = GetEntityCoords(targetPed)
    local distance = #(myCoords - targetCoords)
    if distance < 50.0 then
        -- Only process nearby players
    end
endResource Streaming
Vehicle Streaming
Instead of loading all vehicles at startup, stream them as needed:
-- Bad: Loading everything
-- data/vehicles.meta with 500+ vehicles
-- Good: Stream on demand
exports['my-garage']:StreamVehicle('adder')Optimize DLC Packs
fxmanifest.lua:
-- Only include what you need
files {
    'stream/vehicles.meta', -- Only vehicle data
    -- 'stream/carvariations.meta', -- Skip if not needed
    -- 'stream/handling.meta', -- Skip if using default
}💡 Pro Tip: Every DLC pack adds to load time. Only include assets you actually use.
Monitoring & Diagnostics
txAdmin Performance Monitoring
txAdmin provides built-in performance monitoring:
- Navigate to txAdmin → Server
- Check Performance Chart
- Monitor:
- Server FPS
- Player count
- CPU/RAM usage
- Warning count
 
Using Profiler
Enable built-in profiler for detailed analysis:
# Add to server.cfg
profiler saveThen check /your-server/cache/ for profiler data.
Key Metrics to Monitor
| Metric | Good | Warning | Critical | 
|---|---|---|---|
| Server Timing | <10ms | 10-30ms | >30ms | 
| FPS | 50+ | 30-50 | <30 | 
| RAM Usage | <70% | 70-85% | >85% | 
| Tick Time | <5ms | 5-15ms | >15ms | 
⚠️ Warning: If server timing consistently exceeds 50ms, your server will feel laggy to players.
Advanced Optimization
Implement Resource Lazy Loading
Load heavy resources only when needed:
-- Load dealership script only near dealership
Citizen.CreateThread(function()
    while true do
        local coords = GetEntityCoords(PlayerPedId())
        local distance = #(coords - vector3(215.0, -810.0, 30.0))
        if distance < 100.0 and not dealershipLoaded then
            TriggerEvent('dealership:load')
            dealershipLoaded = true
        elseif distance > 150.0 and dealershipLoaded then
            TriggerEvent('dealership:unload')
            dealershipLoaded = false
        end
        Citizen.Wait(5000)
    end
end)Optimize Network Events
Reduce network traffic:
❌ Bad: Sending full data every update
-- Sending 1kb every second
Citizen.CreateThread(function()
    while true do
        TriggerServerEvent('updatePosition', GetEntityCoords(PlayerPedId()))
        Citizen.Wait(1000)
    end
end)✅ Good: Only send when changed significantly
local lastCoords = vector3(0,0,0)
Citizen.CreateThread(function()
    while true do
        local newCoords = GetEntityCoords(PlayerPedId())
        local distance = #(lastCoords - newCoords)
        if distance > 50.0 then -- Only if moved 50+ units
            TriggerServerEvent('updatePosition', newCoords)
            lastCoords = newCoords
        end
        Citizen.Wait(5000) -- Check less frequently
    end
end)Common Issues & Fixes
Issue: Server Timing Spikes
Symptoms: Random lag spikes, high ms during peak times
Solutions:
- ✓ Check resmonfor resource timing spikes
- ✓ Disable resources one-by-one to identify culprit
- ✓ Review database slow query log
- ✓ Upgrade CPU if consistently high
Issue: Players Timeout/Disconnect
Symptoms: “Server timed out” errors
Solutions:
- ✓ Increase connection timeout in server.cfg:set sv_timeout 120
- ✓ Check network stability
- ✓ Verify OneSync is configured correctly
- ✓ Review firewall rules
Issue: High Memory Usage
Symptoms: Server RAM usage exceeds 90%
Solutions:
- ✓ Implement resource cleanup scripts
- ✓ Remove unused vehicle spawns
- ✓ Clear old database entries
- ✓ Restart server daily during low-traffic hours
- ✓ Upgrade RAM if legitimately needed
Performance Checklist
Before going live, verify:
Server Configuration:
- OneSync enabled and configured
-  sv_maxclientsset appropriately
- Resource load order optimized
- Unnecessary convars disabled
Resources:
-  All resources under 10ms in resmon
- No resource warnings at startup
- DLC packs optimized
- Streaming configured for heavy assets
Database:
- Indexes added to frequent queries
- MySQL optimized for FiveM
- Slow query log reviewed
- Regular backups scheduled
Monitoring:
- txAdmin performance charts enabled
- Alert thresholds configured
- Profiler data reviewed
- Server restart schedule set
💬 Need Help?
Our FiveM specialists are available 24/7 to help optimize your server:
- 💬 Discord — Get expert FiveM support instantly
- 🎫 Ticket System — Submit detailed performance reports
- 🔴 Live Chat — Real-time optimization assistance
🚀 Performance Boost: Our team can audit your server and provide custom optimization recommendations.
Ready for lag-free FiveM hosting?
View our FiveM server plans or request a performance audit from our team.
Last updated: September 22, 2025
 
   
  