开发者

Python Fast Webserver

Have a simple webse开发者_StackOverflow社区rver in python:

try:
    server = HTTPServer(('', 80), MyHandler)
    print 'started httpserver...'
    server.serve_forever()
except KeyboardInterrupt:
    print '^C received, shutting down server'
    server.socket.close()

Is there any way I can make it faster? I believe the above is blocking so concerned about slow responses...

Thanks!


To make web server scaleble use non-blocking IO sockets. A good framework/server for Python is Spawning:

http://pypi.python.org/pypi/Spawning/

Note that this makes your service scalable only in horizontally (you can easily add more concurrent requests). The delay of processing a single request depends on your code (how you make database connections, etc.) and hardware (do not use shared hosting). You did not explain in detail in your question what you are processing, so there is not enough data to give a comprehensive answer to your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