Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I usually code in PHP, and always used apache. I have started my own website but I soon realised that apache is not the best solution to have: it uses 15MB of memory per page, making a small server running out of memory with something like 200 concurrent users.

Now, I was looking at other solutions, and had a quick look at lighttpd or nginx so my question is:

using a lighter option such as the above two, will make my servers being able to handle more users? The reason I am asking is also because, as my website is growing as I type here, there are going to be some serious costs on the server side, going on this way, when I will have 2000 users, I would need 10 web servers, this is not acceptable.

I also read about node.js and Express, would these be valid alternatives for PHP? I am not developing a real time application like a chat but something more like a forum.

Thanks in advance.

share|improve this question

closed as not a real question by Tom O'Connor, Skyhawk, Holocryptic, voretaq7, MDMarra Jan 23 '12 at 17:54

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Everything you have asked is hugely dependent on your application -- We cannot profile your environment for you (well, we can, but not on an internet Q&A site, and not for free :-) -- You need to investigate this for yourself using load testing in your development environment... –  voretaq7 Jan 23 '12 at 17:05
add comment

4 Answers

up vote 1 down vote accepted

It highly depends on the "profile" of your website/webapp.
Does it use SQL alot, do you serve more dynamic content or more static content?
How many Requests/Second are you having?

I went through your situation a few months ago, i also had a rapidly growing website on my hands and did not know that to do, after doing some research & testing i went with the following toolset:

php-fpm dameon
APC Caching
lighttpd/fastcgi connection to the fpm daemon

It works really well, before that i was simply using apache/php with eaccelerator and it was struggeling at 50 requests/second.
Now i am having 300+ requests/second on the same hardware, the server is not even breaking a sweat.
One advantage of lighttpd/nginx or the likes is the ability to serve static files with a very small footprint and little overhead, whereas apache w/o fastcgi will use quite a big footpring even if serving static files.

php-fpm enables you to seperate the preprocessing from the serving layer of you infrastructure, paired with APC Caching, this makes for a good performing toolset.

share|improve this answer
    
is there any way i can contact you? –  Enrico Tuttobene Jan 24 '12 at 14:02
    
Please use the contact form at my website –  Niko S P Jan 24 '12 at 18:05
add comment

you can try using nginx as reverse proxy+static content server and still have apache to handle your dynamically generated pages [php etc]. in this way you'll be able to work with familiar environment and benefit from smaller memory/cpu footprint of nginx.

you'll have to run apache on a different port or different ip and make simple request routing logic in nginx.

for tutorials look for instance here.

regarding alternatives - try your luck on stackoverflow. nginx should play nicely as a reverse proxy for nodejs too.

share|improve this answer
add comment

I would go with nginx all the way. How much memory does your current server have? Are you sure PHP is the problem? It could also the mysql server (if any) that uses all the memory if it's a forum

share|improve this answer
    
the database is in another server so that's not the case. it's not about the memory it's about the costs related to renting the server: i can add any server or make it larger in memory but that would cost me money, so i was looking for a solution which would take the least resources per connection –  Enrico Tuttobene Jan 22 '12 at 19:02
add comment

Nginx will certainly use less memory than than Apache. One issue with that will be most hosting providers will give you a control panel to configure Apache but few do that for nginx. This means you will have to configure the server manually, this also means you are unlikely to get any support from your host. Administering a web server with 2000 concurrent users running forum software is hard. Now it might be this is a community site that will tolerate some downtime and that you learn fast but you should bear this aspect in mind. You will be able to reduce the memory usage of Apache by disabling any modules you are not using and running PHP as fast-cgi instead of an Apache module. Do some testing.

nodejs is really cool and light on memory however you will have to learn a whole new programming paradigm. It's a valid alternative but wheather it's a realistic challenge for you is another matter.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.