Out of the box, the GDK for Unreal has a single Unreal server-worker instance. However, you can set up your Unreal project to split the computation done by that single server-worker instance across multiple server-worker instances.
There are two ways to do this - offloading and zoning:
- Offloading distributes computational load over the game world by defining a set of server-worker types. Instances of these types compute one set of Actor types across the game world.
- Zoning splits the world into grid-based areas of authority, with a different server-worker instance responsible for each area.
Zoning is currently in preview and not available for use in the GDK for Unreal. This documentation describes offloading only.
With offloading, CPU-intensive game systems that struggle with multithreading in Unreal’s native architecture are no longer limited by the processing power of a single server. You can offload computationally expensive but latency-tolerant functionality, such as AI decision-making, onto a separate, dedicated server-worker instance. This leaves your main server-worker instance free to compute other game systems at a larger scale.
To offload to additional server-worker instances, you must set up one or more load balancing strategies to control your server-workers. Each load balancing strategy you set up uses the same Unreal server-worker executable that you get out of the box. After you have set up offloading, when your game deployment starts up, the SpatialOS Runtime spins up as many instances of the server-worker type(s) as you specified during setup.
Offloading: Offloaded Unreal server-worker instance has authority only over Red Actors and the Main Unreal server-worker instance that runs major game systems has authority over all Actors except the Red Actors.
Offloading increases CPU resources at the cost of bandwidth. If you want more interaction between the offloaded server-worker instance and the main server-worker instance, the cost of bandwidth and the CPU consumption on communication between them increase. Therefore, when you design your game feature using offloading, you need to carefully consider the information flow between servers.
Before you offload Actors, consider the following scenarios:
IsServer()function returns true for both the main Unreal server-worker instance and all offloaded instances, to ensure that the logic is called only on an instance that has authority over an Actor, take one of the following options:
- Use the deprecated functions defined in Actor group ownership helpers.
Same as above
Server RPCs follow similar logic to the single-server model.
- When sent from clients: if a client net-owns an Actor and invokes a server RPC, it sends that RPC to the server-worker instance that has authority, which can be either the main Unreal server-worker instance or the offloaded server-worker instance.
- When sent from an offloaded server-worker instance: server RPCs invoked by an offloaded worker run only on that offloaded server-worker instance. However, if you want server RPCs to run on another server-worker instance you should use Cross-server RPCs.
SpawnActoron a server-worker instance that doesn't have authority over the spawned Actor
You might want to spawn an Actor from a server-worker instance that shouldn’t have authority over the Actor. For example, an offloaded AI might drop items that the main Unreal server-worker instance should have authority over.
This might cause issues when the initialization logic in the calls such as
PostInitializeComponentis executed on the wrong server-worker instance. You can usually work around these issues using callbacks /
RepNotifys on the main Unreal server-worker instance. This defers execution until the correct server-worker instance has authority over the offloaded Actor.
2020-06-19 Page updated with editorial review: updating for new offloading implementation
2020-04-16 Page updated with editorial review: added introductory text about offloading
2019-08-08 Page updated with editorial review: updated first part of overview
2019-07-26 Page added with limited editorial review
Updated 4 months ago