I am currently developing a server using Netty and the Command Pattern. During the implementation of the invoker, I got the idea to implement it using several threads in order to ensure high command execution performance.
However, I started wondering whether this is necessary with Netty, as Netty creates multiple threads on it's own. So now my question: Is the invoker already multi-threaded, if I pass a thread safe invoker object to the Netty handlers and call the invoke()-method from there? If that's the case, is this good practice or should I rather create my own invoker threads?
Thanks for your help!
After some more research, I found the answer to my questions. I'll post it here, if anyone comes across a similar question:
Is the invoker already multi-threaded, if I pass a thread safe invoker object to the Netty handlers and call the invoke()-method from there?
Yes, unless otherwise specified, the Netty handlers will built up 2 * count of cores
threads. The channel handlers are thereby often executed in different threads, so a simple invocation of the command.execute() method will already be multi-threaded due to the nature of netty.
Is this good practice?
Yes, otherwise too many threads are created and the tasks for the netty worker threads will just be delegated unnecessarily.