Learn about Centmin Mod LEMP Stack today
Register Now

Sysadmin Best option for multiple web servers with load balancer?

Discussion in 'System Administration' started by Jake B., Oct 7, 2017.

  1. Jake B.

    Jake B. New Member

    5
    3
    3
    Nov 19, 2015
    Ratings:
    +5
    Local Time:
    8:34 PM
    Currently our setup is this:

    [​IMG]

    Wondering if there is any benefit of this over cutting out the two extra nginx installs and just connecting the main one directly to the PHP-FPM as the upstream?
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,933
    6,911
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,407
    Local Time:
    12:34 PM
    Nginx 1.13.x
    MariaDB 5.5
    Redundancy is key - what happens if load balancer is down ? In current config, you can easily fall back to just the backend Nginx servers. If you remove those, you have nothing web server wise.

    I usually install the load balancer each of the backend web servers so if you have 2x web servers you'd have 2x load balancers - one of each web server. Then have load balancers failover between each of them. So on a 5x web server cluster, I'd have 5x load balancers too which can failover. Any one of the web backend servers can take over as load balancer if need be.
     
  3. Jake B.

    Jake B. New Member

    5
    3
    3
    Nov 19, 2015
    Ratings:
    +5
    Local Time:
    8:34 PM
    The setup we have currently isn't really in place for redundancy as the database also lives on the same server as the load balancer so if it's down the database is down as well, it's only there because of the large amount of traffic.

    Would there be any performance gain to having the load balancer nginx connect directly to each php-fpm instance bypassing that second nginx instance?

    And if I did want to setup the two php servers nginx to be a load balancer since I guess it is possible that something could happen to nginx without affecting mariadb, would I bypass nginx from the primary load balancer and have each app server connect directly to the php-fpm? Currently using CloudFlare for DNS and it's caching so would I set each app server as an A record for the domain to do that?
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,933
    6,911
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,407
    Local Time:
    12:34 PM
    Nginx 1.13.x
    MariaDB 5.5
    you'd have to test for yourself to find out :)

    You'd want to pick one of the load balancers as primary and that would be one cloudflare connects to and you'd have to configure load balancer failover yourself.
    you'd usually have that anyway - well you should
     
    Last edited: Oct 7, 2017
  5. Jake B.

    Jake B. New Member

    5
    3
    3
    Nov 19, 2015
    Ratings:
    +5
    Local Time:
    8:34 PM
    Currently the way it's setup is that CF points to the one nginx server, and then that has an upstream for both of the app servers which then point to their own local php-fpm server. It's a setup I've inherited that I've spent the better part of the day cleaning up. I don't think I'll be doing multiple load balancers just because the primary is on the database server and I've never had an issue with nginx randomly crashing without the whole server being down as well. I may do some experimenting with eliminating nginx on the two app servers though and setting the upstreams on the primary to hook directly to php-fpm rather than the current setup because it seems like it'd be more performant. Thanks!
     
    • Informative Informative x 1