Is there a speed difference between WSGI and FCGI?

Question:

From the web I’ve gleaned that WSGI is a CGI for python web development/frameworks. FCGI seems to be a more generalised gateway for a variety of languages. Don’t know the performance difference between the two in reference to the languages python and C/++.

Asked By: torger

||

Answers:

They are two different things. WSGI is a Python specific interface for writing web applications. There are wrappers for about any web server protocol to provide the WSGI interface. FastCGI (FCGI) is one of such web server protocols. So, WSGI is an abstraction layer, while CGI / FastCGI / mod_python are how the actual web servers talk to the application. Some code has to translate the native interface to WSGI (there is a CGI module in wsgiref, there is flup for FastCGI, etc.). There is also mod_wsgi for Apache, which does the translation directly in an Apache module, so you don’t need any Python wrapper.

Correct, WSGI is a Python programmatic API definition and FASTCGI is a language agnostic socket wire protocol definition. Effectively they are at different layers with WSGI being a higher layer. In other words, one can implement WSGI on top of something that so happened to use FASTCGI to communicate with a web server, but not the other way around.

In general, FASTCGI being a socket wire protocol means that you always need some type of programmatic interface on top to use it. For Python one such option is WSGI. As FASTCGI is just a means to an end, one can’t really compare its performance to WSGI in that case because WSGI isn’t a comparable socket wire protocol, but a user of FASTCGI itself.

One could try and compare performance of different language interfaces on top of FASTCGI, but in general that is quite meaningless in itself as the lower network layer and server request handling aren’t the bottleneck. Instead your application code and database will be.

Answered By: Graham Dumpleton
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.