I'm working on a server for a chat program i'm writing, and so far i have it structured to where a loop in main does nothing but sit and wait for a connection, set up the socket stuff, and create a new thread to handle the client, etc.. I've written a little app that shows me the max number of threads per process i'm able to have from limits.h, and it comes up as 16384.
Now, I know I definitely won't have that many users when i first launch the program, but I want the program to be as scalable as possible. I know that even if I were to have 16364 clients connected and using the service, the server would have plenty of ram left, and I defiitely don't want to waste those resources.
What is it exactly that limits the number of possible pthreads if ram isn't the issue?
What could I do to overcome this obstacle? Would a mixture of forks and pthreads be the best solution? Maybe have a top level process that does nothing but create more processes when the other(s) have used up all available pthreads? I'd appreciate any help you could offer.