83

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?

рüффп
  • 5,172
  • 34
  • 67
  • 113
Parker
  • 8,539
  • 10
  • 69
  • 98
  • Is mod_wsgi faster? My current server uses CGI, what reasons are there to switch? – Parker Oct 14 '10 at 20:38
  • Possible duplicate: http://stackoverflow.com/questions/219110/how-python-web-frameworks-wsgi-and-cgi-fit-together – Koroviev Oct 14 '10 at 20:38
  • We 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. – S.Lott Oct 14 '10 at 21:02
  • `mod_wsgi` is Apache only. Is it still the most popular in 2012? – anatoly techtonik Mar 28 '12 at 22:24

4 Answers4

47

A part answer to your question, including scgi.

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

Community
  • 1
  • 1
pyfunc
  • 65,343
  • 15
  • 148
  • 136
  • 1
    There is a FastCGI stdio library (marcos) that let you make a single program capable of running both as CGI and as FastCGI app: http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ap_guide.htm – xorcus Mar 30 '14 at 17:57
  • 1
    Question 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 – user345602 Sep 14 '14 at 18:52
19

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

user703016
  • 37,307
  • 8
  • 87
  • 112
Richard Boardman
  • 1,268
  • 15
  • 12
12

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:

In 2019, WSGI was superseded by ASGI (Asynchronous Server Gateway Interface), used by frameworks like FastAPI on servers like Uvicorn, which is much faster.

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
6
  • 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.

In Detail Diff between FastCGI vs CGI

naveenKumar
  • 367
  • 4
  • 10