Evaluate my Python server structure
<p>I'm building a game server in Python and I just wanted to get some input on the architecture of the server that I was thinking up.</p>

<p>So, as we all know, Python cannot scale across cores with a single process. Therefore, on a server with 4 cores, I would need to spawn 4 processes. </p>

<p>Here is the steps taken when a client wishes to connect to the server cluster:</p>

<p>The IP the client initially communicates with is the Gateway node. The gateway keeps track of how many clients are on each machine, and forwards the connection request to the machine with the lowest client count.</p>

<p>On each machine, there is one Manager process and X Server processes, where X is the number of cores on the processor (since Python cannot scale across cores, we need to spawn 4 cores to use 100% of a quad core processor)</p>

<p>The manager's job is to keep track of how many clients are on each process, as well as to restart the processes if any of them crash. When a connection request is sent from the gateway to a manager, the manager looks at its server processes on that machine (3 in the diagram) and forwards the request to whatever process has the least amount of clients.</p>

<p>The Server process is what actually does the communicating with the client.</p>

<p>Here is what a 3 machine cluster would look like. For the sake of the diagram, assume each node has 3 cores.
<img src="http://img152.imageshack.us/img152/5412/serverlx2.jpg" alt="alt text" /></p>

<p>This also got me thinking - could I implement hot swapping this way? Since each process is controlled by the manager, when I want to swap in a new version of the server process I just let the manager know that it should not send any more connections to it, and then I will register the new version process with the old one. The old version is kept alive as long as clients are connected to it, then terminates when there are no more.</p>

<p>Phew. Let me know what you guys think.</p>
