I have a netty-based application which listens to multiple tcp ports. So each port is initialized like this
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(), Executors.newFixedThreadPool(Settings.getDemuxPoolSize()),
Settings.getDemuxPoolSize()));
But having so many thread pools (and I have really many open TCP ports) looks like a waste to me.
Question is: is it safe to use SAME thread pools across multiple server bootstraps in Netty? (Maybe some thread-local channel references, etc.?)
You would better be off to create a WorkerPool and then share it between the different NioServerSocketChannelFactory instances. So you can use the same Workers for different ChannelFactory instances.
Something like: