{"id":13413598,"url":"https://github.com/panjf2000/gnet","last_synced_at":"2025-05-13T20:03:42.629Z","repository":{"id":37430767,"uuid":"172292744","full_name":"panjf2000/gnet","owner":"panjf2000","description":"🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.","archived":false,"fork":false,"pushed_at":"2025-05-02T10:39:58.000Z","size":43964,"stargazers_count":10469,"open_issues_count":4,"forks_count":1064,"subscribers_count":168,"default_branch":"dev","last_synced_at":"2025-05-06T19:52:00.426Z","etag":null,"topics":["async","asynchronous","epoll","event-driven","event-loop","go","golang","goroutine","io","kqueue","network","networking","non-blocking","reactor","tcp","udp"],"latest_commit_sha":null,"homepage":"https://gnet.host","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/panjf2000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["panjf2000"],"patreon":"panjf2000","open_collective":"panjf2000","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-02-24T03:48:45.000Z","updated_at":"2025-05-06T10:23:28.000Z","dependencies_parsed_at":"2023-12-13T06:26:48.566Z","dependency_job_id":"24564d98-5331-44d0-8e95-f9aa9865db9c","html_url":"https://github.com/panjf2000/gnet","commit_stats":{"total_commits":871,"total_committers":33,"mean_commits":"26.393939393939394","dds":0.06888633754305395,"last_synced_commit":"f03f0bdf9bbbdc18ed659cd3a7d09950d720424b"},"previous_names":[],"tags_count":113,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjf2000%2Fgnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjf2000%2Fgnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjf2000%2Fgnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjf2000%2Fgnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panjf2000","download_url":"https://codeload.github.com/panjf2000/gnet/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253141474,"owners_count":21860541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asynchronous","epoll","event-driven","event-loop","go","golang","goroutine","io","kqueue","network","networking","non-blocking","reactor","tcp","udp"],"created_at":"2024-07-30T20:01:44.137Z","updated_at":"2025-05-13T20:03:42.607Z","avatar_url":"https://github.com/panjf2000.png","language":"Go","readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/panjf2000/logos/master/gnet/logo.png\" alt=\"gnet\" /\u003e\n\u003cbr /\u003e\n\u003ca title=\"Build Status\" target=\"_blank\" href=\"https://github.com/panjf2000/gnet/actions?query=workflow%3ATests\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/panjf2000/gnet/test.yml?branch=dev\u0026style=flat-square\u0026logo=github-actions\" /\u003e\u003c/a\u003e\n\u003ca title=\"Codecov\" target=\"_blank\" href=\"https://codecov.io/gh/panjf2000/gnet\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/panjf2000/gnet?style=flat-square\u0026logo=codecov\" /\u003e\u003c/a\u003e\n\u003ca title=\"Supported Platforms\" target=\"_blank\" href=\"https://github.com/panjf2000/gnet\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20*BSD%20%7C%20Windows-549688?style=flat-square\u0026logo=launchpad\" /\u003e\u003c/a\u003e\n\u003ca title=\"Minimum Go Version\" target=\"_blank\" href=\"https://github.com/panjf2000/gnet\"\u003e\u003cimg src=\"https://img.shields.io/badge/go-%3E%3D1.20-30dff3?style=flat-square\u0026logo=go\" /\u003e\u003c/a\u003e\n\u003cbr /\u003e\n\u003ca title=\"Go Report Card\" target=\"_blank\" href=\"https://goreportcard.com/report/github.com/panjf2000/gnet\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/panjf2000/gnet?style=flat-square\" /\u003e\u003c/a\u003e\n\u003ca title=\"Doc for gnet\" target=\"_blank\" href=\"https://pkg.go.dev/github.com/panjf2000/gnet/v2#section-documentation\"\u003e\u003cimg src=\"https://img.shields.io/badge/go.dev-doc-007d9c?style=flat-square\u0026logo=read-the-docs\" /\u003e\u003c/a\u003e\n\u003ca title=\"Mentioned in Awesome Go\" target=\"_blank\" href=\"https://github.com/avelino/awesome-go#networking\"\u003e\u003cimg src=\"https://awesome.re/mentioned-badge-flat.svg\" /\u003e\u003c/a\u003e\n\u003ca title=\"Release\" target=\"_blank\" href=\"https://github.com/panjf2000/gnet/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/panjf2000/gnet.svg?color=161823\u0026style=flat-square\u0026logo=smartthings\" /\u003e\u003c/a\u003e\n\u003ca title=\"Tag\" target=\"_blank\" href=\"https://github.com/panjf2000/gnet/tags\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/panjf2000/gnet?color=%23ff8936\u0026logo=fitbit\u0026style=flat-square\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://trendshift.io/repositories/9602\" target=\"_blank\"\u003e\u003cimg src=\"https://trendshift.io/api/badge/repositories/9602\" alt=\"panjf2000%2Fgnet | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nEnglish | [中文](README_ZH.md)\n\n### 🎉🎉🎉 Feel free to join [the channels about `gnet` on the Discord Server](https://discord.gg/UyKD7NZcfH).\n\n# 📖 Introduction\n\n`gnet` is an event-driven networking framework that is ultra-fast and lightweight. It is built from scratch by exploiting [epoll](https://man7.org/linux/man-pages/man7/epoll.7.html) and [kqueue](https://en.wikipedia.org/wiki/Kqueue) and it can achieve much higher performance with lower memory consumption than Go [net](https://golang.org/pkg/net/) in many specific scenarios.\n\n`gnet` and [net](https://golang.org/pkg/net/) don't share the same philosophy in network programming. Thus, building network applications with `gnet` can be significantly different from building them with [net](https://golang.org/pkg/net/), and the philosophies can't be reconciled. There are other similar products written in other programming languages in the community, such as [libuv](https://github.com/libuv/libuv), [netty](https://github.com/netty/netty), [twisted](https://github.com/twisted/twisted), [tornado](https://github.com/tornadoweb/tornado), etc. which work in a similar pattern as `gnet` under the hood.\n\n`gnet` is not designed to displace the Go [net](https://golang.org/pkg/net/), but to create an alternative in the Go ecosystem for building performance-critical network services. As a result of which, `gnet` is not as comprehensive as Go [net](https://golang.org/pkg/net/), it provides only the core functionality (via a concise set of APIs) required by a network application and it doesn't plan on becoming a coverall networking framework, as I think Go [net](https://golang.org/pkg/net/) has done a good enough job in that area.\n\n`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. It enables developers to implement their own protocols(HTTP, RPC, WebSocket, Redis, etc.) of application layer upon `gnet` for building diversified network services. For instance, you get an HTTP Server 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.\n\n**`gnet` derives from the project: `evio` with much higher performance and more features.**\n\n# 🚀 Features\n\n## 🦖 Milestone\n\n- [x] [High-performance](#-performance) event-driven looping based on a networking model of multiple threads/goroutines\n- [x] Built-in goroutine pool powered by the library [ants](https://github.com/panjf2000/ants)\n- [x] Lock-free during the entire runtime\n- [x] Concise and easy-to-use APIs\n- [x] Efficient, reusable, and elastic memory buffer: (Elastic-)Ring-Buffer, Linked-List-Buffer and Elastic-Mixed-Buffer\n- [x] Multiple protocols/IPC mechanisms: `TCP`, `UDP`, and `Unix Domain Socket`\n- [x] Multiple load-balancing algorithms: `Round-Robin`, `Source-Addr-Hash`, and `Least-Connections`\n- [x] Flexible ticker event\n- [x] `gnet` client\n- [x] Running on `Linux`, `macOS`, `Windows`, and *BSD: `Darwin`/`DragonFlyBSD`/`FreeBSD`/`NetBSD`/`OpenBSD`\n- [x] **Edge-triggered** I/O support\n- [x] Multiple network addresses binding\n\n## 🕊 Roadmap\n\n- [ ] **TLS** support\n- [ ] [io_uring](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023) support\n- [ ] **KCP** support\n\n***Windows version of `gnet` should only be used in development for developing and testing, it shouldn't be used in production.***\n\n# 🎬 Getting started\n\n`gnet` is available as a Go module and we highly recommend that you use `gnet` via [Go Modules](https://go.dev/blog/using-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.\n\n## With v2\n\n```bash\ngo get -u github.com/panjf2000/gnet/v2\n```\n\n## With v1\n\n```bash\ngo get -u github.com/panjf2000/gnet\n```\n\n# 🎡 Use cases\n\nThe following corporations/organizations use `gnet` as the underlying network service in production.\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.tencent.com/\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/tencent_logo.png\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.tencentgames.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/tencent-games-logo.jpeg\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.iqiyi.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/iqiyi-logo.png\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.mi.com/global/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/mi-logo.png\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.360.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/360-logo.png\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://tieba.baidu.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/baidu-tieba-logo.png\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.jd.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/jd-logo.png\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.zuoyebang.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/zuoyebang-logo.jpeg\" width=\"200\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003ca href=\"https://www.bytedance.com/\" target=\"_blank\"\u003e\n          \u003cimg src=\"https://res.strikefreedom.top/static_res/logos/ByteDance_Logo.png\" width=\"250\" /\u003e\n        \u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\nIf you're also using `gnet` in production, please help us enrich this list by opening a pull request.\n\n# 📊 Performance\n\n## Benchmarks on TechEmpower\n\n```bash\n# Hardware Environment\n* 28 HT Cores Intel(R) Xeon(R) Gold 5120 CPU @ 3.20GHz\n* 32GB RAM\n* Dedicated Cisco 10-gigabit Ethernet switch\n* Debian 12 \"bookworm\"\n* Go1.19.x linux/amd64\n```\n\n![](https://raw.githubusercontent.com/panjf2000/illustrations/master/benchmark/techempower-plaintext-top50-light.jpg)\n\nThis is a leaderboard of the top ***50*** out of ***486*** frameworks that encompass various programming languages worldwide, in which `gnet` is ranked ***first***.\n\n![](https://raw.githubusercontent.com/panjf2000/illustrations/master/benchmark/techempower-plaintext-topN-go-light.png)\n\nThis is the full framework ranking of Go and `gnet` tops all the other frameworks, which makes `gnet` the ***fastest*** networking framework in Go.\n\nTo see the full ranking list, visit [TechEmpower Benchmark **Round 22**](https://www.techempower.com/benchmarks/#hw=ph\u0026test=plaintext\u0026section=data-r22).\n\n***Note that the HTTP implementation of gnet on TechEmpower is half-baked and fine-tuned for benchmark purposes only and far from production-ready.***\n\n## Contrasts to the similar networking libraries\n\n## On Linux (epoll)\n\n### Test Environment\n\n```bash\n# Machine information\n        OS : Ubuntu 20.04/x86_64\n       CPU : 8 CPU cores, AMD EPYC 7K62 48-Core Processor\n    Memory : 16.0 GiB\n\n# Go version and settings\nGo Version : go1.17.2 linux/amd64\nGOMAXPROCS : 8\n\n# Benchmark parameters\nTCP connections : 1000/2000/5000/10000\nPacket size     : 512/1024/2048/4096/8192/16384/32768/65536 bytes\nTest duration   : 15s\n```\n\n#### [Echo benchmark](https://github.com/gnet-io/gnet-benchmarks)\n\n![](https://github.com/panjf2000/gnet_benchmarks/raw/master/results/echo_conn_linux.png)\n\n![](https://github.com/panjf2000/gnet_benchmarks/raw/master/results/echo_packet_linux.png)\n\n## On MacOS (kqueue)\n\n### Test Environment\n\n```bash\n# Machine information\n        OS : MacOS Big Sur/x86_64\n       CPU : 6 CPU cores, Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\n    Memory : 16.0 GiB\n\n# Go version and settings\nGo Version : go1.16.5 darwin/amd64\nGOMAXPROCS : 12\n\n# Benchmark parameters\nTCP connections : 300/400/500/600/700\nPacket size     : 512/1024/2048/4096/8192 bytes\nTest duration   : 15s\n```\n\n#### [Echo benchmark](https://github.com/gnet-io/gnet-benchmarks)\n\n![](https://github.com/panjf2000/gnet_benchmarks/raw/master/results/echo_conn_macos.png)\n\n![](https://github.com/panjf2000/gnet_benchmarks/raw/master/results/echo_packet_macos.png)\n\n# ⚠️ License\n\nThe source code of `gnet` should be distributed under the Apache-2.0 license.\n\n# 👏 Contributors\n\nPlease read the [Contributing Guidelines](CONTRIBUTING.md) before opening a PR and thank you to all the developers who already made contributions to `gnet`!\n\n\u003ca href=\"https://github.com/panjf2000/gnet/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=panjf2000/gnet\" /\u003e\n\u003c/a\u003e\n\n# ⚓ Relevant Articles\n\n- [A Million WebSockets and Go](https://www.freecodecamp.org/news/million-websockets-and-go-cc58418460bb/)\n- [Going Infinite, handling 1M websockets connections in Go](https://speakerdeck.com/eranyanay/going-infinite-handling-1m-websockets-connections-in-go)\n- [Go netpoller 原生网络模型之源码全面揭秘](https://strikefreedom.top/go-netpoll-io-multiplexing-reactor)\n- [gnet: 一个轻量级且高性能的 Golang 网络库](https://strikefreedom.top/go-event-loop-networking-library-gnet)\n- [最快的 Go 网络框架 gnet 来啦！](https://strikefreedom.top/releasing-gnet-v1-with-techempower)\n\n# 💰 Backers\n\nSupport us with a monthly donation and help us continue our activities.\n\n\u003ca href=\"https://opencollective.com/gnet#backers\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/gnet/backers.svg\"\u003e\u003c/a\u003e\n\n# 💎 Sponsors\n\nBecome a bronze sponsor with a monthly donation of $10 and get your logo on our README on GitHub.\n\n\u003ca href=\"https://opencollective.com/gnet#sponsors\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/gnet/sponsors.svg\"\u003e\u003c/a\u003e\n\n# ☕️ Buy me a coffee\n\n\u003e 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.\n\n\u003cimg src=\"https://raw.githubusercontent.com/panjf2000/illustrations/master/payments/WeChatPay.JPG\" width=\"250\" align=\"middle\"/\u003e\u0026nbsp;\u0026nbsp;\n\u003cimg src=\"https://raw.githubusercontent.com/panjf2000/illustrations/master/payments/AliPay.JPG\" width=\"250\" align=\"middle\"/\u003e\u0026nbsp;\u0026nbsp;\n\u003ca href=\"https://www.paypal.me/R136a1X\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/panjf2000/illustrations/master/payments/PayPal.JPG\" width=\"250\" align=\"middle\"/\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\n\n# 🔑 JetBrains OS licenses\n\n`gnet` has 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.\n\n\u003ca href=\"https://www.jetbrains.com/?from=gnet\" target=\"_blank\"\u003e\u003cimg src=\"https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg\" alt=\"JetBrains logo.\"\u003e\u003c/a\u003e\n\n# 🔋 Sponsorship\n\n\u003cp\u003e\n  \u003ch3\u003eThis project is supported by:\u003c/h3\u003e\n  \u003ca href=\"https://www.digitalocean.com/\"\u003e\u003cimg src=\"https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/SVG/DO_Logo_horizontal_blue.svg\" width=\"201px\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e","funding_links":["https://github.com/sponsors/panjf2000","https://patreon.com/panjf2000","https://opencollective.com/panjf2000","https://opencollective.com/gnet","https://www.paypal.me/R136a1X"],"categories":["Popular","Misc","Go","开源类库","Networking","Repositories","Open source library","网络相关库","Relational Databases","网络","Network"],"sub_categories":["网络","Transliteration","Uncategorized","The Internet","暂未分类","音译","暂未分类这些库被放在这里是因为其他类别似乎都不适合。","Strings"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanjf2000%2Fgnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanjf2000%2Fgnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanjf2000%2Fgnet/lists"}