RPC is usually heavy on processing logic and therefore cannot handle I/O serially. But Go’s standard
library net is designed for blocking I/O APIs, 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.
For more information, please refer to Document.
- LinkBuffer provides nocopy API for streaming reading and writing
- gopool provides high-performance goroutine pool
- mcache provides efficient memory reuse
IsActivesupports checking whether the connection is alive
Dialersupports building clients
EventLoopsupports building a server
- TCP, Unix Domain Socket
- Linux, Mac OS (operating system)
- Windows (operating system)
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:
- Support concurrent calls, support timeout(1s)
- Use protocol: header(4 bytes) indicates the total length of payload
- CPU: Intel(R) Xeon(R) Gold 5118 CPU @ 2.30GHz, 4 cores
- Memory: 8GB
- OS: Debian 5.4.56.bsk.1-amd64 x86_64 GNU/Linux
- Go: 1.15.4