I've built a Java NIO TCP server, it currently uses four threads. One ServerRunnable thread that uses a selector and three worker threads.
I've been looking around for some information about this, as I've read in the past that you should only have one thread per processor core. So that's that.
But that got me wondering recently, and after a little more research I came across this thread.
Where, in the comments on the accepted answer user Donal Fellows points out the following:
Have at most one CPU-bound thread per processor allocated to the application. IO-bound threads aren't a big problem (other than the memory they consume) and it's important to remember that apps can be restricted to only use a subset of the system's CPUs; after all, it's (usually) the user's/admin's computer and not the programmer's.
With that in mind, am I correct in thinking I can safely increase the number of selector threads and worker threads in my thread pool.
My server thread reads input, processes the data into JSONObjects and then pushes them to a queue. The worker threads then take the JSONObjects from the queue, checks what type of objects they are and then pushes them to the database. So there is very little computational work going on there. Is it safe enough for me to increase the number of threads here, as in use more ServerRunnable threads and more worker threads? Say to double the amount of each for example?
What do I need to think about when considering something like this?