Apache2 or Nginx?

Started by tjbalon, May 20, 2016, 02:05:55 AM

Previous topic - Next topic

tjbalon

While I have read quite a few articles on the benefits of apache2 or nginx (linked below), I feel it will be most efficient to ask here, as I will be using this for my SMF Forum. We are quite a large forum, arriving at 250k posts soon, with quite a few unique connections per month.

https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations
https://community.rackspace.com/products/f/18/t/30

Recently I am choosing to move from a shared webhost (for the time, they kept me on a majority of my own dedicated stuff, friends with the owner of the company) on a 7200rpm hdd, an e3 processor, and ddr3 memory.

My configuration:
MySQL Server:
1 Dedicated Thread(A core on a hyper-threaded CPU) (E5-1630v3)
8 GB DDR4 ECC 2133 MHz
128 GB SSD Storage,
OS: Debian 8.3

WebServer:
1 Dedicated Core (2 threads of the hyper-threaded CPU) (E5-1630v3)
8 GB DDR4 ECC 2133 MHz
256 GB SSD Storage
OS: Debian 8.3
SMF 2.0.X

I have been using Apache2 for a long time, and I'm wondering if this move to the ssd, etc, will be night and day, or if I should move over to Nginx to feel the increase as well. I have been reading up that it is better performing, but some of these articles are outdated. While I understand what "asynchronously, allowing work to be handled in a non-blocking manner" means (nginx), I do not think I need this just yet, as a lot of the content on my website is not static, it is closer to dynamic, which is suggested to use Apache for.

Just looking for peoples opinions, experience, etc.

To add, if any of you have used this guide, do you know which are still relevant to today?
http://www.simplemachines.org/community/index.php?topic=293441.0

Thanks a ton in advance. Hoping this thread helps someone out in the future as well.

Arantor

The biggest question: do you use anything on your site that uses htaccess? E.g. SMF with Pretty URLs, Wordpress with the nice URL layouts...

tjbalon

Nope, just the standard stuff.

My biggest concern is if it's worth it to move over, or keep going with what I know. I don't care to do pretty URLs, etc. But if it's minor increase in efficiency, not worth it to me personally.

Also glad you responded, was hoping you would, I see helpful posts from you everywhere on here regularly, so thank you in advance!

Arantor

Well, that's where the headache comes, configuring pretty URLs on nginx is harder than on Apache.

My experience, interestingly, is that nginx when properly configured will be faster even for dynamic stuff than Apache is.

When Apache gets a PHP request, it has to load the PHP engine to process a PHP file. With nginx though, you don't have to do that every time, as instead you keep a collection of PHP processes in memory ready to handle the requests, meaning that you say that time and effort when starting PHP, and the difference can be surprising.

That said, setting up the necessary PHP configuration isn't the simplest to do, and if you're not in any real pressure to cope with load, I would probably leave it as is. If you need the extra oomph, though, make the change. Hopefully someone who is more of a server guy than I am will add something, though, I'm more of a programmer than a server admin...

And thanks, I try to help though it doesn't always go quite to plan...

vbgamer45

You are going to see a big increase just from moving from shared hosting to a dedicated as long as it is configured well.
SSD big boost right off the bat. All my servers now a days just use SSD for hard disks.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

tjbalon

Do either of you have your best recommendation for php.ini settings?

I have 8GB of memory on this, which can be expanded, shrunk, whatever. Therefore I can raise memory_limits, etc, to whatever will be most efficient.

Thank you for both of your responses, for now I am going to stay on Apache, and see how the SSD changes things, I can always change over in the future with a few commands and a lot of configuration, so it'll come down to testing.

---

Also going back to the guide I linked up top (on the SMF website), one biggest question is altering tables to ENGINE=InnoDB still more efficient than not? Or not for a large forum.

Thanks.

spiros

Have you considered LiteSpeed? It appears not to have any issues with .htaccess files.

LiteSpeed Web Server has been designed to run off Apache's httpd.conf and .htaccess files. There is no re-configuration necessary when you switch to LiteSpeed. LiteSpeed Web Server uses the settings you already have, but processes them with its event-driven architecture.
https://www.litespeedtech.com/products/litespeed-web-server/features/feature-explanations


As far as nginx, there is a tool here that might come in handy

http://winginx.com/en/htaccess

tjbalon

I'm not too concerned about pretty URLs, so that is fine, I can figure out .htaccess.

Just simply looking for the benefits, but thank you guys for your info! Will come in very handy if I decide to use them in the future.

Paracelsus

Changing from Apache to Nginx+PHP-FPM was definitely one of the best moves we ever made, apache works well with few users, but is lousy managing memory resources if you start having moments with lots of connections and clicks, the whole thing gets so slow it is totally unbearable.

tjbalon

Quote from: Paracelsus on May 21, 2016, 11:51:31 AM
Changing from Apache to Nginx+PHP-FPM was definitely one of the best moves we ever made, apache works well with few users, but is lousy managing memory resources if you start having moments with lots of connections and clicks, the whole thing gets so slow it is totally unbearable.

Thank you, I'll be testing it then.

Beautiful forum by the way!

青山 素子

Nginx is awesome, and great at being lightweight. Apache HTTPd can offer similar performance (especially with the newer worker MPM), but requires more configuration attention to get the results. For most people, unless they need Apache-specific stuff, nginx will be much easier to configure for performance.

My opinion is that you should go with what you feel most comfortable managing. For PHP under Apache HTTPd, you'll gain a lot by moving from mod_php to mod_fcgid and even better to fpm (via mod_proxy_fcgi).
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


nsno

Quote from: Paracelsus on May 21, 2016, 11:51:31 AM
Changing from Apache to Nginx+PHP-FPM was definitely one of the best moves we ever made, apache works well with few users, but is lousy managing memory resources if you start having moments with lots of connections and clicks, the whole thing gets so slow it is totally unbearable.

that was our experience too, once we switched from Apache to nginx we noticed a huge speed increase during our busier times, with much less server overloads

leghorn23

Honestly, if you have to ask: you're better off sticking with Apache. From my experience there is simply just more "out there" in the community to help you out with in terms of forums/stackoverflow/etc. Best of luck

forumside

Nginx is much better then Apache, and even for pretty urls you have and mod for nginx config.

Advertisement: