So I was a witness to a conversation where single threaded server was being compared with a multithreaded server. The participants discussed pros and cons.
Here are the pros that were listed for a single threaded server:
- its performance is better at the cost of resources as you spawn more processes
- creating threads and context switching is expensive
- it's easier for programmers as they don't need to deal with locks and other multithreading difficulties
I have to admit I was a bit puzzled by the third statement. Handling requests with multithreaded server is a problem that was solved in many commonly used frameworks, and it's not like there is a need to reinvent the wheel. There are already robust implementations of thread pools that do not share resources, so race conditions are avoided. Of course there is no advantage of using many thread if you don't have many cores available, but it doesn't seem to be the scenario that was being discussed.
Any thoughts?