I startin the project of a (web) server in c++ and i want to able to manage about 1000-2000 clients.
I have been reading alot about Single-thread VS Multi-thread server and i wanna know what u guys think about it.
I do not plan on using one-thread-per-client because i have heard that its too slow for 1000+ clients.
On the begin , i was 100% about using about 5 threads , by service: 1 for the Window Console (so the user can see its information without freezy the window) 1 for sending data 1 for receving data 1 for Accepting new clients 1 for computing the ugly processes (AI)
But then I heard about ppl sayin that have done webservers with only 1 thread (3 in my case, cause 1 for the window, 1 for acceptin new clients and 1 AI, Receving, Sending data), and i came up with the thought that if i do only use 1 thread for Receive,Sending and AI I wouldnt need to Lock/Unlock so much data (in those 3 processes).
What i wanna know is that, would u guys try to put the Receive,Sending and AI in just 1 process?
and
(Even though i believe dont, i need to make sure:) Would the access to the database (mysql in my case) LOCK my thread for a couple ms? or its just like another function call?
I think, multi-threading is a good approach for servers which process data (make lots calculations), for webservers (which transport data) single-threaded should be enough. I suggest you to start with single-threaded because it is easier to debug ;) First try to understood how THTTPS works. I thing it will be the best answer for Yours questions for now.
> 1 for the Window Console (so the user can see its > information without freezy the window)
I'm guessing - You think about MS Windows as a base platform? Read something about a "Logging" systems.