简体   繁体   中英

Netty client bootstrap

I am developing an application where I have a set of external TCP servers, which I have to connect from within my application.

  • I have a set of drivers which connect these servers.
  • a tcp client creating and returning the connection.
  • every driver communicates with an device, which is the tcp server

Now it is not clear to me what is the correct way to handle the client bootstrap. Should the TcpClient create a bootstrap and reuse it to open new channel or is it better to create a new Bootstrap every time a driver connects the device (server)?

Usually you would create a new Bootstrap per client (driver) and re-use it. The most important part in general is that you want to re-use the EventLoopGroup if possible. You may even share the same group with all the drivers if possible. This will ensure you can maximise the usage of the threads per EventLoopGroup and keep resource usage to a minimum.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM