Hi,
I had this basic question about what activities Netty worker threads should or should not do, as a guideline/convention.
1. Should not block in IO: I understand that. Because if workers block in IO, there is nobody to service requests even though CPU is idle and we have memory. And creating too many worker threads (hundreds or thousands) is also not appropriate for context switch overhead reasons, in fact, Netty allows us to solve that problem by multiplexing thousands of channels on just a few worker threads.
2. Should not block in heavy CPU work: Say, deserialization, lookups, even sending asynchronous requests to other services, etc. Not sure about whether this is true or not. Someone has to do the CPU work anyways, say via some other thread, while Netty worker just puts incoming records on a buffer that is emptied by other threads. Even then, say, if those threads are going to be scheduled by the OS anyways, it is very likely that netty workers don't get a chance to run because these other threads are doing some CPU work. So, adding that additional level of indirection through an additional buffer has not helped much. In fact, might add a bit of latency. The netty worker could very well have done that work. So, is it then ok for Netty workers to do some more work other instead of just putting off the requests in another buffer for handling by other threads?
Wanted to know whether my opinion on the above two points look correct.
Regards,
--Parikshit N. Samant.