While creating a server, Hertz uses netpoll by default, but this behavior can be modified by configuration:
Note: Netpoll currently does not support Windows. Windows will automatically switch the network library to go net through conditional compilation.
While creating a Client, it can also be modified by configuration:
Choosing appropriate network library
- If you need to start a TLS server, Please use
go netlib instead.
netpollis now working on it but not ready yet.
- Due to the different I/O trigger model between the two network libs,
go netfor ET model and
netpollfor LT model, which makes the application scenarios of the two libs somewhat different. Under the ET mode, Read / Write events will be handled by the framework. Under the LT mode, Read / Write events will be handled by the network lib itself instead. So with the small size requests, better schedule strategy provided by netpoll will makes LT model perform better; But under the situation with large size requests, since the Read / Write is not controlled by the framework layer, it may cause memory pressure because large amount of data will be loaded into the memory but can not be handled in time.
- Under the situation with large request size ( generally larger than 1M ), go net lib with streaming is recommended.
- In other situation, netpoll lib is recommended for extreme performance.
Was this page helpful?