gnet is an Event-Loop networking framework that is fast and small. It makes direct epoll and kqueue syscalls rather than using the standard Go net package, and works in a similar manner as libuv and libevent.
The goal of this project is to create a server framework for Go that performs on par with Redis and Haproxy for packet handling.
gnet sells itself as a high-performance, lightweight, nonblocking network library written in pure Go which works on transport layer with TCP/UDP/Unix-Socket protocols, so it allows developers to implement their own protocols of application layer upon gnet for building diversified network applications.
For instance, you get a HTTP Server or Web Framework if you implement HTTP protocol upon gnet while you have a Redis Server done with the implementation of Redis protocol upon gnet and so on.
gent derives from project evio while having higher performance.
gnet alternatives and similar packages
Based on the "Networking" category
Do you think we are missing an alternative of gnet or a related project?
English | [🇨🇳中文](README_ZH.md)
gnet is an event-driven networking framework that is fast and lightweight. It makes direct epoll and kqueue syscalls rather than using the standard Go net package and works in a similar manner as netty and libuv, which makes
gnet achieve a much higher performance than Go net.
gnet sells itself as a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go which works on transport layer with TCP/UDP protocols and Unix Domain Socket , so it allows developers to implement their own protocols(HTTP, RPC, WebSocket, Redis, etc.) of application layer upon
gnet for building diversified network applications, for instance, you get an HTTP Server or Web Framework if you implement HTTP protocol upon
gnet while you have a Redis Server done with the implementation of Redis protocol upon
gnet and so on.
gnet derives from the project:
evio while having a much higher performance and more features.
- [x] [High-performance](#-performance) event-loop under networking model of multiple threads/goroutines
- [x] Built-in goroutine pool powered by the library ants
- [x] Built-in memory pool with bytes powered by the library bytebufferpool
- [x] Lock-free during the entire runtime
- [x] Concise and easy-to-use APIs
- [x] Efficient and reusable memory buffer: Ring-Buffer
- [x] Supporting multiple protocols/IPC mechanism:
Unix Domain Socket
- [x] Supporting multiple load-balancing algorithms:
- [x] Supporting two event-driven mechanisms:
epollon Linux and
- [x] Supporting asynchronous write operation
- [x] Flexible ticker event
- [x] SO_REUSEPORT socket option
- [x] Built-in multiple codecs to encode/decode network frames into/from TCP stream: LineBasedFrameCodec, DelimiterBasedFrameCodec, FixedLengthFrameCodec and LengthFieldBasedFrameCodec, referencing netty codec, also supporting customized codecs
- [x] Supporting Windows platform with
event-driven mechanism of IOCPGo stdlib: net
- [ ] Implementation of
Benchmarks on TechEmpower
# Hardware Environment CPU: 28 HT Cores Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz Mem: 32GB RAM OS : Ubuntu 18.04.3 4.15.0-88-generic #88-Ubuntu Net: Switched 10-gigabit ethernet Go : go1.14.x linux/amd64
This is the top 50 on the framework ranking of all programming languages consists of a total of 422 frameworks from all over the world where
gnet is the runner-up.
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 see the full ranking list, visit TechEmpower Plaintext Benchmark.
Contrasts to the similar networking libraries
On Linux (epoll)
# Machine information OS : Ubuntu 18.04/x86_64 CPU : 8 Virtual CPUs Memory : 16.0 GiB # Go version and configurations Go Version : go1.12.9 linux/amd64 GOMAXPROCS=8
On FreeBSD (kqueue)
# Machine information OS : macOS Mojave 10.14.6/x86_64 CPU : 4 CPUs Memory : 8.0 GiB # Go version and configurations Go Version : go version go1.12.9 darwin/amd64 GOMAXPROCS=4
Please visit the official website for more details about architecture, usage and other information of
Source code in
gnet is available under the MIT License.
Please read the [Contributing Guidelines](CONTRIBUTING.md) before opening a PR and thank you to all the developers who already made contributions to
⚓ Relevant Articles
- A Million WebSockets and Go
- Going Infinite, handling 1M websockets connections in Go
- Go netpoll I/O 多路复用构建原生网络模型之源码深度解析
- gnet: 一个轻量级且高性能的 Golang 网络库
- 最快的 Go 网络框架 gnet 来啦！
- 字节跳动在 Go 网络库上的实践
🎡 User cases
Please feel free to add your projects here~~
Support us with a monthly donation and help us continue our activities.
Become a bronze sponsor with a monthly donation of $10 and get your logo on our README on Github.
☕️ Buy me a coffee
Please be sure to leave your name, Github account or other social media accounts when you donate by the following means so that I can add it to the list of donors as a token of my appreciation.
💵 Paid Support
If you need a tailored version of
gnet and want the author to help develop it, or bug fix/fast resolution/consultation which takes a lot of effort, you can request paid support here.
🔑 JetBrains OS licenses
gnet had been being developed with
GoLand IDE under the free JetBrains Open Source license(s) granted by JetBrains s.r.o., hence I would like to express my thanks here.
This project is supported by:
*Note that all licence references and agreements mentioned in the gnet README section above are relevant to that project's source code only.