Performance and operating limits ​
The handler reduces duplicate vehicle lifecycle loops by centralizing records and using a spatial grid for persistent streamed vehicles. Its spatial grid is partitioned by routing bucket and each occupied cell is visited once per pass even when players overlap. Default passes run every 1.5 seconds, examine at most 256 record candidates, create at most four vehicles and review at most eight active vehicles for despawn. Fair cursors preserve progress when a cap is reached, with separate spawn and despawn radii.
These are implementation defaults, not benchmark results. No live FiveM server performance measurements are claimed here. Measure on your own artifact, population, routing buckets and vehicle counts before changing the caps.
Practical tuning ​
- Keep the streaming radius close to the use area and the despawn radius larger to reduce churn near the boundary.
- Increase per-pass caps if large player movement causes visible spawn delays; watch server hitches and entity creation load.
- Use persistent streamed records for parked vehicles that do not need to exist far from players.
- Keep snapshot size and depth limits bounded. Large custom state blobs increase network and database cost.
- The independent snapshot scheduler grows its per-pass budget from
maxPerTicktoward the configured interval, up tomaxAdaptivePerTick. With default settings its scheduling capacity is 1,280 active records per 30 seconds. Above that population the cap extends the sweep; debug logging reports overload. Capture failures, owner response time and database latency can extend actual durability freshness. - Ownerless periodic transform saves use at most four asynchronous workers by default. Tune
maxConcurrentFallbackSavesto the database capacity. - Use a stable routing bucket for each vehicle and avoid unnecessary definition re-registration.
Reduced recurring work ​
Unchanged saves issue no SQL and reuse serialized property/state values. Changed saves update dirty columns rather than rewriting the whole row. Successful owner captures avoid redundant stream-out saves unless the transform moved afterward. Per-ID FIFO write serialization keeps removal durable.
Repeated requests for the same owner, generation and revision share a snapshot token. Explicit capture callers retain independent timeouts and receive the durable result. Client initialization uses cached state-bag payloads and lightweight wake events; a separate hydration marker avoids full payload replication for readiness acknowledgements. Out-of-scope caches expire after 60 seconds.
VIN and attachment reverse indexes avoid whole-record scans. Free-spot searches read world vehicle positions once per call, including unmanaged blockers. Optional keys integrations use a bounded retry queue only while the keys resource runs.
The repository includes tests/streaming_performance.lua, persistence regressions within tests/server_core.lua, and tests/streaming_benchmark.lua. The benchmark is a mocked Lua workload, not a live FiveM timing claim.
Limits to verify live ​
- Server vehicle creation and setter behavior can vary by artifact and model type.
- Entity state bags and owner migration must be checked with OneSync enabled.
- The server cannot read all vehicle tuning fields; supported properties are applied from a bounded client snapshot.
- Tuning changes are not observed at every native change; snapshots occur after driver exit, periodically for persistent active vehicles, or when a server resource explicitly requests one.
- Optional exports and key/fuel/tuning integrations must be tested with the versions you run.
Capture server and client profiles during dense parking, player movement, owner migration and restart recovery. Start with profiler record 500, then profiler view or profiler saveJSON filename.json; see the Cfx profiler guide. Compare script CPU, database writes/latency, snapshot age and network traffic using your actual population and tuning payloads.