Differences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?
Solution 1
A part answer to your question, including scgi.
- What's the difference between scgi and wsgi?
- Is there a speed difference between WSGI and FCGI?
- How Python web frameworks, WSGI and CGI fit together
CGI vs FCGI
Lazy and not writing it on my own. From the wikipedia: http://en.wikipedia.org/wiki/FastCGI
Instead of creating a new process for each request, FastCGI uses persistent processes to handle such requests. Multiple processes can configured, increasing stability and scalability. Each individual FastCGI process can handle many requests over its lifetime, thereby avoiding the overhead of per-request process creation and termination
Solution 2
There's also a good background reader on CGI, WSGI and other options, in the form of an official python HOWTO: http://docs.python.org/2/howto/webservers.html
Solution 3
In a project like Django, you can use a WSGI (Web Server Gateway Interface) server from the Flup module.
A WSGI server wraps a back-end process using one or more protocols:
- FastCGI (calling a server process)
- SCGI (Simple Common Gateway Interface - a simpler FastCGI)
- AJP (Apache JServ Protocol - a Java FastCGI)
- mod_python (runs pre-loaded code per request - uses lots of RAM)
- CGI (Common Gateway Interface, starts a process per request - slow)
Solution 4
- FastCGI is a kind of CGI which is long-live, which will always be running.
- With FastCGI, it'll take less time.
- Because of multi-processes, FastCGI will cost more memory than CGI.
Related videos on Youtube
![Parker](https://i.stack.imgur.com/WowPn.png?s=256&g=1)
Parker
Duke 2013 Microsoft PM '13-Present I like Python. Also, turtles.
Updated on July 05, 2022Comments
-
Parker almost 2 years
I'm just wondering what the differences and advantages are for the different CGI's out there. Which one would be best for python scripts, and how would I tell the script what to use?
-
Parker over 13 yearsIs mod_wsgi faster? My current server uses CGI, what reasons are there to switch?
-
Koroviev over 13 yearsPossible duplicate: stackoverflow.com/questions/219110/…
-
user1066101 over 13 yearsWe can't tell you if mod_wsgi will be faster in your environment. You have to actually measure them in your environment with your constraints and your applications and your configuration.
-
anatoly techtonik over 12 years
mod_wsgi
is Apache only. Is it still the most popular in 2012?
-
-
xorcus over 10 yearsThere is a FastCGI stdio library (marcos) that let you make a single program capable of running both as CGI and as FastCGI app: fastcgi.com/devkit/doc/fastcgi-prog-guide/ap_guide.htm
-
user345602 almost 10 yearsQuestion about FastCGI: How it handle simultaneous connections with one process when PHP itself is blocking language ? What if I have something "sleep(100)" . Wont it block the process for the other users ? Thanks
-
GiriB about 7 yearsThis is a great resource for beginners.
-
lesnik over 6 yearsLooks like the url is obsolete. But this one works: docs.python.org/2/howto/webservers.html