Welcome! Log In Create A New Profile

Advanced

Re: Upstream setup with proxy and fastcgi?

Francis Daly
April 18, 2011 02:36PM
On Mon, Apr 18, 2011 at 01:45:54PM -0400, TECK wrote:

Hi there,

> [ 1.localserverip (main load balancer, with nginx and php-fpm installed)
> ]
> |
> ---- + [ 2.localserverip (node with php-fpm installed) ]
> |
> ---- + [ 3.localserverip (node with php-fpm installed) ]
> |
> ---- + [ 4.localserverip (node with php-fpm installed) ]
>
> A better graphical example can be viewed in this image:
> http://farm6.static.flickr.com/5023/5631528237_9153f0d4a5_o.gif

There's still something of a lack of explicitness here. The words show one
nginx (load balancing) http server plus four php-fpm fastcgi servers. The
picture shows the load balancer plus multiple web servers.

Putting them together, what I *think* you have is:

one nginx http server which does the load balancing, plus

many nginx http servers which do file serving, plus

many php-fpm fastcgi servers which do php processing,

where each fastcgi server is on the same machine as a file-serving nginx;
and also one of the file-serving nginx servers is on the same machine
as the load-balancing nginx server.

> Basically, 1.localserverip is the site entrance, where nginx load
> balancing is done.
> Each server (including the 1.localserverip) will have the exact same
> content into /var/www/html directory.
> The served content consist in static (images, cass, js, etc.) and php
> files.

Igor mentions "don't load-balance static stuff".

If you want to do it anyway, for failover reasons for example, then the
load-balancing nginx server would have something like

location / {
proxy_pass http://proxy;
}

and the file-serving nginx servers would just have something like

root /var/www/html;

> My goal is to be able to load balance not only the proxy but also the
> fastcgi.
> What would be the configuration like?

There are two different ways you can do this.

If you decide "load balancer shall know about fastcgi", then you will
have something like

location [php urls] {
fastcgi_pass php;
}

where [php urls] is the appropriate string or regex. That will be on
the load-balancing nginx server; the file-serving nginx servers won't
have any mention of fastcgi.

Alternatively, you could let the file-serving nginxen handle fastcgi --
in that case, the load balancer would have

location / {
proxy_pass http://proxy;
}

and the file servers would have

location [php urls] {
fastcgi_pass this_php_server;
}

It's an extra level of proxying for the fastcgi stuff, and it means that
one http server is pretty much tied to one fastcgi server; but since the
fastcgi server is accessing the same filesystem as the http server, the
"-e $filename" and other file-related cleverness in nginx can work.

I suggest just setting up a quick test, and seeing if one plan doesn't
work well enough for you.

Good luck,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Upstream setup with proxy and fastcgi?

TECK April 14, 2011 02:15PM

Re: Upstream setup with proxy and fastcgi?

TECK April 16, 2011 06:49PM

Re: Upstream setup with proxy and fastcgi?

Igor Sysoev April 18, 2011 10:12AM

Re: Upstream setup with proxy and fastcgi?

TECK April 18, 2011 11:13AM

Re: Upstream setup with proxy and fastcgi?

TECK April 18, 2011 12:29PM

Re: Upstream setup with proxy and fastcgi?

Francis Daly April 18, 2011 01:08PM

Re: Upstream setup with proxy and fastcgi?

TECK April 18, 2011 01:45PM

Re: Upstream setup with proxy and fastcgi?

TECK April 18, 2011 02:25PM

Re: Upstream setup with proxy and fastcgi?

Igor Sysoev April 18, 2011 02:02PM

Re: Upstream setup with proxy and fastcgi?

TECK April 18, 2011 02:45PM

Re: Upstream setup with proxy and fastcgi?

Francis Daly April 18, 2011 03:04PM

Re: Upstream setup with proxy and fastcgi?

Igor Sysoev April 18, 2011 02:30PM

Re: Upstream setup with proxy and fastcgi?

Francis Daly April 18, 2011 02:36PM

Re: Upstream setup with proxy and fastcgi?

TECK April 18, 2011 03:11PM

Re: Upstream setup with proxy and fastcgi?

TECK April 22, 2011 05:02AM

Re: Upstream setup with proxy and fastcgi?

Francis Daly April 23, 2011 06:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready