Apache or nGinx?

Discussion in 'HOWTO-Related Questions' started by Vinay Samant, Apr 16, 2020.

?

Apache or nGinx?

Poll closed Apr 23, 2020.
  1. Apache

    50.0%
  2. nGinx

    50.0%
  1. Vinay Samant

    Vinay Samant Member

    I am using Debian Apache2 & ISP since some years now and it's always very comfortable experience till date.
    Recently i worked on a government website that we hosted on my personal server for time being. On day of promotion, website received 65000+ hits in just 2-3 hours. This crashed Apache completely and overall performance of server was completely compromised. All other websites also went down and response time was almost 4-5 minutes per page.. so many requests aborted.. lot of mess..

    this server is 4c8t, 16GB RAM, Debian, Apache2, mySQL, ISP3.1.13 .. it's php7.3 fpm configured with higher limits.
    Experts advising me to install nGinx instead of Apache2 to get better experience.
    All my websites are wordpress & drupal. I always have multiple users & authorities on all CMS. I also have some membership driven websites in wordpress. So caching is always not solution for me. Many pages have custom code, blocks those need to be dynamically presented as per logged in user. Apache does this all well & I never faced any issue. Now the question is, will that be same experience on nginx? will wordpress & drupal behave same. They say nginx is 2.5times faster than apache. But while this speed, its equally imp for me to present dynamic content per user. will that happen?

    I m already upgrading to higher config server with 32GB RAM & NVEMs.. so i want to take call whether to install apache or nginx on this new server.. plz advice..
     
  2. nhybgtvfr

    nhybgtvfr Active Member

    I don't think this so-called speed differential is really that large. yes nginx is faster for static content (and that's where that 2.5 x faster result came from), it's never done php itself, it's always passed that off directly to php, whilst apache handled the php content itself. but with apache configured with mpm event and using php-fpm, it's no slower that nginx for dynamic content:

    you're more likely to see significant speed/concurrency improvements by tuning apache and MySQL to the expected workload, and if possible, optimizing the MySQL queries. and of course, faster disks, and more cpu/ram always helps. :p

    I don't know what cms you're using, I know that with varnish cache, used with magento, it cached and served static content from varnish, and also did full page caching, but it also allowed blocks of page content to be left as dynamic, so varnish would handle all the static parts and still pass the dynamic bits over to apache/php and embed the returned content back into the cached page. I assume that similar is possible with plugins/extensions for wordpress/joomla etc, but haven't looked for any myself.
     
  3. Vinay Samant

    Vinay Samant Member

    i stumbled upon this https://w3techs.com/technologies/history_overview/web_server/ms/y
    see the popularity of apache n nginx .. is this something i should be considering??

    i mainly use wordpress as CMS. Some of my clients user wordpress membership modules. So different members with different membership see different courses/articles. Anonymous users get fast response, but logged in user experience lag. Some of my wordpress frontends are dynamic. I show randomly selected articles from encyclopedia. Also some are news websites, where breaking news, latest news are displayed dynamically.. this sometimes needs updated per 10-15 minutes.. so cache doesn't help much...

    Some sites are in Drupal. Drupal has very powerful caching. And many things work automatic there. But server is becoming slow with increasing number if hits. sometimes we get 800 online users per second, due to this government website. This slows down the whole thing..

    So do u think still i should stick with apache? I am upgrading to 32GB RAM server with SSD and 500mbps network. should i get systems installed in configured by some expert??
     
  4. nhybgtvfr

    nhybgtvfr Active Member

    I can't really answer specifically nginx/apache.
    a lot depends on how much you (or colleagues) know about nginx and apache, or will/can learn/understand of nginx.
    i'm not sure switching will give you a big performance gain, and you might need to relearn a lot first.. so it may not be worth it, but that's just my opinion, there's probably a lot of nginx evangelists on here that will still urge you to switch.

    obviously nvme disks will help with file access/write times. more ram will give room for more apache / nginx / php processes to run without swapping. more cpu's/core's will obviously allow you to run more processes simultaneously without having to wait for cpu time.

    everything else comes down to tuning / optimizing what you've got.
    google will return plenty of advice on tuning apache, nginx and MySQL. you'll even find a mysqltuner.pl script that will offer suggestions for improving your db server performance. it's just that there is no fixed answer for tuning, it's not a one time thing, it needs to be redone regularly as your visitor patterns change.
    you could even look at offloading static content to a cdn, freeing up more capacity for dynamic content.

    for a particularly busy site, you may want to look at putting it on it's own server. or replication/loadbalancing, or changing the hosting architecture for that site completely: https://medium.com/@naveed125/how-t...ordpress-cluster-almost-for-free-d1a9e4c79ab5
     
  5. nhybgtvfr

    nhybgtvfr Active Member

    maybe start running sites/pages through gtmetrix.com, pingdom.com etc if you don't already. see what can be done to improve the performance of each individual site. you may find some sites are loading very large image files, and lots of little css/js scripts that can be optimized, compressed, combined to reduce file searches/load times, processing, caching etc. enough little gains here and there can soon mount up....
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Personally, I use nginx for all new servers that I set up. But Nginx reguires special rules for most CMS, so it's not that easy when you host sites for clients that want to manage the sites on their own.

    What I can recommend you for your current setup is to start reading on MySQL optimization and using mysqltuner. In many cases, this has a large impact when you have a lot of traffic to choose the right buffer sizes etc.
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Is there a way to monitor database performance while websites load? I'm examining why site made with Concrete 5 is so very slow. Currently I suspect it makes massive amouns of database queries, which slows down page loads. On the order of first 5 seconds spent with database and then browser starts loading page.
    I plan to use mysqltuner, but I would be meaningfull to monitor before and after and compare.
     
  8. nhybgtvfr

    nhybgtvfr Active Member

    you can try mytop, although that only show's snapshots of what's running at each interval, never really used MySQL workbench, maybe that has something? or percona or severalnines etc may have something useful, though they're not usually cheap...
    SolarWinds database performance analyser starts at £350, although you can get a 14 day free trial, might be enough for you to work out what you need before it expires....

    you can see what queries the site is making by turning on MySQL logging, to log all queries, so it's obviously not something you want left on for long...and when it's on, it's on for all queries on all databases.
    not ideal, but it will at least give you an idea of just how many queries it makes for each page, and it only costs lot's of disk space ;)
     
  9. Vinay Samant

    Vinay Samant Member

    thanks for your replies and everyone who is giving time in this. i m really learning a lot out of this process..

    my observations :
    • i m currently having 2 servers. One personal on SoYouStart.com and one with Amazon for state government. Both installed with ISPConfig. SYS server is debian & Amazon is CentOS. I never faced any issue with my server in last 4-5 years.. or even more. I am extremely happy with ISP and it's functions. But i face many issues in CentOS and frequently. Even right now my phpmyadmin is shot. CentOS and ISP doesn't jell well, or i didn't manage to configure it correctly. But this is one more thing i will like to mark here - I am 1st developer to bring ISPConfig to IT setups & AWS in our State Government. Initially i faced a lot of reluctance but now everyone has seen the performance & ease of use. So sooner ISPConfig will root deeper in my state government for sure. And i am very thankful & grateful to ISPConfig developer(s) & their staff. You people are awesome.
    • Looking at my work on 7 websites hosted on single server using ISP, government is giving me this 2nd job where i will be hosting 3 websites (or may be 5-6). One website https://mahainfocorona.in/ is drupal based website. It's my state government's initiative against corona to spread right information and awareness. This is the website that crashed my server. As government pushed news about this website, so many people rushed to it. Then we stopped promoting it. Now we are planning to host it on government AWS. So i got this server with 4Core, 16GB RAM, 250GB SSD, Debian 9. I have choice to install Apache or Nginx. Now most of the load on this website (plz check) are frontend pages. Various information officers all over state will upload some data per day. Max 500 post & write requests. Then all pages will show data in charts & graphs. If you see home page, it shows corona related news. They are dynamic. As department staff update news, these blocks are updated. Same is case on inner pages in sidebars. Then there is a filter page where people can search various essential facilities in their local areas and contact them. None of this is static and requires database interaction.
    • Then 2nd website will be my state government's official news media website. Staff will upload daily news with images, across day. And we expect a lot of traffic to this. This will be in wordpress with auto social-media promotion and notifications. Also PWA & mobile apps will be in place for this. This will bring a lot of attention n traffic. This will be hosted on same server..
    • Now looking at this scenario, i want to draw you people's attention to 1 imp thing - i m not server admin. I learn a lot of things from tutorials and advices from experts like you. I am full stack developer. But i am big zero in server technology. I want peace of mind just like my server. I was never bothered about any issue on my server. Now that i m getting Debian server from government also, (earlier it was not possible), i think if i stick to apache i will have good peace of mind. Please let me know if you people feel otherwise.
    • I use many analytical tools analyze page sizes, calculate response etc. but all the problem i m facing at moment is purely on webserver config. 1 bad thing is, i m on 250MBPS inter-phase at moment. And too much of traffic due to this one website.
    • So 2 things i m going to do -
      • hosting new government on Debian with ISPConfig & Apache
      • Upgrading my personal server with better RAM & NVEM. And sticking with Apache.
    Let me know if i m going wrong or need to change some things..
    Thanks a lot for you kind attention n support..
    Let me know best config options for Apache2.4, PHP7.4 FPM, MariaDB & anything else i should be configuring..

    @till - 1st of all thanks for such great ISPConfig & your personal attention in this thread. I am following your perfect server documentations. Why they are not with php7.4?
     
    till likes this.
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    PHP 7.4 is not supported yet by ISPConfig. This does not mean that parts of ISPConfig may not work when you use PHP 7.4, but we have not verified that yet as no supported Linux distribution ships with PHP 7.4 as base PHP version. Using PHP 7.4 as additional PHP for websites is fine though.

    Besides that, I highly recommend switching to Ubuntu or Debian if possible in your environment, you will see that it's way easier to install, maintain and that the resulting setup is way more stable than using centOS. centOS has the tendency to break things, actually not related to ISPConfig, the problem with centOS is that it does not have a central repository which contains all packages and where all packages get tested against each other, so with CentOS, you have to use several repos to get all required packages and this will sooner or later end in conflicts which finally cause the server to fail. Some other commercial panels get around this weakness of centos by actually not using any centos packages, they just use some basic things and compile everything else on their own, they basically build their whole own Linux distribution on top of the CentOS kernel, but that's not what we aim to do, we want to build a control panel that uses existing Linux distributions instead of building our own distribution.
     
  11. nhybgtvfr

    nhybgtvfr Active Member

    don't see any problems with that. I definitely find Debian/ubuntu a lot easier to use than centos. :)
    I assume these coronavirus sites are only intended to be short term (assuming the find an effective treatment). are you paying for the hosting and charging them? or are they paying? are they expecting a fixed price?

    just thinking that you might end up looking at some quite large servers to meet peak capacity, which could be doing almost nothing overnight but still racking up costs. you could create the sites outside of ispconfig, and instead of using ec2 instances, you could use ecs, that way you could still dockerise them like in the link in my second post above, drupal should dockerise in the same way. but using ecs instead of ec2, you don't need to pay for a large server, create multiple copies of the same ec2 instance. just configure scaling in ecs.
    just have one very small ecs cluster when nothing's happening, and a very large one when everyone piles onto the site.
    it's a lot harder to estimate the total hosting costs, but you are then only paying for the actual cpu and ram you need, not having a lot of spare capacity going idle at your expense when it's not busy. of course, that also means a lot more for you to learn if you don't already know ecs and docker...
     
  12. Vinay Samant

    Vinay Samant Member

    hii till,

    thanks again for your time.
    i m going debian way now. I burned my fingers with centos already.
    but just wondering if i can atleast install php7.3 at time of installation itself as base version. This will take away lot of headache. I dont need older versions as additional. Ideally 7.4 or atleast 7.3 is more than sufficient.

    **do u think ISP will break if i go with php7.4? i did a blunder where i uninstalled other versions of php on my production server. everything stopped including ISP. Even mysql related functions. Then i installed 7.4 and things went online smoothly. This actually happened on live server
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Debian 10 ships with PHP 7.3 as base version. Don't try to exchange base PHP versions, the only thing you get by this is an instable system.

    Apache: http://www.howtoforge.com/perfect-server-debian-10-buster-apache-bind-dovecot-ispconfig-3-1/
    Nginx: https://www.howtoforge.com/perfect-server-debian-10-nginx-bind-dovecot-ispconfig-3.1/

    You can then install PHP 7.4 for your websites as additional PHP version.

    https://www.howtoforge.com/tutorial...fig-3-from-debian-packages-on-debian-8-and-9/
     
  14. nhybgtvfr

    nhybgtvfr Active Member

    till is erring very much on the side of caution re: php7.4. and rightly so, it's never supported until the developers have confirmed it works ok.
    I've not used php 7.4 in production, but I have used it extensively as the only php installed on ubuntu 18.04 running ispconfig, I've done a lot of testing creating websites to host test/trial web applications to see if they'd be useful in our company, and so far it as worked flawlessly, and if i can't break it, it's well built ;). to the point where the only reason I haven't done that in production is that I haven't needed to create a new production server since 7.4 was released. so again, it's not supported, but I don't think you'll run into any problems doing so. it's up to you if you think it's worth the risk.
     
  15. Vinay Samant

    Vinay Samant Member

    i actually didn't understand a single word here, as i m 0 in server admin.
    it's compulsory to host every government site on their hosting environments. AWS is their standard at moment. Ideally they provide full-fledged AWS instance per site, but then i have understand whole AWS thing to manage it. It's too much to learn and for what? it's not my side. So I prefer Dedicated Server. I demanded independent server and they agreed. State government takes care of payments etc. So i m not worried. Ideally they would pay for 3 instances (or more) depending upon number of sites they are hosting. And AWS charge for licensed webserver, DB and everything.. So when i host their multiple websites on single ISP, i save a lot of money. They like me for this (and AWS hates me ;) ) .. so price is not much of concern in case of government..
    And yes, this corona website is just temperory. Will last only till July i suppose..
    But the 2nd news website is going to be central media website of my state government that will fetch a lot of attention and traffic. Every opinion of state government, policies, interviews will be propagated from this one. So just wanted to make sure that it will sustain that kind of load..

    And 2nd is about my own server that i am upgrading on SYS. I pay for it personally. I host websites for my clients on that server. Private clients, not government. I dont charge them separately. Hosting is part of my software/website package, always.
     
  16. Vinay Samant

    Vinay Samant Member

    It's worth risk. 1 website of my state government is Encyclopedia in a local language. You know, very few languages have something like encyclopedia. And i experienced a lot of performance gain when i switched from 7.3 to 7.4 .. It was installed as additional version..
     
  17. Vinay Samant

    Vinay Samant Member

    hii friends...

    finally i managed to install ISPConfig on Debian10. Everything went smooth. I have 2 things to bring to your attention -
    1. after installing php i get following message, which i ignored -
      NOTICE: Not enabling PHP 7.3 FPM by default.
      NOTICE: To enable PHP 7.3 FPM in Apache2 do:
      NOTICE: a2enmod proxy_fcgi setenvif
      NOTICE: a2enconf php7.3-fpm
      NOTICE: You are seeing this message because you have apache2 package installed.
      is it ok? or should i run it after completing installation or anytime in between?
    2. My ISP is now available at https://15.206.141.220:8080/ ... but i receive warning that security certificate is invalid. I have to add exception n access it. This happens always though certificate is generated during process of installation. Worse part is, i never manage to see/acces that certificate. It's broken/corrupted. How can i overcome this? This problem is on my each server..
    Can you people guide me for some apache, fpm and mariadb settings for high performance? Or links to some links in this regard please..
     
  18. Vinay Samant

    Vinay Samant Member

    one more thing..
    the installation instructions start from setting /etc/hosts and /etc/hostname files ... what if i change those values after installation? how much problematic this may be??
     
  19. till

    till Super Moderator Staff Member ISPConfig Developer

  20. till

    till Super Moderator Staff Member ISPConfig Developer

    These settings have been used by all services during installation, changing them afterwards requires that you change them in additional files like /etc/mailname, /etc/postfix/main.cf and in ISPConfig server settings.
     

Share This Page