I am implementing a MMO server using TCP. Well, this server was already implemented before, but in single threaded way, and of course did not scale properly.
The single threaded version just polled all player sockets constantly, and the response times were atrocious with more than 15 players online.
So now, I decided to modify it to create a new thread for each player that connects, and use blocking sockets instead of polling.
First question, is this scalable enough? What kind of limit can I expect?
I usually heard that MMO servers usually cap out at 2000 online players per server, could I reach this kind of value by using one thread per player.or the cpu would bottleneck too much?
My server is installed on Amazon EC2, so bandwidth wont be a problem, the performance will all depend on my implementation.
Second, how to detect when one client dropped the connection in TCP.
Let's say that one thread on the server is blocked on socket.Read() and the client just dropped the connection (for example, crashed ).
How should this be handled, does the blocking read() interrupts if the connection is dropped or it hangs there until the thread is killed by the main thread?
In the current implementation, since the sockets do not block, the server just keeps track of the timestamp of the last message received and drops the connection when too much time passes without new messages.
Edited by Relfos, 15 December 2013 - 12:25 AM.