title: Which is best network solution for MMORPG?
body: <p>we are developing a mmorpg with a small team. There are 2 structures we can create on the server side for managing clients and processing packages. I wonder what structure is better. I would be very happy if there is a good structure that you can recommend.</p>
  
  <p><strong>First Structure</strong></p>
  
  <p><a href="https://i.stack.imgur.com/agZNz.png" rel="nofollow noreferrer">IdleSessionQueue and ActiveSessionMap</a></p>
  
  <p><a href="https://i.stack.imgur.com/vG2Tv.png" rel="nofollow noreferrer">TaskQueue and SendQueue</a></p>
  
  <p>In this structure, idle sessions (IdleSessionQueue) are initially created and there is a thread (NetworkListenerThread) that listens to the network and accepts users. This thread takes a session from idle sessions when a new user arrives and adds the session to the active sessions table (ActiveSessionMap) using the values ​​of SessionId and Session. then creates a thread (ClientListenerThread) to listen to the session added to the table. a ClientListenerThread occurs for each user. When the client has disconnect, it is added back to IdleSessions again.</p>
  
  <p>When the client sends a request (Packet), that request is added to TaskQueue. A certain number of workersThreads are created in advance. As long as there is a package in TaskQueue, WorkerThreads receives the package and processes it and adds the new package to SendQueue. SenderThreads receives and sends each packet in SendQueue to client.</p>
  
  <p><strong>Second Structure</strong></p>
  
  <p><a href="https://i.stack.imgur.com/aVDyh.png" rel="nofollow noreferrer">IdleSessionQueue and ActiveSessionMap</a></p>
  
  <p>In this structure, idle sessions (IdleSessionQueue) are initially created and there is a thread (NetworkListenerThread) that listens to the network and accepts users. This thread takes a session from idle sessions when a new user arrives and adds this session to the active sessions table (ActiveSessionMap) using the values of SessionId and Session. then creates a thread (ClientListenerThread) to listen to the session added to the table. a ClientListenerThread occurs for each user. When the client has disconnect, it is added to IdleSessions again. When the client sends a request (Packet), that request is processed by ClientListenerThread and the result is sent to one or more clients.</p>
  
  <p>Which one is better solution or what is the best solution for this problem?</p>