The current state of the art from a server capacity perspective is cooperative multitasking and queues. The basic notion is that you should not have to pay for all the context switches in the operating system and the CPU when you don’t want/need them. If you design your application to yield everytime it is waiting for something to return then you gain MASSIVE performance improvement both in terms of speed and in terms of not requring huge amounts of memory per simultaneous client. See e.g. The C10K Problem.
In python, your options are async core (aka Medusa) or Twisted.. Medusa is being fecklessly maintained while twisted is in active development so the choice is obviously twisted. If I were working in Java, I might choose Seda.
So having chosen twisted you want to create a src directory. In the src directoy, create a directory with your application name (this is going to be a module name directory or package directory if you are in java). Add the src directory to your compiler or script language loadpath.
In that directory, create a main.py that takes a config and runs your site given your framwork. For Twisted, this looks something like this:
#!/bin/env python
from twisted.internet import app
from twisted.web import static, server,script,vhost
def start(config):
root = static.File(config.fileBase)
root.indices=['index.rpy']
root.processors = {'.rpy': script.ResourceScript}
root.ignoreExt(".rpy")
rootroot = NameVirtualHost()
rootroot.addHost(config.host,root)
application = app.Application('web')
application.listenTCP(config.port, server.Site(rootroot))
application.run()
import sys
if __name__=="__main__":
configPath=sys.argv[1]
execfile(configPath)
main(__name__)
This script allows you to start the site either with config.py as a commandline argument or from another script by passing a config as an argument to start. It also runs the site as a virtual host so that unless someone knows the name of the file your dev site is inaccessible to nosy people on your LAN even if you are exposing the port to the world. Remember to edit your hosts file to get the local name to resolve correctly.