3

Gnet is the fastest networking framework in Go

 6 months ago
source link: https://gnet.host/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Build high-performance networking applications in Go

On top of a variety of protocols of HTTP, RPC, WebSocket, Redis, etc.

logo-light

gnet is the fastest networking framework in Go.

#Why gnet?

Ultra-Fast

Built in Go, gnet is ultra-fast and memory efficient based on the event-driven mechanism. It's designed to create a networking server framework for Go that performs on par with Redis and Haproxy for networking packets handling.

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 for users, it only exposes the essential APIs and takes over most of the tough work for users, minimizing the complexity of business code so that developers are able to concentrate on business logic instead of the underlying implementations.

Multiple Porotocols

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

Learn how gnet works
  •  Multiple Reactors
  •  Multiple Reactors With Groutine Pool
multi-reactorsClientClientClientMain ReactorSub ReactorReadDecodeComputeEncodeWriteAcceptorSub ReactorReadDecodeComputeEncodeWrite

#Cross Platform

Built on Linux, FreeBSD, DragonFly BSD, Darwin, Windows
003-linuxCreated with Sketch.    001-appleCreated with Sketch.    002-windowsCreated with Sketch.
UNIX & Windows
X86_64, ARM64
Light-weight
Ultra-fast

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

With v1

#Performance

Benchmarks on TechEmpower
All languages

This is a leaderboard of the top 50 out of 499 frameworks that encompass various programming languages worldwide, in which gnet is ranked first.

Go

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 Plaintext Benchmark.

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

The following companies/organizations use gnet as the underlying network service in production.
iqiyi-logo.pngmi-logo.png360-logo.pngbaidu-tieba-logo.pngtencent-games-logo.png

If your projects are also using gnet, feel free to open a pull request refreshing this list.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK