whatisgithub

What is gnet?

panjf2000/gnet — explained in plain English

Analysis updated 2026-06-24

11,144GoAudience · developerComplexity · 4/5Setup · moderate

In one sentence

A Go library for building extremely fast network servers that handles thousands of simultaneous connections using event-driven I/O instead of one goroutine per connection.

Mindmap

mindmap
  root((gnet))
    What it does
      Event-driven networking
      High-throughput servers
      Connection management
    Tech stack
      Go
      epoll
      kqueue
    Use cases
      TCP proxy servers
      Custom protocols
      Game backends
    Audience
      Go developers
      Systems programmers
      Backend engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a high-throughput TCP proxy server that manages tens of thousands of simultaneous connections with low memory use.

USE CASE 2

Implement a custom game server backend in Go that needs minimal latency and tight control over connection handling.

USE CASE 3

Write a specialized UDP protocol handler where Go's standard networking package is too slow for your traffic volume.

What is it built with?

Go

How does it compare?

panjf2000/gnet0xjacky/nginx-uiloft-sh/vcluster
Stars11,14411,13811,132
LanguageGoGoGo
Setup difficultymoderatemoderatehard
Complexity4/53/54/5
Audiencedeveloperops devopsops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Go 1.20+, Windows support is development-only and not suitable for production deployments.

So what is it?

gnet is a Go library for building high-performance network services. It works at the transport layer, meaning it handles the low-level mechanics of accepting and managing network connections for protocols like TCP and UDP, while leaving it to you to implement the application-level protocol on top, such as HTTP, WebSocket, or Redis. Most Go programs use the standard library's built-in networking package, which handles each connection with a dedicated goroutine. gnet takes a different approach: it uses event-driven I/O based on operating system primitives (epoll on Linux, kqueue on macOS and BSD) to handle many connections without a goroutine per connection. This design reduces memory use and can improve throughput in scenarios where a server needs to manage very large numbers of simultaneous connections. The library is not intended to replace Go's standard net package for everyday use. It is aimed at situations where raw performance is a priority, such as building a high-throughput proxy, a custom game server, or a specialized protocol handler. It provides an internal goroutine pool, elastic memory buffers, multiple load-balancing strategies, support for timed events, and edge-triggered I/O, all behind a concise API. gnet runs on Linux, macOS, Windows, and BSD variants, though the Windows version is noted as suitable for development use only rather than production. The library is used in production by several large Chinese technology companies including Tencent, iQiyi, Xiaomi, Baidu Tieba, and JD.com. Go 1.20 or higher is required. The library is added to a project as a standard Go module with a single import line.

Copy-paste prompts

Prompt 1
Using gnet, write a simple TCP echo server in Go that handles connections efficiently without a goroutine per connection.
Prompt 2
Show me how to implement a custom protocol handler in gnet that parses a fixed-length binary frame over TCP.
Prompt 3
Help me benchmark gnet against Go's standard net package for a server handling 50,000 concurrent TCP connections.
Prompt 4
Walk me through building a UDP server with gnet that uses the built-in goroutine pool and round-robin load balancing.

Frequently asked questions

What is gnet?

A Go library for building extremely fast network servers that handles thousands of simultaneous connections using event-driven I/O instead of one goroutine per connection.

What language is gnet written in?

Mainly Go. The stack also includes Go.

How hard is gnet to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is gnet for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.