Server Optimization

How to Optimize Your FiveM Server Performance: Complete 2026 Guide

By oxince | Web-Services Team12 min read

Is your FiveM server experiencing lag, high ping, or poor performance? You're not alone. With the right optimization techniques, you can achieve stable 50ms server timing even with 64+ players and heavy roleplay scripts.

This comprehensive guide covers everything from hardware requirements to advanced script optimization, ensuring your players enjoy a smooth, professional gaming experience.

Why Server Optimization Matters

Player Retention & Revenue

The brutal truth:

  • 78% of players leave servers with consistent lag
  • Poor performance = negative reviews on server lists
  • Optimized servers support more players = more revenue potential
  • Every 10ms improvement in server timing = 5% retention boost

The goal: Maintain server tick time below 6ms at peak load (64 players).

1. Hardware Requirements (2026 Standards)

Minimum Specifications for 32 Players

CPU: Intel i5-11400 / AMD Ryzen 5 5600X
     (6 cores, 12 threads, 3.5+ GHz base clock)
RAM: 16GB DDR4 3200MHz
Storage: 250GB NVMe SSD Gen 3 (read 3500 MB/s)
Network: 100 Mbps symmetric (upload = download)
OS: Ubuntu 22.04 LTS / Windows Server 2022

Expected performance: 40-50ms server timing with 30 scripts

Recommended for 64+ Players

CPU: AMD Ryzen 7 7800X3D / Intel i7-13700K
     (Single-thread optimized, 4.5+ GHz boost)
RAM: 64GB DDR5 6000 CL30
Storage: 1TB NVMe Gen 4 SSD (read 7000+ MB/s)
Network: 1 Gbps dedicated connection
OS: Ubuntu 22.04 LTS (better performance than Windows)

Expected performance: 30-40ms server timing with 50+ scripts

Why These Specs Matter

CPU - Single-Thread Performance is King:

  • FiveM is predominantly single-threaded
  • High clock speed (GHz) > Core count
  • AMD X3D cache technology provides 15-20% boost
  • Intel 13th/14th gen offers excellent single-thread performance

RAM - Prevent Page Faults:

  • Heavy mod/script loads consume 8-12GB base
  • Map streaming requires additional 4-8GB
  • Fast RAM (6000MHz+) provides 5-8% performance gain

Storage - Fast SSDs Reduce Load Times:

  • NVMe Gen 4 reduces map streaming by 60%
  • Players connect 40% faster
  • Database queries speed up 30%
  • Server restarts take half the time

2. Server.cfg Optimization

Your server.cfg file controls core performance. Here's the optimized 2026 configuration:

# ====================================
# ESSENTIAL PERFORMANCE SETTINGS
# ====================================

# OneSync - MANDATORY for 32+ slots
onesync on

# Player slots (adjust based on hardware)
sv_maxclients 64

# Network bandwidth per client
sv_maxrate 65000        # ~520 kbps per player
sv_minrate 25000        # Minimum bandwidth

# Connection quality enforcement
sv_packetLoss 0.05      # Disconnect at 5% sustained loss
sv_timeout 60           # Timeout after 60 seconds

# Enhanced FXServer features (experimental)
set sv_enhancedDriver true
set sv_enhancedHostSupport true

# ====================================
# DATABASE CONFIGURATION
# ====================================

set mysql_connection_string "mysql://user:password@localhost/database?charset=utf8mb4&maxConnections=10"
set mysql_slow_query_warning 100  # Alert queries >100ms

Critical Settings Explained

onesync on:

  • Enables 32+ player support
  • Improves entity synchronization by 70%
  • Required for modern frameworks (QBCore, ox_lib)
  • Never run without OneSync in 2026

sv_maxrate 65000:

  • Controls bandwidth per player (bytes/second)
  • Too low = poor sync quality
  • Too high = bandwidth waste
  • Sweet spot: 50,000-70,000

3. Script Optimization Strategies

Identify Performance Drains

Use the built-in resmon command in your server console:

resmon 1

What to look for:

  • Any resource showing >1ms idle time (optimization needed)
  • Database queries taking >50ms (index problem)
  • Client-side scripts with excessive draw calls

Top 10 Performance Killers

Script Type Problem Solution Impact
Vehicle Spawners Pre-loading all 500+ vehicles Stream on-demand + cleanup -4ms
Inventory Systems Constant database writes Client caching + batch writes -2ms
HUD/UI Resources 60 FPS NUI updates Reduce to 4 FPS (250ms interval) -1.5ms
Legacy MySQL Scripts Synchronous queries Switch to oxmysql async -3ms
Map/MLO Packs Unoptimized textures Compress to DXT format -2ms

Total potential savings: 16.4ms → Massive performance gain

Script Optimization Checklist

  • Switch to oxmysql for all database operations
  • Remove unused resources – trim server.cfg to essentials
  • Limit total resources to under 150 active
  • Use optimized frameworks (QBCore > ESX in 2026)
  • Enable lazy-loading for database queries
  • Implement proper cleanup for spawned entities
  • Reduce thread intervals (250ms minimum for most loops)
  • Cache frequently accessed data in Lua tables

Golden rule: Every script you add increases server load. Ask: "Do I REALLY need this?"

4. Database Optimization (Critical)

Your MySQL database can become a major bottleneck. Here's how to fix it:

Add Indexes to Frequently Queried Columns

Indexes speed up SELECT queries by 100-1000x:

-- Check current indexes
SHOW INDEX FROM users;

-- Add indexes for common queries
ALTER TABLE users ADD INDEX idx_identifier (identifier);
ALTER TABLE users ADD INDEX idx_license (license);
ALTER TABLE owned_vehicles ADD INDEX idx_owner (owner);
ALTER TABLE owned_vehicles ADD INDEX idx_plate (plate);

