Hertz integrated Netpoll and Golang network lib by default. Users can choose the appropriate one according to the actual scenarios to meet the best performance.
While creating a server, Hertz uses netpoll by default, but this behavior can be modified by configuration:
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?
Please tell us how we can improve.
Last modified March 28, 2023 : docs: declare netpoll delay issue and rm outdated info (#591) (52dcd86)