Load balancer question

Hi everyone,
I am starting to work with nginx to use it as a load balancer for a web
service. Basically, what I am try to configure is something like:

$ cat nginx.conf

http {

       upstream load_balancer {
           server localhost:8080/Instance1;
           server localhost:8080/Instance2;
           server localhost:8080/Instance3;
   }

   server {
           listen 81;
           server_name;
           location / {
                   proxy_pass http://load_balancer;
           }
   }

}

I would like nginx to manage the requests among the three instances
above, depending on the load. Is it correctly defined? How can I test
that my request are properly managed by nginx?
Thanks in advance,

Cheers

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos group
liability cannot be triggered for the message content. Although the
sender endeavors to maintain a computer virus-free network, the sender
does not warrant that this transmission is virus-free and will not be
liable for any damages resulting from any virus transmitted.

Este mensaje y los ficheros adjuntos pueden contener información
confidencial destinada solamente a la(s) persona(s) mencionadas
anteriormente y pueden estar protegidos por secreto profesional.
Si usted recibe este correo electrónico por error, gracias por informar
inmediatamente al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos
no se hace responsable por su contenido. Su contenido no constituye
ningún compromiso para el grupo Atos, salvo ratificación escrita por
ambas partes.
Aunque se esfuerza al máximo por mantener su red libre de virus, el
emisor no puede garantizar nada al respecto y no será responsable de
cualesquiera daños que puedan resultar de una transmisión de virus.

Hi,

I would like nginx to manage the requests among the three instances above,
depending on the load. Is it correctly defined?

what you have defined is a round-robin-based loadbalancing,
what you probably would like to do is a loadbalancing based on the
connections processed:

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#least_conn

“Specifies that a group should use a load balancing method where a
request
is passed to the server with the least number of active connections,
taking
into account weights of servers. If there are several such servers, they
are
tried in turn using a weighted round-robin balancing method.”

please read Module ngx_http_upstream_module
for more available loadbalancing-methods

How can I test that my request are properly managed by nginx?

create a dummypage on each server and / or check the logs on your
appserver.

cheers,

mex

Posted at Nginx Forum:

On Tue, Nov 11, 2014 at 04:42:56PM +0000, Tinte garcia, Miguel Angel
wrote:

Hi there,

http {

       upstream load_balancer {
           server localhost:8080/Instance1;
           server localhost:8080/Instance2;
           server localhost:8080/Instance3;
   }

I would like nginx to manage the requests among the three instances above,
depending on the load. Is it correctly defined? How can I test that my request are
properly managed by nginx?

sbin/nginx -t

nginx: [emerg] invalid host in upstream “localhost:8080/Instance1” in
/usr/local/nginx/conf/nginx.conf:14
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

“upstream” must not include any part of the url.

You will probably better match nginx’s idea of load-balancing if you
can use “/Instance” on each of three different host:port combinations.

f

Francis D. [email protected]