-- Check query performance (should use index)
EXPLAIN SELECT * FROM users WHERE identifier = 'steam:xxxxx';

Result: Queries drop from 200ms to <10ms with proper indexes.

Use Connection Pooling

In your oxmysql configuration:

set mysql_connection_string "mysql://user:pass@localhost/db?charset=utf8mb4&maxConnections=10"

maxConnections = 10:

  • Reuses database connections instead of creating new ones
  • Reduces connection overhead by 80%
  • Prevents "too many connections" errors

Cache Immutable Data

Don't query the database for data that never changes:

-- ❌ BAD: Query DB every time (200ms per call)
local vehicleName = MySQL.Sync.fetchScalar('SELECT name FROM vehicles WHERE model = ?', {model})

-- ✅ GOOD: Cache in Lua table (0.001ms per call)
local VehicleNames = {
    ["adder"] = "Truffade Adder",
    ["t20"] = "Progen T20",
    ["turismor"] = "Grotti Turismo R"
}
local vehicleName = VehicleNames[model]

Impact: 200,000x faster lookups 🚀

5. Network & Connection Optimization

Use Anti-DDoS Protection

Protect your server from attacks:

Option 1: OVH Game DDoS Protection

  • 480 Gbps protection capacity
  • Automatic mitigation
  • €50-150/month extra

Option 2: Cloudflare Spectrum

  • Enterprise-level protection
  • Requires business plan
  • €200+/month

Option 3: TCPShield (Affordable)

  • FiveM-specific protection
  • $10-30/month
  • Easy setup

6. Asset Optimization (Maps, Vehicles, MLOs)

Texture Optimization

Problem: Uncompressed textures use 10x more VRAM

Solution:

  • Convert textures to DXT format
  • Target size: <16MB per file
  • Use DXT1 for opaque textures (smaller)
  • Use DXT5 only when transparency needed

Result: 60% reduction in VRAM usage

Audio Optimization

# Resample audio to game-quality
ffmpeg -i input.mp3 -ar 48000 -ac 1 -b:a 128k output.mp3

# Explanation:
# -ar 48000    = 48kHz sample rate (game standard)
# -ac 1        = Mono (stereo not needed for game sounds)
# -b:a 128k    = 128 kbps bitrate (sufficient quality)

Rule: 48kHz mono is sufficient for 99% of game audio

7. Performance Benchmarks

Target Metrics for 2026:

Metric Poor Average Good Excellent
Server Tick (64 players) >10ms 6-10ms 3-6ms <3ms
Idle Resource Time >1ms 0.5-1ms 0.1-0.5ms <0.1ms
Database Query Time >100ms 50-100ms 10-50ms <10ms
Player Connect Time >60s 30-60s 15-30s <15s

Real-World Examples:

❌ Before Optimization:

  • 32 players = 12ms server tick
  • 150 active resources
  • MySQL-Async with no indexes
  • Unoptimized textures
  • Result: Frequent lag, players complaining

✅ After Optimization:

  • 64 players = 4ms server tick
  • 85 active resources (removed bloat)
  • oxmysql with proper indexes
  • Compressed textures
  • Result: Smooth gameplay, 5-star reviews

Performance Optimization Checklist

Before going live, verify:

Hardware:

  • ☐ CPU has high single-thread performance (4.0+ GHz)
  • ☐ Minimum 16GB RAM (64GB for 64+ players)
  • ☐ NVMe SSD Gen 3 or better
  • ☐ 100+ Mbps symmetric internet

Software:

  • ☐ OneSync Infinity enabled
  • ☐ oxmysql installed and configured
  • ☐ Latest FXServer artifact build
  • ☐ Ubuntu 22.04 LTS (or Windows Server 2022)

Scripts:

  • ☐ All resources showing <1ms in resmon
  • ☐ No legacy MySQL-Async scripts
  • ☐ Inactive resources removed
  • ☐ Total resources under 150

Testing:

  • ☐ Server tick time <6ms at peak load
  • ☐ 2x capacity stress test passed
  • ☐ No memory leaks after 4+ hours
  • ☐ Player feedback positive (no lag reports)

Conclusion: Achieve 50ms Server Timing

By implementing these optimization techniques, you'll achieve:

  • Stable 50ms server timing with 64+ players
  • Sub-6ms tick time at peak load
  • 40-60% performance improvement over unoptimized servers
  • Better player retention due to smooth gameplay
  • Scalability for server growth

Remember: Optimization is an ongoing process. Monitor performance weekly, update scripts regularly, and always test changes in a staging environment before pushing to production.

Next Steps

  1. Audit your current server using this guide's benchmarks
  2. Implement quick wins (oxmysql, remove unused scripts)
  3. Database optimization (add indexes, connection pooling)
  4. Monitor for 1 week and track improvements
  5. Gradually optimize scripts based on resmon data

Need expert help? Our team specializes in FiveM performance tuning and can achieve 30-50% improvements in just 24 hours.

📊 Request Performance Audit

Professional FiveM server optimization • 30-50% improvement guaranteed

Contact Us →

Related Guides

WEBSERVICES
#1 FIVEM SERVICE
Home
Scripts
Blog
Search
Login

FAQ

Where can I get help with the setup or with questions?

You can get help with questions or setting up the products on our Discord (discord.gg/webservices).

How can I download the product I have just purchased?

You can download the script you have just purchased from your Keymaster account as usual and then use it on your server.

Is it possible to get a refund?

Unfortunately, a refund is not possible.

How do I access your control panel?

You can access our control panel via the following link: control-panel.ws

All rights reserved. 2021-2026 © WS Shop
Terms
Privacy
Impressum
Designed by: Mattiwe Design
Loading...