Перейти к основному содержимому
Вернуться в категорию

Оптимизация производительности сервера FiveM

Руководство по оптимизации производительности сервера FiveM. Управление ресурсами, OneSync, оптимизация базы данных.

Время чтения: 15 dk Настройка игровых серверов
fivemonesyncпроизводительностьресурсбаза данныхgta vоптимизация

Содержание

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

Resource32 Slots64 Slots128+ Slots
CPU4 Cores6+ Cores8+ Cores
RAM8 GB16 GB32+ GB
Disk50 GB SSD100 GB NVMe200+ GB NVMe
Network50 Mbps100 Mbps200+ Mbps

OneSync Configuration

OneSync is FiveM's advanced synchronization system required for high player counts.

server.cfg

hljs 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

ModeDescriptionPlayer Limit
offOneSync disabled32
onStandard OneSync64
on + InfinityAdvanced sync128+
on + BeyondLong-range sync2048

Resource Management

Resource Performance Analysis

hljs cfg
set sv_resourceMonitor true
set sv_resourceMonitorInterval 5000

From server console:

resmon 1

Resource Optimization Tips

  1. Remove unnecessary resources: Disable unused scripts
  2. Thread usage: Optimize heavy operations with Citizen.Wait instead of Citizen.Wait(0)
  3. Event optimization: Reduce unnecessary network events
  4. Native calls: Cache frequently used natives

Optimization Example

hljs lua
-- 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

hljs ini
[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

hljs cfg
set mysql_connection_string "mysql://user:password@localhost/fivem?charset=utf8mb4&connectionLimit=50"

Query Optimization

hljs lua
-- 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

hljs cfg
set sv_streamingMemoryLimit 2048

Network Optimization

hljs cfg
set net_statsFile "netstats.log"
set sv_endpointPrivacy true
set rateLimiter_stateBagFlood_rate 75
set rateLimiter_stateBagFlood_burst 150

Port Configuration

PortProtocolUsage
30120TCP + UDPFiveM game port
40120TCPtxAdmin web panel

Firewall Rules

hljs bash
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:

hljs bash
# txAdmin comes bundled with FiveM
# Web panel: http://SERVER_IP:40120

Performance Monitoring

hljs cfg
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.