cloudwego / netpoll
- суббота, 17 июля 2021 г. в 00:28:41
A high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance.
Netpoll is a high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance.
RPC is usually heavy on processing logic and therefore cannot handle I/O serially. But Go's standard library net designed blocking I/O API, so that the RPC framework can only follow the One Conn One Goroutine design. It will waste a lot of cost for context switching, due to a large number of goroutines under high concurrency. Besides, net.Conn has no API to check Alive, so it is difficult to make an efficient connection pool for RPC framework, because there may be a large number of failed connections in the pool.
On the other hand, the open source community currently lacks Go network libraries that focus on RPC scenarios. Similar repositories such as: evio, gnet, etc., are all focus on scenarios like Redis, Haproxy.
But now, Netpoll was born and solved the above problems. It draws inspiration from the design of evio and netty, has excellent Performance, and is more suitable for microservice architecture. Also Netpoll provides a number of Features, and it is recommended to replace net in some RPC scenarios.
We developed the RPC framework KiteX and HTTP framework Hertz (to be open sourced) based on Netpoll, both with industry-leading performance.
Examples show how to build RPC client and server using Netpoll.
For more information, please refer to Document.
Already
IsActive
supports checking whether the connection is aliveDialer
supports building clientsEventLoop
supports building a serverFuture
Unsupported
Benchmark is not a digital game, it should meet the requirements of industrial use first. In the RPC scenario, concurrent calls and waiting timeout are necessary support items.
Therefore, we set that the benchmark should meet the following conditions:
Similar repositories such as net , evio, gnet. We compared their performance through Benchmarks, as shown below.
For more benchmark reference Netpoll-Benchmark , KiteX-Benchmark and Hertz-Benchmark .
Compared with net , Netpoll latency about 34% and qps about 110% (continue to pressurize, net latency is too high to reference)