[Tutor] cgi, fastcgi, mod_python

Mike Hansen mhansen at cso.atmel.com
Fri Apr 30 17:47:01 EDT 2004


Thanks for the info. It's good to hear that cgi does the job and that 
the other options might not be necessary. I'll also keep jonpy in mind 
if it becomes necessary to use FastCGI.

Next up, I'm going to experiment with htmltemplate.

Mike

Lloyd Kvam wrote:

>On Thu, 2004-04-29 at 15:36, Mike Hansen wrote:
>  
>
>>Hello,
>>
>>I've recently started experimenting with Python to write web apps. My 
>>first app did a little form processing using the cgi module. Performance 
>>isn't a huge issue, but I'm curious on how to pep it up if the need 
>>should arise. I'm a bit confused on other solutions like FastCGI and 
>>Mod_Python. If I decided to use FastCGI, would I need to significantly 
>>change my code? 
>>    
>>
>
>The main impetus for using fastCGI or Mod_Python is to avoid starting a
>whole new process for each HTTP transaction.  This becomes an issue on
>very high traffic sites OR where your script needs to go through
>elaborate initialization routines.  The jonpy module (from sourceforge)
>can simplify a fastCGI script.  Jonpy provides a different interface to
>the parameters and environment as compared to the cgi module.  However,
>it is easy to feed the jonpy parameters into the cgi module so that most
>of a fastCGI script is similar to a regular cgi script.  Only the
>"startup logic" needs to be different.  In a simple case, the startup
>logic is the call to cgi.fieldstorage which gets replaced by a jonpy
>cgihandler class which accepts the jonpy parameter objects.  These can
>be fed to cgi.fieldstorage.  Make the rest of the cgi script into a
>function that gets the cgi.fieldstorage object as a parameter.  (I hope
>that made sense.)
>
>I have found that most web sites will work quite nicely through the
>regular cgi interface.  Even establishing database connections each time
>the script is run normally works OK.
>
>The jonpy module provides a simple set of tools to handle the creation
>and re-use of resources such as database connections.
>
>  
>
>>I didn't get the impression that you just install it, 
>>modify your apache config, and import FastCGI in your code instead of 
>>the cgi module. The same with Mod_Python. Could someone briefly explain 
>>the differences in coding cgi, FastCGI, or Mod_Python if there are any 
>>differences?
>>    
>>
>
>fastCGI and Mod_python require more configuration of the web (apache)
>server.  Mod_python allows for much tighter integration with the apache
>server.  Each HTTP request goes through a series of steps within
>apache.  Mod_python gives you the means to add scripting at each step.  
>
>I have NOT done any mod_python scripting.  I have not found fastCGI to
>be necessary.  I keep a test server configured so that I can run fastCGI
>scripts and I practiced converting a couple of cgi scripts to fastCGI. 
>It was NEVER necessary to actually deploy a fastCGI script into
>production.
>
>  
>
>>Thanks,
>>
>>Mike Hansen
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>    
>>



More information about the Tutor mailing list