Results 1 to 7 of 7

  1. Post

    NGINX vs Apache2 on PHP website

    So I've been playing with Apache2 and NGINX. Many say use NGINX as a reverse proxy in front of Apache. And others say just use NGINX.

    I've got two NGINX reverse proxies using KeepAlived (so one at a time) pointing at two app servers.

    I put NGINX on one server, and Apache on the other and had them both connected to their own SQL server with multi-master replication (so they're identical).

    Finally I also had them listen on their own subdomain so I could access each server directly.

    Now, I've run load tests against each with 10,000 clients accessing a light and a heavy page across a time span under a minute.

    Name:  Screenshot from 2019-11-21 11-34-42.png
Views: 123
Size:  20.5 KB

    So, they're basically identical but NGINX JUST wins with a more common load (product). No error rate means no errors. And I didn't bother with lower loads on Apache home as there was no errors at 20s.

    As a result, I've gone purely NGINX on my app servers so I only have to remember how to configure one engine.

    The reason for this thread is:
    Is there anything I'm missing out on binning Apache2?

    Some amazing wonderful function that will make my life easier that I'd be better off using Apache2 only on the App Servers (seeing as performance is close enough between the two) instead of NGINX only.

  2. Post
    There used to be a significant performance gap between the two of them a while ago mainly when apache defaulted to using prefork for request handling (there were two other options but while they were fast were badly documented and badly supported)

    I think with that latest 2.4 apache they defaulted to some event based handling method along the same line as nginx so there is no large gap between them as you have found.

    nginx is significantly nicer as a reverse proxy (even though I'd prefer haproxy over nginx for that job) but for general web server stuff it's really down to personal preference and/or integration into existing stuff.

    so to answer your question - no not really, i'd just stick with nginx

  3. Post
    Sweet, thanks, that's what I needed to know.

  4. Post
    Switching to HAProxy,

    Health Checks are Nginx Plus (using their servers as yet another Proxy that's a paid service) only and whilst I'm now going to send MySQL requests to the Proxy rather than dedicating them to the App Servers (rendering the Health Checks unnecessary and letting me have an uneven number of SQL/App servers that are load balanced with varying hardware) it looks like a better option overall.

    My problem was that one of the SQL servers didn't automatically reconnect to the pool, so one of the App Servers on WordPress would just return UNABLE TO CONNECT TO DATABASE, which Nginx thought was fine and dandy. I modified WordPress to return a 503 instead but only with Nginx Plus could I flag an HTTP error code as being a server down.

    So every refresh would have a chance of dumping you on a server that says the DB is down.

    Thus I'm segregating the pool of SQL servers and dumping them on the Proxy to deal with, in theory this means an app server shouldn't ever go "down" without actually going down (and automatically getting skipped), making Nginx usable but HAProxy seems to be able to do a few things natively I'd need Nginx Plus to perform.

  5. Post
    Seems reasonable, haproxy is very good as a tcp loadbalancer not only for http- i've run a heap of wordpress sites on an environment pretty much the same as what you have set up and it seemed to go pretty well.

    One thing you might find valuable if you aren't already doing it is passing a user agent header into the haproxy heathcheck, that way you can parse it out in your app logs so it doesn't fill up with those checks (and also making the healthcheck page a static page of some kind to reduce unneeded load). You can also do some geo blocking/routing pretty easily with a couple of acls which can be handy to remove unwanted countries

    Also I didn't realise those basic features were locked behind plus :/ it's ****ing expensive as well which is funny cause haproxy is probably better and doesn't cost anything

  6. Post
    Yeah, turns out non-HTTP routing (TCP/UDP) is also Nginx Plus. So I have to make the switch either way.

  7. Post
    Pretty cool, HAProxy cut down my config file from like 180 lines on Nginx down to like 40 to achieve the same thing plus the TCP routing and load balancing for MySQL. I don't split the domains out at all and LetsEncrypt certs are dumped into a folder and it snoops out the right one to terminate and update the headers, then SSLs again to the servers.

    Definitely way better than Nginx. Stats should be fun as well when I actually look into it.