5 ms·
PHP is much better than CGI, because it doesn't have to load an interpreter and all libraries per request -- they were loaded at server startup time. This is w
by brendano 15y ago
PHP is much better than CGI, because it doesn't have to load an interpreter and all libraries per request -- they were loaded at server startup time. This is why all serious web frameworks don't use CGI. But PHP avoids the administrative/stability problems of persistent servers -- Python, Java, Ruby -- by disallowing state across requests.
I think, because PHP servers are so stable, that's part of why they're so common on shared web hosts. For example, running a WSGI server is much more complicated. If a WSGI app goes bonkers you have to restart the relevant server. In mod_php, just kill the process.
What would be interesting is a forking-style server for Python or another reasonable language.
- slurgfest 15y agoIt isn't true that "if a WSGI app goes bonkers you have to restart the relevant server." This is between you and your specific app server, it isn't a matter of WSGI.
- brendano 15y agoPHP has no app servers to go bonkers.
- Lazare 15y agoUm. We're getting a little bogged down here, but... 1) PHP is commonly implemented via CGI by many webhosts, even today. Not only is it generally considered more secure, but it lets you easily run multiple versions behind the same Apache instance. The performance hit isn't bad, either. So I'm not sure what "PHP is ... better than CGI" even means. 2) PHP is not particularly stable and it is not uncommon for a PHP process to hang until killed, often soaking up 100% CPU time. The stateless nature does make it easier to just kill it whenever it goes crazy, but it doesn't really have anything to do with how often it goes crazy. 3) You can configure servers in all sorts of ways, but there's nothing inherently harder about WSGI. You absolutely can just "kill the process". 4) I honestly have no idea what you mean by "a forking-style server for Python". Is there something you dislike about all the current ones? :)
- lmm 15y ago> 3) You can configure servers in all sorts of ways, but there's nothing inherently harder about WSGI. I'm willing to believe this - but if it's true, where are the cheap shared webhosts with WSGI enabled? Or do you think there's some other reason PHP is so much more widely available?
- Lazare 15y agoPeople seem really hung up on the idea that Python and WSGI are not supported by cheap shared webhosts. If you ever think "gee, I wish I had some decent shared WSGI hosting for less than $10/month" the answer is Webfaction. :) http://news.ycombinator.com/item?id=3826416 http://news.ycombinator.com/item?id=3826416 (@lmm: Sorry, I can't reply directly to your post.)