Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do web frameworks serve via FastCGI/SCGI, rather than HTTP?

Major web frameworks (such as Django, Pyramid, Rails, etc) are often run as persistent servers, with a separate web server like nginx serving as a frontend. The web server connects via a protocol like FastCGI or SCGI:

browser --[http]--> nginx --[fastcgi]--> flup -> django

This seems convoluted to me; why is the request converted to an entirely different protocol, when the backend could just run its own HTTP server?

browser --[http]--> nginx --[http]--> wsgiref -> django

This approach appears to be both simpler and more flexible, since there's only one transport protocol and it's an RFC.

However, I don't think I've ever seen a web framework encourage the http-only design, so I assume there must be a reason for it.

What are the advantages of using a protocol like FastCGI/SCGI here?

like image 232
John Millikin Avatar asked Jan 19 '12 05:01

John Millikin


1 Answers

HTTP is a large, complex protocol. Paring the interface down to the capabilities provided by FastCGI or WSGI allows the framework to handle requests faster than if it had to deal with the original.

like image 168
Ignacio Vazquez-Abrams Avatar answered Oct 18 '22 12:10

Ignacio Vazquez-Abrams