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.
- High-performance event-loop under networking model of multiple threads/goroutines
- Built-in goroutine pool powered by the library ants
- Built-in memory pool with bytes powered by the library bytebufferpool
- Lock-free during the entire runtime
- Concise and easy-to-use APIs
- Efficient and reusable memory buffer: Ring-Buffer
- Supporting multiple protocols/IPC mechanism:
Unix Domain Socket
- Supporting multiple load-balancing algorithms:
- Supporting two event-driven mechanisms:
epollon Linux and
- Supporting asynchronous write operation
- Flexible ticker event
- SO_REUSEPORT socket option
- 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
- Supporting Windows platform with
event-driven mechanism of IOCPGo stdlib: net
- Implementation of
For more details about using
gnet, please visit documentations for gnet.