Sunday, September 25, 2016

New Project: Chimera

Introduction

Chimera is a Conquer Online private server project written in Go. Roughly half a decade ago when I first began programming in a managed language, I grossly underestimated the requirements for developing such a project. I was unprepared for developing a server which could meet the performance requirements of my planned systems. Half a decade later, I look back at my old prototypes and miss the development scene. I have challenged myself again with the same goals for developing a high-performance Conquer Online server, though a lot as changed in regards to my design and choice in technology.

Architecture

The primary objective of Chimera is to create a distributed system of servers which service the Conquer Online game client. These servers are configurable to service a section of maps, and cluster together to encapsulate the game world. Below is a basic description of these server projects.

  • Account Server: Authenticates connections and exposes a private interface for authentication in the game server project.
  • Game Server: Routes players between regions and conducts synchronization with map servers; processes world events.
  • Map Servers: Encapsulates a region of the game world and processes map and player actions.

Map servers cache changes to the world. When players exceed a calculated threshold for substantial character improvement, their changes are synchronized with the game server as a synchronization event. Other actions may also trigger a synchronization event. The goal in implementing this design is to minimize the overhead and requirement for larger synchronization periods and to minimize network stress and hits on the database. A side-effect of this architecture is that map servers may be migrated seamlessly to newer builds while continuing to serve players.

Packet Structuring

Another focus in Chimera is the scalability of internal systems, such as the server's packet structuring and processing procedures. To reduce development costs and time associated with defining procedures for reading and writing packets, I analyzed a sample of all known packet structures and constructed byte ordering rules for packet encoding. In combination with Go's powerful reflection features, these rules allow binary buffers to be generically converted to data structures, supporting recursive data types, collections, etc. Below is an example of this work in action.

Binary packet with header and payload:
00000000  1e 00 f7 03 28 13 00 00  15 03 02 47 6f 07 43 6f  |....(......Go.Co|
00000010  6e 71 75 65 72 07 59 6f  75 72 73 65 6c           |nquer.Chimera|

This packet can be represented by this simple structure in Go:
type MsgName struct { 
PacketHeader
Identity uint32
Action   byte
Strings  []string
}

And decoded using the following call:
err := packets.Read(buffer, packet)

Traditionally, I would be required to handle byte prefixed string lengths and reading in strings dynamically using custom byte ordering rules, but a system like this allows the me to simplify this process and improve the organization of the project.

Portability

Having a portable server architecture means easier deployment, reduced costs in maintaining system software / dependencies, and simplified requirements for selecting a host. Since Go is self-contained and cross platform, it can run on any operating system and architecture supported by Go; for example, across an array of ARM Raspberry Pis running Linux or Plan9. In addition to portability, Go offers Chimera a small and efficient runtime, compiled into the executable. The efficiency of this managed runtime and the Go garbage collector allows Chimera to be launched across low-resource systems, further adding to the flexibility of the distributed system.

Conclusion

I'll be updating this blog as I continue development. If you have questions, please don't hesitate to ask or make conversation; however, bashing on the Go language will not be welcomed criticism. There is no benefit to starting argumentation on language preference. All other feedback and criticism are welcome. To the question of "will this project be abandoned", there's always that possibility as I do attend school full-time and work part-time. Do I have intentions on abandoning it? No. My aim is to develop a server which is openly available. Thanks again for your interest and support.