How do I create multiple instances of python application server?
<p>How do I create multiple instances of python application server?</p>

<p>I created an application server in python using httpserver. I am not using any python frameworks. Now I want to create multiple instances of the server and use load balancer on top of it. How can I create multiple instances of this application server? Are there any tutorials on how to create multiple instances?</p>

<p>I was going through Nginx. Can nginx create multiple instances? Are there any tutorials?</p>

<p>Details: I am working on windows machine. It is a python application server created using BaseHTTPServer. I am not using any framework like tornado, django.</p>

<p>You could bind different ports for each instance of your server.  </p>

<p>Make your script initialize each instance binding a different port ( e.g port 3000, 3001, 3002 ...) and configure nginx to spread the load on those ports.  </p>

<p>From <a href="https://docs.python.org/2/library/basehttpserver.html" rel="nofollow">https://docs.python.org/2/library/basehttpserver.html</a> , the example given is :</p>

<pre><code>def run(server_class=BaseHTTPServer.HTTPServer,
    handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
    server_address = ('', 8000)
    httpd = server_class(server_address, handler_class)
    httpd.serve_forever()
</code></pre>

<p>So you might create a class with a function like this as a method which could take the server port as an argument, in the example above the port is hard coded as 8000.  </p>

python python-2.7 nginx application-server