gitmyhub

netpoll

Go ★ 4.6k updated 11d ago

A high-performance non-blocking I/O networking framework focusing on RPC scenarios.

Netpoll is a Go networking library built by ByteDance, the company behind TikTok, specifically for handling the kind of high-volume internal communication that happens between services in large software systems. That communication pattern, where many services constantly send small requests to each other, is called RPC (remote procedure call), and it has specific performance requirements that Go's built-in networking tools are not well suited for.

The core problem is that Go's standard networking library is designed around a model where each connection ties up a thread-like structure called a goroutine while it waits for data. Under high load, this means thousands or millions of goroutines sitting idle waiting, which wastes memory and processing time just switching between them. Netpoll takes a different approach: it handles many connections without dedicating a goroutine to each one, using an event-driven model where the system only acts when data actually arrives.

This approach borrows design ideas from similar tools in other languages, notably Netty from the Java world and evio from Go. Netpoll adds features that are specifically useful for RPC workloads: a way to read and write data without copying it in memory, a pool of goroutines that can be reused instead of created fresh for each task, and a way to check whether a connection is still alive before using it.

Netpoll is the foundation for two other ByteDance open-source projects: Kitex, an RPC framework, and Hertz, an HTTP framework. Both use Netpoll as their networking layer and are described as having industry-leading performance benchmarks.

The library runs on Linux and macOS. Windows is not supported. The README links to benchmark projects and design documentation for readers who want to go deeper.