Mod_Python introduction - The other LAMP: "Why Python?
Python is the ideal programming language for new programmers. It is easy and quick to learn, the interpreter makes playing with your code easy and it comes with an extensive library so you can reuse other people's code and develop more quickly. This makes it ideal for developing prototypes and rapid development. Websites such as google, yahoo mail, yahoo groups and others were at some point in their lives mostly python.
The downsides? Because python is dynamically typed for larger applications unit testing is important. Not as many ISPs support mod_python as PHP, mod_perl and ASPs yet.
mod_python is a module that allows python to run embedded directly into the apache server allowing for good performance. The current version includes support for sessions, psp templates, and cgi support.
Scaling
How fast is mod_python? Recent benchmarks that I have made put it (20-50x) faster than cgi or zope and mildly faster than mod_php. If you need to make your application truly scalable you should investigate caching servers such as mod_cache in apache or HTTP server acceleration using squid server. Generate much of your content as possible as static pages and try to minimize the session information held in memory.
If bandwidth is the constraint have a look at mod_gzip or the gzip example in mod_python. You will see 50% to 20% bandwidth savings. Most browsers support this - unfortunately most spiders don't yet support gzip.
How to run code?
The original method of running code on web servers was through the CGI model. In CGI each time the program is run a separate process is spawned and its standard output is redirected to the browser. Because python is interpreted there is significant overhead of launching the interpreter. Every CGI request causes a process to be created and the Py"
Brak komentarzy:
Prześlij komentarz