Skip to content

A High-Performance, Highly Available demo TCP/UDP Game Server enabled with Cgo.

License

Notifications You must be signed in to change notification settings

wanliqun/cgo-game-server

Repository files navigation

cgo-game-server

This is a demo project showcasing a high-performance TCP/UDP game server built with Go and cgo. It includes a server, simulator, and stress testing tool for development and evaluation. It also provides a RESTful service that exposes two RPC methods to view the server status and metrics.

Quick Start

Clone the Repository

git clone --recurse-submodules https://github.com/wanliqun/cgo-game-server.git

This downloads the required submodule ( C++ Random Name Generator ) automatically.

Build the C++ Library (cgo)

Requirements:

  • automake
  • clang++
make cgo

This generates a .so dynamic link library used by cgo.

Run the Application:

Install Go (v1.21+) and edit the configuration file (config/config.yml) for customization, then run:

go run main.go --help

This displays usage instructions and available commands.

  • Start Server (TCP, UDP, RESTful):
go run main.go server
  • Start Simulator (client for debugging):
go run main.go simulator
  • Stress Testing:

Establish Mass Connections and Measure TPS:

go run main.go loadrunner -w 100 -r 100 -d 1h

-w: Number of concurrent workers (go-routines) -r: Robots (clients) allocated per worker -d: Duration of the test

Metrics

cgo-game-server starts a RESTful service which provides two RPC methods to view the server status and metrics. eg., You can open the following URL in a web browser to check the server running statistics if you are running as predefined configurations:

Acknowledgement

The following projects are referenced:

About

A High-Performance, Highly Available demo TCP/UDP Game Server enabled with Cgo.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published