2

I have been doing a lot of studying of the BaseHTTPServer and found that its not that good for multiple requests. I went through this article http://metachris.org/2011/01/scaling-python-servers-with-worker-processes-and-socket-duplication/#python

and I wanted to know what is the best way for building a HTTP Server for multiple requests ->

My requirements for the HTTP Server are simple - - support multiple requests (where each request may run a LONG Python Script)

Till now I have following options -> - BaseHTTPServer (with thread is not good) - Mod_Python (Apache intergration) - CherryPy? - Any other?

3 Answers 3

2

I have had very good luck with the CherryPy web server, one of the oldest and most solid of the pure-Python web servers. Just write your application as a WSGI callable and it should be easy to run under CherryPy's multi-threaded server.

http://www.cherrypy.org/

Sign up to request clarification or add additional context in comments.

Comments

1

Indeed, the the HTTP servers provided with the standard python library are meant only for light duty use; For moderate scaling (100's of concurrent connections), mod_wsgi in apache is a great choice.

If your needs are greater than that(10,000's of concurrent connections), You'll want to look at an asynchronous framework, such as Twisted or Tornado. The general structure of an asynchronous application is quite different, so if you think you're likely to need to go down that route, you should definitely start your project in one of those frameworks from the start

Comments

1

Tornado is a really good and easy-to-use asynchronous event-loop / webserver developed by FriendFeed/Facebook. I've personally had very good experiences with it. You can use the HTTP classes as in the example below, or only the io-loop to multiplex plain TCP connections.

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.current().start()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.