Jump to content
MDDHosting Forums

Planned awesome web server stack


kuemerle5

Recommended Posts

Alright, so, if you've read the previous two threads in this forum, you'll know that I'm planning on setting up a web server from scratch on a VPS. In this post, I'm going to detail the process I plan to use and possibly some tips/tricks that will help others along the way. Now, onto the good stuff ;)

 

After much research and option weighing, I have come to the conclusion that I will be using Apache + PHP fgci behind Nginx. Now, before everyone gets into an uproar as to why I just didn't opt all for Nginx, I'll explain why:

  • Running Apache behind Nginx will allow me to retain mod_rewrite capabilities, so that I don't have to deal with rewriting the rules specifically for Nginx.
  • Using Apache + PHP fcgi over mod_php was decided because of the lower memory footprint which is vital is pretty much any server environment. Using fcgi does have its downsides though; I will be unable to set PHP directives from the htaccess file as I have grown used to over the years. This means that I will have to come up with a PHP configuration that kicks butt and works well for my combination of mostly WordPress and Drupal powered sites.
  • Much faster page load times; duh!
  • Applications will see that they are being run from Apache, which is good because some web apps might disable certain functions if they detect they are being run on different server software.

All in all, I think I've come up with a winning combination; I've added awesome page load times but really only lost functionality that was negligible to begin with (setting PHP directives from .htaccess). I felt that if I went all Nginx, I would be adding complexities that, quite frankly, I didn't know/want to deal with with the only benefit of *maybe* getting slightly better load times and less memory usage. Another high performance web server that I looked at was Cherokee. Cherokee is probably just as fast and lightweight as Nginx (don't quote me on that :P) and also includes an awesome web interface to configure the server. Unfortunately, like Nginx, Cherokee does not have mod_rewrite compatibility and again, I'm not going to run mission critical web server software that I don't know how to fully work in case something were to go wrong. All of the above also applies to lighttpd.

 

Now, onto the database layer in that juicy web stack. I will being running Percona just because I have yet to see an argument yet about why I shouldn't run it. In the WHT forums, a guy said that I probably will not notice the difference between Percona and MySQL for the size of my server. Keeping in mind that memory is king, I wanted something like Nginx that could handle connections consistently even when put under a lot of stress. It is possible to optimize MySQL to use less memory by more or less following the "my-small" config to reduce the memory footprint and such. However, this does not address the issue that the InnoDB storage engine simply cannot handle as many transactions as the XtraDB engine can.

 

OK, so the big stuff is out of the way now but there are still more things I can do to optimize my setup. First thing is some sort of caching mechanism. While I haven't looked into caching and Nginx I do have experience with Apache, PHP, and XCache and let me tell you, XCache is truly amazing. For those of you who don't know, XCache is a PHP opcode cacher made by the same folks who make lighttpd. I never really thought much of of XCache until I installed it on my buddy's server and let me just share some of the statistics:

  • 480.07Kb file reduced to 69.63Kb
  • 30.70Kb file reduced to 3.03Kb
  • 5.35Kb file reduced to 637.00b (that's bytes folks)

On average, with the current configuration, XCache has approximately 120 files cached at any one time. But I must warn you: XCache was not easy to configure. Not the syntax, but the "best" settings. It took me a while to figure out the settings which worked best and it's going to be different for each server. For example, in the beginning my OOMs (out of object memory) were going through the roof and I just had to play with the setting to keep the number as low as I could. Another issue I ran into was the memory filling up right away which is also no bueno. For those of you really curious, I've uploaded a screenshot of the XCache overview page to see my config and the general "stats". To those of you now wanting to use XCache: I strongly urge you to build it yourself as I couldn't find any up to date repos and building it was super simple; just follow the instructions.

 

The second step you can take to speed up your server is CloudFlare which you can easily opt into here at MDDHosting through your CPanel (w00t!). Not only does it do an awesome job at caching files but it also functions as your DNS server which is just another load off of your machine. There's not much to say about CloudFlare except to just use it!

 

Sorry about the writing slowly turning to crap from top to bottom (quite tired as I write this) but hopefully, you get my general gist. Hopefully, I'll get this thing running on a sandbox server in the next few days and present even more findings! Also, I'll be running Ubuntu server 11.10 (the latest) with dropbear for the SSH server as it uses less memory than OpenSSH. Yay less memory usage!

Link to comment
Share on other sites

Nice stack! That's actually very close to what one of my VPSs has. It runs Debian 6, Cherokee, PHP-FPM, Percona, and CloudFlare on top of that. It really is a great set-up. AMAZINGLY fast. Cherokee is much faster than LiteSpeed and Apache and a little faster than Nginx.

 

P.S. Cherokee and Nginx do rewrites, it's just not apache compatible. They do this because mod_rewrite is extremely inefficient (not as bad in LiteSpeed then in Apache).

 

EDIT: Duh... I forgot I posted in the other thread you made. Now it makes sense why it's somewhat similar to what I had.

Link to comment
Share on other sites

Nice stack! That's actually very close to what one of my VPSs has. It runs Debian 6, Cherokee, PHP-FPM, Percona, and CloudFlare on top of that. It really is a great set-up. AMAZINGLY fast. Cherokee is much faster than LiteSpeed and Apache and a little faster than Nginx.

 

P.S. Cherokee and Nginx do rewrites, it's just not apache compatible. They do this because mod_rewrite is extremely inefficient (not as bad in LiteSpeed then in Apache).

 

EDIT: Duh... I forgot I posted in the other thread you made. Now it makes sense why it's somewhat similar to what I had.

 

Haha, thanks! Yes, my recent threads in this forums have been similar :P

 

I would like to use Cherokee if only it were compatible with mod_rewite (then, I would be willing to learn all the ins and outs of it) but I figured Nginx and XCache will at least get me close to Cherokee speeds. :) Do you have anything set up (available to the public) on your server to see performance? Also, just curious, but why did you choose Debian over Ubuntu server? Oh, and another question: is Percona administered in a similar manner to MySQL? E.g I can use phpMyAdmin and such?

Link to comment
Share on other sites

Research Update

 

After reflecting upon Apache + PHP fcgi, I have come to some conclusions and extra information.

 

  1. If you are not using mod_php, it would be an extreme n00b mistake to install prefork for Apche's MPM. Best option would be to use either worker or event (which I believe is the method Nginx employs but is currently experimental in Apache). @Adam: Do you know if Cherokee is also event based?
  2. Since mod_php is not guaranteed to be thread friendly (due to all the libraries), I am ultimately forced to use some sort of cgi processing for PHP.
  3. PHP FPM I feel is currently the best route. This is because you get the benefits of fastcgi (process continues to live after being used, eliminates startup times, etc.) and will allow me to have a separate server solely to execute PHP scripts (need be). This has one big benefit: If the server is receiving enormous amounts of traffic, I can order up another node and have it up and running with PHP FPM. Just a quick fyi: PHP FPM can listen on either a TCP/IP port or utilize a socket connection. At this point, I can have, say, 2 of my sites switched over to use the new node's PHP FPM which will reduce load on the first node. While this route is definitely trickier, I think it's worth it to have a server(s) that functions as efficiently as possible. And, to be honest, I think this whole PHP FPM thing is overkill because I will be using XCache so the whole separate node to process PHP thing is pretty much never going to happen.

I guess that's pretty much it. The big thing was really just getting rid of the ancient, disgusting monster that is Apache prefork.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...