Java. Server architecture question for the game

Question:

I am thinking about the architecture of the server for the game and the question arose about how to handle client connections. Protocol – tcp / ip .

There is a choice between a multi-threaded architecture (1 client – 1 thread) and asynchronous I / O (when reading does not block the thread, if there is no data, but returns 0 and the thread can handle other clients, that is, 1 thread – many clients).

The game is mmorpg, where potentially people can stand in the city and not transmit almost any input to the server, but there are also dynamic moments where a quick server response is important.


When stopped, threads do not use CPU cycles , they are more responsive , but they hold RAM , which would not be desirable in low-active places, where there is almost no input from the players.


The asynchronous approach uses less memory , is less vulnerable to low-activity clients , but less efficient for active clients.

The choice is very difficult, so I would like to ask for advice from more experienced ones who have had experience with these approaches, thank you.

Answer:

I would suggest dynamic thread pooling. You know the pros from him. And the size of this pool can be changed depending on the load, which will save on CPU and achieve sufficient performance depending on the needs of users

Scroll to Top