views:

136

answers:

4

Hi all, I've been refactoring some code running on a simple LAMP box on my network. I noticed that there really isn't any particular reason why we're using Apache aside from being able to say it's a LAMP setup.

I've heard of some other options (lighttpd, nginx, etc.) and was wondering what benefit using these would provide over using Apache. I'm running PHP 5.2 through FastCGI on Apache 2 as of right now. Would another platform provide better performance? Would setup or maintenance be more or less of an issue? Would reliability be affected?

I'm asking this as a purely hypothetical question; I don't really intend to change the platform of the server(s), I'm just curious about why one might choose one of the other apps over Apache.

Thanks in advance

A: 

Hip-Hop for PHP


Since this is purely hypothetical and you don't really have any intention of changing... I'll throw this answer in the direction of another option you could take.

Take a look at HPHP. Hip-Hop for PHP. Take a read of this. http://developers.facebook.com/news.php?story=358&blog=1

You can download HipHop and then translate and compile your PHP scripts to optimised C++ code, from here : http://github.com/facebook/hiphop-php

What is Hip-Hop?


Essentially : It is a PHP compiler that translates PHP code to C++ code. Then using something like g++ you can compile it to native binaries. Which once used as a replacement for lets say a LAMP stack, will save time and CPU.

Here is a quote from Haiping (who I believe is creditted as the project leader along with Scott and Dave.)

How HipHop Works

The main challenge of the project was bridging the gap between PHP and C++. PHP is a scripting language with dynamic, weak typing. C++ is a compiled language with static typing. While PHP allows you to write magical dynamic features, most PHP is relatively straightforward. It's more likely that you see if (...) {...} else {..} than it is to see function foo($x) { include $x; }. This is where we gain in performance. Whenever possible our generated code uses static binding for functions and variables. We also use type inference to pick the most specific type possible for our variables and thus save memory.

The transformation process includes three main steps:

  • Static analysis where we collect information on who declares what and dependencies,

  • Type inference where we choose the most specific type between C++ scalars, String, Array, classes, Object, and Variant, and

  • Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions.

Laykes
What's your experience with using HipHop? Was it successful for you?
Greg Hewgill
Well, if you are signed up the mailing list, someone called Chris just posted a case study of his benchmark on his site. This is what he said. >>>>>>>>> I finally got myself in a position where I could benchmark my projects speed increase... According to a quick 'siege' my software's front page loads 2.38x faster (138% faster). Not bad!
Laykes
+2  A: 

There are tons of reasons why one person would choose one given platform over another. As an apache user myself, I like that it is incredibly easy to deploy and manage under linux. It has a large user-base, and great documentation (first-party and third-party).

Lighttpd is made for speed. It looks like it supports PHP now, but it was originally designed and (probably still) best used for serving static content, at ridiculous speeds.

If you're a Microsoft kinda guy, IIS would look really appealing.

I've never used nginx.

Hope that helps.

E-man
About Microsoft.. I saw this today and just laughed. http://www.microsoft.com/WEB/websitespark/ Microsoft I think are as distant to the Web developer community as... well... they just aren't appealing to any developers in my opinon right now.
Laykes
+1  A: 

Try Zend Server CE(php stack from Zend, with optimizer and cache plus a nice gui).
I admire lighttpd for it's threading system but it's a nono with php.(thread safe modules are a nice dream.).
And nginx is really fast but it ventures off the syntax(configs) I'm used with.
lighttpd and nginx are really fast but I would only use them for static content.
As a fellow php developer i really recomend zend server for dinamic content and either lighttpd or nginx for static content.
(P.S. I know this is an intranet thing but it's nice knowing you've made them run as good as posibble.),Cheers.

DCC
A: 

S.O is not really the place for hypothetical discussions.

Even if its for the stated objective of improving performance, there's no simple answer as to what's the right solution. Monkey httpd + PHP might be right answer for someone working with an embedded server, the only time IIS would ever make sense is to workaround the bugs in Microsoft's SSL implementation, for some poeple tux might be the answer, or a CDN, or squid reverse proxying an LVS cluster of Xitami servers. And yes, the answer to Facebook's problem was HipHop.

If you have a problem which needs to be solved then ask away - but the answers so far seem to be solutions for a problem which does not exist.

C.

symcbean
This isnt an answer. If you don't think its a question don't respond!
Laykes
On the contrary, I'm asking a very relevant question: what are the costs and benefits of alternative PHP setups? I'm simply giving a bit of context by presenting my situation; just because I'm not instituting the ideas presented here immediately doesn't mean I'm ignorant to them.
mattbasta