Puzzled about WSGI vs. FastCGI

1,539 views
Skip to first unread message

Fred

unread,
Oct 24, 2012, 11:58:21 AM10/24/12
to django...@googlegroups.com
Hello

I'm trying to find how to install Python on a Lighttpd server that currently runs PHP scripts.

Although WSGI is the preferred deployment platform for Django, many people use shared hosting, on which protocols such as FastCGI, SCGI or AJP are the only viable options.

I'm puzzled, because I seemed to understand that WSGI is an API that relies on a lower-level transport solution like FastCGI, SCGI, or AJP.

Could it be that the article actually opposed mod_wsgi, which can run within Apache à la mod_php *?

And if someone knows of a good way to run Python through FastCGI (with or without WSGI) on Lighttpd, I'm interested: "Python FastCGI on lighty with flup" at the very bottom only seems to run a specific script.

Thank you.

* altough it can also run in its own process, just like FastCGI 

Nikolas Stevenson-Molnar

unread,
Oct 24, 2012, 12:46:55 PM10/24/12
to django...@googlegroups.com
The easiest way would probably be to run Gunicorn (http://gunicorn.org/) or some other WSGI HTTP server, and then configure lighttpd as a proxy, e.g: https://gist.github.com/514252

_Nik
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/5L_njBv3dUwJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Javier Guerra Giraldez

unread,
Oct 24, 2012, 3:26:37 PM10/24/12
to django...@googlegroups.com
On Wed, Oct 24, 2012 at 10:58 AM, Fred <frdt...@gmail.com> wrote:
> This article says:
>>
>> Although WSGI is the preferred deployment platform for Django, many people
>> use shared hosting, on which protocols such as FastCGI, SCGI or AJP are the
>> only viable options.
>
>
> I'm puzzled, because I seemed to understand that WSGI is an API that relies
> on a lower-level transport solution like FastCGI, SCGI, or AJP.

not exactly like that. it's not about which is higher-level, or which
runs on top of what... i see it more like a chain of protocol
conversions.

at one end, it's WSGI, it's a standard, a convention of how to call
Python functions to implement web applications. Django is implemented
as a WSGI application, so you need something that makes those WSGI
calls.

at the other end is the user browser, which does HTTP requests.

so, you need to translate HTTP requests to WSGI calls, and the
returned WSGI responses into HTTP responses.

there are HTTP-WSGI servers, like gunicorn, and tornado, and lots others.

there are also many HTTP servers that can use a multitude of back-end
protocols to talk to webapps.

Apache, for instance can do FastCGI. if so, you can use flup to serve
FastCGI with WSGI calls.

or you could use mod_wsgi to skip flup and keep the HTTP-WSGI within
Apache. (this is the recommended structure for Apache)

several other webservers can do FastCGI, like lighttp or nginx. in
all those cases you can still use flup.

but nginx is also a quite good HTTP-HTTP load-balancer, so you can use
gunicorn to serve HTTP behind nginx. this is a very popular setup.
or you can replace nginx with lighttp in proxy mode.

another very good alternative is uWSGI, which adapts several protocols
and calls WSGI apps (and others!). It was originally designed to use
a very compact and efficient protocol, mainly driven by a mod_uwsgi
add-in for nginx. this can be a very low-overhead, high-performance
option. uWSGI also has many, many options to administer the whole
system with great detail.

hope that helps.

--
Javier

Fred

unread,
Oct 24, 2012, 6:11:03 PM10/24/12
to django...@googlegroups.com
Thanks guys for the infos. It makes a lot more sense now.

So it looks like Lighttpd does not support the equivalent of mod_wsgi, so requires a second server that speaks either FastCGI or HTTP/WSGI.

Nikolas Stevenson-Molnar

unread,
Oct 24, 2012, 6:23:39 PM10/24/12
to django...@googlegroups.com
Correct. I've found proxying to an HTTP WSGI server to be eaisier as you don't need to configure passing of FastCGI params. I use Gunicorn with nginx, and it requires very little all around configuration. I would expect Gunicorn with lighttpd to be similar.

_Nik
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/n62KPozSRhcJ.

Fred

unread,
Oct 25, 2012, 8:55:05 AM10/25/12
to django...@googlegroups.com
Thanks Nik. I'll experiment.
Reply all
Reply to author
Forward
0 new messages