zinx is a free, open source gaming project written in Go and released under MIT. It has 7,764 GitHub stars, 1,262 forks and 96 open issues, and was last pushed 3 months ago. On this registry it ranks #10 of 12 tracked projects in Gaming, with 5 head-to-head comparisons available.

What is zinx?

Zinx is a lightweight concurrent server framework written in Go, aimed at developers who want a small, readable TCP server skeleton they can study and customise rather than adopt a large opaque application framework.

What it is

Zinx is a lightweight concurrent server framework based on Golang, distributed as the Go module github.com/aceld/zinx under the MIT licence. It lives in the Go ecosystem alongside the language's other server libraries, and its stated design goal is to provide a complete outline of how to write a TCP server in Go so that developers can understand the internal details of a server framework and extend it for their own enterprise scenarios.

The concrete problem it solves is the gap the project itself names: although many Go server frameworks exist, few lightweight enterprise frameworks target gaming and other long-linked fields. Zinx replaces the option of hand-rolling a TCP server skeleton or pulling in a heavier application framework when the requirement is a long-lived connection, a message-ID routing layer, and a codebase small enough to read end to end. Its development is deliberately synchronised with an accompanying tutorial series, with each version adding a small increment of functionality rather than presenting a finished framework all at once.

Key capabilities

  • TCP long-connection server handling, reflected in the tcp-server and game-server topics and in the framework's focus on long-linked fields.
  • Message-ID routing: routers embed znet.BaseRouter and implement Handle(request ziface.IRequest), with handlers reading request.GetMsgID() and request.GetData().
  • Server bootstrap through a single constructor call, znet.NewServer(), shown in the README's Zinx-Server example.
  • Interface-driven extension points, including ziface.IRequest for request access and znet for concrete implementations.
  • Installation as a standard Go module via go get github.com/aceld/zinx, with a documented requirement of Golang Version 1.17 or newer.
  • Distributed source mirrors on GitHub, Gitcode, and Gitee, plus a project site at zinx.me.
  • Documentation and learning material across the GitHub wiki, a Yuque book, a dev.to tutorial, and video walkthroughs on BiliBili, Douyin, and YouTube.

Who uses it and how

  • Enterprises use Zinx for message forwarding between backend modules, where a lightweight concurrent server is enough and a full application framework is not.
  • Teams building long-linked game servers use it as the connection and message-handling layer for persistent client sessions.
  • Developers writing message handling plugins for existing web frameworks use Zinx as the long-connection component alongside a conventional HTTP stack.
  • Learners follow the version-by-version tutorial series, reading the framework internals in the order the increments were introduced.
  • Community support runs through Discord and Gitter channels linked from the README.

Getting started

Install the module with go get github.com/aceld/zinx on Golang Version 1.17 or newer, then create a server with znet.NewServer() and register routers as shown in the README's Zinx-Server example.

How it compares

The facts provided name no paid products that Zinx replaces and no comparable tools in this registry, so no licence, self-hosting, or cost-model contrast can be drawn here. On the evidence available, it stands alone among the entries described in this directory.

When to use it — and when not to

A self-hoster must operate a Go build and runtime; the facts mention no database, storage layer, or SMTP dependency to provision. Developers who need a batteries-included web framework, or who want a fully managed hosted service, should not pick Zinx, because it is deliberately a small framework positioned around understanding and customisation rather than breadth. The honest weakness evident in the facts is that the README is largely a directory of links and tutorial material, and the project carries 96 open issues, so a team adopting it should expect to read the source and the tutorials rather than rely on polished reference documentation; part of that tutorial material is also published in Chinese.

project readme (upstream, from github) — read inline

English | 简体中文

License Discord Gitter zinx tutorial Original Book of Zinx

Zinx is a lightweight concurrent server framework based on Golang.

Document

Note: Zinx has been widely used in many enterprises for development purposes, including message forwarding for backend modules, long-linked game servers, and message handling plugins for web frameworks. Zinx is positioned as a framework with concise code that allows developers to quickly understand the internal details of the framework and easily customize it based on their own enterprise scenarios.


Source of Zinx

Website

http://zinx.me


Online Tutorial

Online Tutorial Video

platform online video
zinx-BiliBili
zinx-BiliBili
zinx-youtube

I. One word that has been said before

Why did we create Zinx? Although there are many Golang application frameworks for servers, there are few lightweight enterprise frameworks applied in the gaming or other long-linked fields.

The purpose of designing Zinx is to provide a complete outline of how to write a TCP server based on Golang, so that more Golang enthusiasts can learn and understand this field in a straightforward manner.

The development of the Zinx framework project is synchronized with the creation of learning tutorials, and all the incremental and iterative thinking involved in the development process is incorporated into the tutorials. This approach avoids overwhelming beginners with a complete framework that they may find difficult to grasp all at once.

The tutorials will be iterated version by version, with each version adding small increments of functionality, allowing a beginner to gradually and comprehensively learn about the field of server frameworks.

