title: Node.js multiplayer game multi threading and multi core
body: <p>I'm working on an web multiplayer game. Using docker, node, digital ocean with postgres and redis for data. My docker machine has many CPUs, but node.js is only using a single CPU. Because of this I'm near the point this game can scale.</p>
  
  <p>I want to be able to leverage the other CPUs. Some of the methods I've heard and read about are:</p>
  
  <ul>
  <li>Using child processes</li>
  <li>Running multiple node servers in 1 droplet</li>
  <li>Running multiple node servers in different droplets</li>
  </ul>
  
  <p>I prefer not to run more node servers, if I can get away with it. The game structure is kind of like this:</p>
  
  <p>Lobby (Player info, all online players etc..)
  Rooms (Limited amount of players)
  Games (Limited amount of players, 20-40m play time)</p>
  
  <p>Lobby &lt;=> Room => Games</p>
  
  <p>I do not have a way of measuring (Open to suggestions here too), but I'm guessing most of the CPU usage are from singular games. I'm hoping for a solution somewhat like keeping Lobby &amp; Rooms in the main thread. While all games are created in either random different threads or created in thread that has the minimum amount of active game count. </p>
  
  <p>Some possible problems I foresee are messages and playerstate. A player can have multiple browser tabs open at the same time. Which means a single player object can have like 4 sessions &amp; socket connections. 1 inside lobby, 3 inside games. Player might want to send a private message from his game to a player inside the lobby. Also when a game finishes, player state will get updated. </p>
  
  <p>According to all these info, what would be my best way to proceed? Any docs, blogs, links, keywords, videos are appreciated. </p>