| ryah ( @ 2009-01-29 02:26:00 |
| Entry tags: | rant |
Public Service Announcement: the "P" in "HTTP" stands for "protocol"
FastCGI is a special protocol for HTTP proxies to speak to backends. I think most are missing the absurdity of this. Let's review what happens:
- the (frontend) proxy server receives a HTTP request.
- it parses the HTTP and rewrites it in into the FastCGI protocol
- the proxy transfers it to your backend process (PHP, Rails, etc)
- the backend process parses the FastCGI and processes the request
- the backend sends a reply to proxy using FastCGI
- the proxy parses the FastCGI and rewrites it into HTTP
- the proxy sends the reply to the client.
It's not like FastCGI is infinitely easier to parse or extremely more compact. Indeed, FastCGI is hard enough to parse that someone has invented: SCGI (Simple CGI). If you notice, the headers and message body in SCGI are still sent in their original encoding - SCGI only saves a couple of characters—a few "\r\n" here and there, "HTTP/1.1", etc.—but at the cost of introducing an entirely new protocol. Even more ridiculous, Passenger Phusion (an apache module which load balances Rails instances and restarts them when they die) has invented their own HTTP transfer protocol despite the popularity of the Mongrel HTTP server library in Ruby. Who knows how many others are doing this behind closed doors.
These "optimizations" only complicate things. HTTP is a fine protocol: an open standard which quite literally is becoming the backbone of our society. It is understood by countless software. It has support for all sorts of various features. It's even compact when compared with things like XMPP.
There are well tested, feature-full, fast, free, stand-alone, easy-to-use HTTP parsers out there. There is no excuse to use SCGI, FastCGI, or to invent your own HTTP-transfering protocol.
So please, the next time you're thinking about which protocol to use to transfer HTTP messages, just choose HTTP.