Of course, we hope that more people will join Zinx and provide us with valuable feedback, enabling Zinx to become a truly enterprise-level server framework. Thank you for your attention!

II. Zinx architecture

Zinx框架

流程图 zinx-start

III. Zinx development API documentation

(1) QuickStart

DownLoad zinx Source

$go get github.com/aceld/zinx

note: Golang Version 1.17+

Zinx-Server
package main

import (
	"fmt"
	"github.com/aceld/zinx/ziface"
	"github.com/aceld/zinx/znet"
)

// PingRouter MsgId=1 
type PingRouter struct {
	znet.BaseRouter
}

//Ping Handle MsgId=1
func (r *PingRouter) Handle(request ziface.IRequest) {
	//read client data
	fmt.Println("recv from client : msgId=", request.GetMsgID(), ", data=", string(request.GetData()))
}

func main() {
	//1 Create a server service
	s := znet.NewServer()

	//2 configure routing
	s.AddRouter(1, &PingRouter{})

	//3 start service
	s.Serve()
}

Run Server

$ go run server.go
                                        
              ██                        
              ▀▀                        
 ████████   ████     ██▄████▄  ▀██  ██▀ 
     ▄█▀      ██     ██▀   ██    ████   
   ▄█▀        ██     ██    ██    ▄██▄   
 ▄██▄▄▄▄▄  ▄▄▄██▄▄▄  ██    ██   ▄█▀▀█▄  
 ▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀  ▀▀    ▀▀  ▀▀▀  ▀▀▀ 
                                        
┌──────────────────────────────────────────────────────┐
│ [Github] https://github.com/aceld                    │
│ [tutorial] https://www.yuque.com/aceld/npyr8s/bgftov │
└──────────────────────────────────────────────────────┘
[Zinx] Version: V1.0, MaxConn: 12000, MaxPacketSize: 4096
===== Zinx Global Config =====
Host: 0.0.0.0
TCPPort: 8999
Name: ZinxServerApp
Version: V1.0
MaxPacketSize: 4096
MaxConn: 12000
WorkerPoolSize: 10
MaxWorkerTaskLen: 1024
MaxMsgChanLen: 1024
ConfFilePath: /Users/Aceld/go/src/zinx-usage/quick_start/conf/zinx.json
LogDir: /Users/Aceld/go/src/zinx-usage/quick_start/log
LogFile: 
LogIsolationLevel: 0
HeartbeatMax: 10
==============================
2023/03/09 18:39:49 [INFO]msghandler.go:61: Add api msgID = 1
2023/03/09 18:39:49 [INFO]server.go:112: [START] Server name: ZinxServerApp,listenner at IP: 0.0.0.0, Port 8999 is starting
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 0 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 1 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 3 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 2 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 4 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 6 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 7 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 8 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 9 is started.
2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 5 is started.
2023/03/09 18:39:49 [INFO]server.go:134: [START] start Zinx server  ZinxServerApp succ, now listenning...
Zinx-Client
package main

import (
	"fmt"
	"github.com/aceld/zinx/ziface"
	"github.com/aceld/zinx/znet"
	"time"
)

//Client custom business
func pingLoop(conn ziface.IConnection) {
	for {
		err := conn.SendMsg(1, []byte("Ping...Ping...Ping...[FromClient]"))
		if err != nil {
			fmt.Println(err)
			break
		}

		time.Sleep(1 * time.Second)
	}
}

//Executed when a connection is created
func onClientStart(conn ziface.IConnection) {
	fmt.Println("onClientStart is Called ... ")
	go pingLoop(conn)
}

func main() {
	//Create a client client
	client := znet.NewClient("127.0.0.1", 8999)

	//Set the hook function after the link is successfully established
	client.SetOnConnStart(onClientStart)

	//start the client
	client.Start()

	//Prevent the process from exiting, waiting for an interrupt signal
	select {}
}

Run Client

$ go run client.go 
2023/03/09 19:04:54 [INFO]client.go:73: [START] Zinx Client LocalAddr: 127.0.0.1:55294, RemoteAddr: 127.0.0.1:8999
2023/03/09 19:04:54 [INFO]connection.go:354: ZINX CallOnConnStart....

Terminal of Zinx Print:

recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]
recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]
recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]
recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]
recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]
recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]
...

(2) Zinx configuration file

{
  "Name":"zinx v-0.10 demoApp",
  "Host":"0.0.0.0",
  "TCPPort":9090,
  "MaxConn":3,
  "WorkerPoolSize":10,
  "LogDir": "

readme truncated — read the full docs on github

Frequently asked questions

Is zinx free to use?

zinx is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does zinx do?

A lightweight concurrent server framework based on Golang.

What is zinx written in?

zinx is primarily written in Go. Its source is publicly available at https://github.com/aceld/zinx, and it has 7,764 GitHub stars.