Build high-performance networking applications in Go
On top of a variety of protocols of HTTP, RPC, WebSocket, Redis, etc.
gnet is the fastest networking framework in Go.
Why gnet?
Ultra-Fast
Built in Go, gnet is an ultra-fast and memory-efficient networking framework. It is built from scratch by exploiting the event-driven techniques - epoll and kqueue. gnet sells itself as a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go which works on the transport layer with TCP/UDP protocols and Unix Domain Socket.
Lock-Free
gnet is lock-free during the entire runtime, which keeps gnet free from synchronization issues and speeds it up.
Concise & Easy-to-use APIs
gnet provides concise and easy-to-use APIs. It takes over most of the tough work for developers, minimizing the complexity of networking applications so that developers are able to concentrate on business logic instead of the underlying implementations of networking.
Multiple Protocols
gnet supports multiple protocols/IPC mechanism: TCP, UDP and Unix Domain Socket, enabling you to develop a variety of networking applications.
Cross Platform
gnet is devised as a cross-platform framework, as a result, it works faultlessly on multiple platforms: Linux, FreeBSD, DragonFly BSD, Windows.
Powerful Libraries
There is a rich set of libraries in gnet, such as memory pool, goroutine pool, elastic buffers, logging package, etc., which makes it convenient for developers to build fast and efficient networking applications.
Networking model of multiple reactors
- Multiple Reactors
- Multiple Reactors With Groutine Pool
Cross Platform
How to install gnet
`gnet` is available as a Go module and we highly recommend that you use `gnet` via Go Modules, with Go 1.11 Modules enabled (Go 1.11+), you can just simply add `import "github.com/panjf2000/gnet/v2"` to the codebase and run `go mod download/go mod tidy` or `go [build|run|test]` to download the necessary dependencies automatically.
Run go get to download gnet:
With v2
go get -u github.com/panjf2000/gnet/v2
With v1
go get -u github.com/panjf2000/gnet
Performance
# Hardware Environment* 28 HT Cores Intel(R) Xeon(R) Gold 5120 CPU @ 3.20GHz* 32GB RAM* Dedicated Cisco 10-gigabit Ethernet switch* Debian 12 "bookworm"* Go1.19.x linux/amd64
This is a leaderboard of the top 50 out of 486 frameworks that encompass various programming languages worldwide, in which gnet
is ranked first.
This is the full framework ranking of Go and gnet
tops all the other frameworks, which makes gnet
the fastest networking framework in Go.
To check the full ranking list, visit TechEmpower Benchmark Round 22.
Note that the HTTP implementation of gnet on TechEmpower is half-baked and fine-tuned for benchmark purposes only and is far from production-ready.
Use cases
gnet
as the underlying network service in production.If your projects are also using gnet
, feel free to open a pull request refreshing this list.