Skip to content
GTA666
advanced10 min readUpdated 2026-09-09

Performance, Security and Backups

Server tick, resource optimisation, event security, DDoS, secrets management and backups — keeping a roleplay server fast, safe and recoverable.

Quick answer

Performance problems are almost always one or two badly written resources, so measure before you optimise. Security is mostly one rule: never trust the client. Cfx.re's own guidance is to validate everything server-side and use RegisterNetEvent only for genuinely cross-context events. And a server without a tested restore is a server with no backups.

This chapter is three jobs that share one habit: measure, do not guess. It uses the FiveM/GTA V stack, the working model for this track, since GTA 6 private-server support has not been announced.

Performance: find the culprit, don’t tune blindly

A roleplay server’s main loop is largely one busy thread, which means one badly written resource can degrade the experience for everyone. The good news is that the offender is almost always identifiable.

Measure first. Use the server’s resource monitor at your busiest hour and sort by time consumed. In nearly every case, two or three resources account for most of it. Fix those and stop; everything else is noise.

The recurring causes, in rough order of frequency:

  • Loops running every frame that only need to run every few seconds. A wait of zero in a client script is the classic.
  • Distance checks against every player or entity, every tick, instead of against a nearby set.
  • Database queries in a hot path, or on a table with no index. A single unindexed lookup on join can stall the whole server.
  • Too many streamed assets. Big vehicle and MLO packs cost memory and make joins slow.
  • Resources that never sleep — a script polling for something that could be event-driven.

Two more things worth doing:

Scheduled restarts. Long uptimes accumulate leaks and orphaned entities. Most servers restart every 6–12 hours with warnings; txAdmin handles the scheduling and the announcements.

Size against measurement, not marketing. Cfx.re publishes no official server hardware specification, so every spec table you find belongs to a hosting company. Watch your own CPU and memory under load and buy against that — see choose your hosting.

Security: never trust the client

Cfx.re’s Secure Your Events page is the most important document in this chapter, and its premise is blunt: cheats can allow the client to trigger events in any context. Everything follows from that.

Use the right event registration. Their guidance: use AddEventHandler when an event is only meant to be triggered within the same context — client-to-client or server-to-server — and RegisterNetEvent only when it genuinely needs to cross that boundary. Registering a net event makes it callable by any client, including a cheater’s.

Validate on the server, always. The docs call out validating inventory and items, position, permissions and roles, and state bags, and put it plainly: directly adding items to the user from their own input is always bad practice — always validate user input.

In practice, on a roleplay server, that means:

  • The server decides whether a player is near the shop, has the money, and owns the item. Never the client.
  • The server checks the job and grade before an action, on every action.
  • Prices, payouts and quantities come from server-side config, never from the event payload.
  • Sanity-check positions: a player who moved 600 metres in a second did not.

Keep sv_scriptHookAllowed false. The server commands reference documents it as defaulting to false, and enabling it lets Script Hook V clients connect. There is essentially no reason for a roleplay server to turn it on.

Understand what OneSync does and does not give you. OneSync is a synchronisation system, not an anti-cheat. What it does offer is server-authoritative sync plus routing-bucket lockdown modes, where strict blocks client-side entity creation entirely and relaxed blocks client-created script entities. Use those. But a server whose scripts trust client input is exploitable no matter what the sync layer does.

Anti-cheat tooling is worth having, and worth keeping in perspective. It raises the effort required, catches the lazy majority, and never replaces secure scripting. Pair it with the logging described in staff and moderation, because most exploits are caught by someone noticing impossible wealth — which is also why the money supply metrics in economy and jobs design are a security control as much as an economic one.

Network exposure

Reduce your attack surface to what has to be public.

Cfx.re’s proxy setup guide covers running a standard HTTPS reverse proxy in front of the server on port 443, with sv_proxyIPRanges listing the CIDR ranges allowed to set X-Real-IP and bypass the rate limiter, and sv_forceIndirectListing to stop the server advertising its direct IP. It also advises firewalling the non-proxied ports from external access.

Alongside that:

  • Firewall everything except the game port and your administrative access.
  • Never expose MySQL to the internet. Bind it to localhost or a private network.
  • Put txAdmin’s panel behind a proxy with TLS, and do not leave it open to the world on its default port.
  • Keep DDoS protection on, and confirm it covers UDP game traffic, not just your website.

Secrets

Your licence key, database password, Discord bot token, Tebex secret and any API keys are the keys to the server.

  • Keep them in a separate config file that your main server.cfg includes, and keep that file out of version control.
  • Never paste a config into Discord or a support ticket without redacting it. Licence keys leak this way constantly.
  • Rotate anything an ex-staff member could have seen — part of the monthly audit in staff and moderation.
  • Use named database accounts rather than one shared root login, so access can be revoked individually.

Backups

Your database is the server. Everything else can be rebuilt in an afternoon.

Checklist

  • Automated daily database dumps, minimum.
  • Stored off the machine — a failed host is the case backups exist for.
  • Several days of history, so a corruption discovered on Wednesday is still recoverable.
  • Resources and configs in version control, with secrets excluded.
  • A documented restore procedure someone other than you could follow.
  • A test restore every month, into a spare server. This is the step everyone skips and the only one that proves the rest work.
  • Backups taken before every artifact update, framework update, and economy change.

The pattern that ends servers is dull and preventable: a bad update or a bad actor, a backup nobody had checked, and a database that turns out to be six weeks stale. Ten minutes a month prevents it.

With the server fast, safe and recoverable, the last two questions are how to pay for it and how to fill it: monetisation within the rules.

Takeaways
  • Measure with the resource monitor before changing anything — the culprit is usually one resource
  • Never trust the client: validate items, money, positions and permissions server-side
  • Use AddEventHandler for same-context events; RegisterNetEvent exposes an event to clients
  • Keep sv_scriptHookAllowed false — Cfx.re's default, and for good reason
  • An untested backup is not a backup; restore one before you need it

Frequently asked

Why does my server lag with only 30 players?

Almost never the player count. It is usually a resource running expensive work every frame, an unindexed database query in a hot path, or a script looping over every entity. Open the resource monitor at peak, sort by time, and look at the top three.

Is OneSync an anti-cheat?

No, and it is worth being precise. OneSync is Cfx.re's synchronisation system; what it gives you security-wise is server-authoritative sync plus routing-bucket lockdown modes, where strict blocks all client-side entity creation. Real anti-cheat is separate, and secure scripting matters more than either.

How often should I back up?

The database, at least daily, kept off the machine, with several days of history. Your resources and configs belong in version control. Then restore one into a test server every month — most backup systems are discovered to be broken at the exact moment they are needed.

Sources
  1. Secure Your Events · Cfx.re
  2. Server Commands · Cfx.re
  3. Proxy Setup · Cfx.re
  4. OneSync · Cfx.re
Day-one whitelist

Get recruited when GTA 6 private servers open.