This is a creation in Article, where the information may have evolved or changed.
Goworld is a scalable distributed game server engine that is implemented using Golang and supports hot-update of game logic.
Goworld Code: Https://github.com/xiaonanln/goworld
Process structure
Goworld Frame composition
A goworld system consists of a dispatcher process, one or more game processes, and one or more gate processes. Dispatcher is responsible for message forwarding between game and gate and game, and provides support for some basic functions. The game process is responsible for managing the entity objects and running all game logic, and the gate process is responsible for managing client connections and forwarding client requests through dispatcher to the game process. Gate also needs to be responsible for compressing and decrypting the client data (not yet implemented). Goworld can increase the load capacity of the server by adding more game processes or gate processes. Although the dispatcher process is a single point in the Goworld server, preliminary testing and projections indicate that running dispatcher on a multicore high-performance host can support more than 1 million of simultaneous online.
Hot update
Goworld uses hot-swappaing to implement hot updates to game logic. When the game process receives the SIGUSR1 signal, it saves all current entity and other related states to a file and ends the process. You can then restart the game process with the latest executable image and restore all the entity and game states from the saved file and resume execution. During the hot update process, the player client's connection will not be interrupted, the player's role status will remain unchanged, but will feel a bit of lag, and recovery after the end of the hot update.
Entity architecture
Entity RPC
In Goworld, we use an entity to represent objects such as players, monsters, and NPCs in the game scene. Goworld also supports RPC traffic from the client to the server, as well as RPC traffic between the server-side entity.
Goworld uses the Messagepack format for packet and parsing of RPC data and will support Google Protobuf in the future.
Scene
The scene (Space) is a very important concept in Goworld. Each entity belongs to a scene. Each function can be called directly between the entity of the same scene, and RPC is used to communicate between the entity across the scene. Entity can jump to another scene through the migration (Migrate) function, and all of the attribute data of the entity will remain unchanged after jumping to the scene.
AOI
Goworld provides a simplified set of AOI mechanisms. A neighbor list is maintained between the entity and the scene based on distance. Goworld uses a cross-list to maintain all the entity in the scene, thus updating the AOI information of all the entity in real time based on the position change of the entity.
Property synchronization
Goworld provides an attribute mechanism for entity. Attributes are divided into server-side properties, client properties, and global properties. Service-side properties are accessible only on the server side, and client properties can be accessed concurrently on both the client and the server side. Each time the server modifies it, the change in properties is immediately synchronized to the client, keeping the client data updated in real time. Global properties are data that is visible to all entity, including other players. Global properties are broadcast to all players in the Aoi range when they change, allowing the player to get real-time property changes for other entity within the Aoi range.
Entity disk and load
Goworld supports the automatic filing of entity. Persistent (persistent) entity is saved at a certain time interval. Goworld also provides the ability to load the saved entity. Currently Goworld supports two different underlying databases for MongoDB and Redis.
Client connectivity and communication
Each server creates a listening port to receive connections from the client. A RPC communication is also used between the client and the server. The client can initiate an RPC call to the player and other entity in the player's Aoi.
Goworld supports the compression of client communication. The encryption feature has yet to be added ...
Also in the development phase, more content to be supplemented, please pay attention to ...