Forum: NGINX Debugging nginx Load Balancer

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (arungupta)
on 2009-04-29 07:44
I'm using nginx 0.6.36 for a load balancing a cluster of GlassFish Gem.

Is there a debug level or statement that can be added to nginx.conf that
will log the instance serving the request ?

-Arun
96321bb7fd6f712aa7785ce2d58388f2?d=identicon&s=25 Anton Yuzhaninov (Guest)
on 2009-04-29 09:11
(Received via mailing list)
Arun Gupta wrote:
> I'm using nginx 0.6.36 for a load balancing a cluster of GlassFish Gem.
>
> Is there a debug level or statement that can be added to nginx.conf that
> will log the instance serving the request ?

1. nginx should be build with ./configure --with-debug

2. add ip to debug requests to nginx.conf:

events {
   debug_connection 10.10.1.1;
}
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (arungupta)
on 2009-04-29 15:47
Thanks for the response!

nginx was built using --with-debug, here is my complete CLI:

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin --with-debug
--with-http_ssl_module

nginx and GlassFish gem are all running on the same box for my
experiment, i.e. 127.0.0.1. So I updated the existing events entry as:

events {
    worker_connections  1024;
    debug_connection 127.0.0.1;
}

Saw no new messages in access.log and lots of messages in error.log but
no information on the port being servicing the request.

Am I missing something ?

-Arun

Anton Yuzhaninov wrote:
> Arun Gupta wrote:
>> I'm using nginx 0.6.36 for a load balancing a cluster of GlassFish Gem.
>>
>> Is there a debug level or statement that can be added to nginx.conf that
>> will log the instance serving the request ?
>
> 1. nginx should be build with ./configure --with-debug
>
> 2. add ip to debug requests to nginx.conf:
>
> events {
>    debug_connection 10.10.1.1;
> }
96321bb7fd6f712aa7785ce2d58388f2?d=identicon&s=25 Anton Yuzhaninov (Guest)
on 2009-04-29 16:49
(Received via mailing list)
Arun Gupta wrote:
> events {
>     worker_connections  1024;
>     debug_connection 127.0.0.1;
> }
>
> Saw no new messages in access.log and lots of messages in error.log but
> no information on the port being servicing the request.
>

This should be in error.log

May be I misunderstood your question, but if you want to know upstream
port, you may add to
access_log format variable $upstream_addr

http://wiki.nginx.org/NginxHttpUpstreamModule#.24u...
http://wiki.nginx.org/NginxHttpLogModule
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (arungupta)
on 2009-04-29 20:07
> May be I misunderstood your question, but if you want to know upstream
> port, you may add to
> access_log format variable $upstream_addr
>
> http://wiki.nginx.org/NginxHttpUpstreamModule#.24u...
> http://wiki.nginx.org/NginxHttpLogModule
Ok, that took care of logging.

I created a cluster of 3 backend servers and the access.log now shows
...

127.0.0.1 - [127.0.0.1:3002] - [29/Apr/2009:11:03:43 -0700] GET /runlogs
HTTP/1.1 "200" 621 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X
10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1
Safari/525.27.1" "-"
127.0.0.1 - [127.0.0.1:3000] - [29/Apr/2009:11:03:43 -0700] GET
/stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889
"http://localhost/runlogs" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X
10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1
Safari/525.27.1" "-"
127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:11:03:43 -0700] GET
/favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs" "Mozilla/5.0
(Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1
(KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-"

The port is shown as the second parameter in each log line, that's good!
But I expected the request to be served by only one instance, why all 3
?

-Arun
96321bb7fd6f712aa7785ce2d58388f2?d=identicon&s=25 Anton Yuzhaninov (Guest)
on 2009-04-29 20:34
(Received via mailing list)
Arun Gupta wrote:
> /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs" "Mozilla/5.0
> (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1
> (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-"
>
> The port is shown as the second parameter in each log line, that's good!
> But I expected the request to be served by only one instance, why all 3

It seems to be 3 different requests and they was served by different
upstreams because of load
balancing  upstreams.
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (arungupta)
on 2009-04-29 20:42
>> The port is shown as the second parameter in each log line, that's good!
>> But I expected the request to be served by only one instance, why all 3
>
> It seems to be 3 different requests and they was served by different
> upstreams because of load
> balancing  upstreams.
Interesting ...

If I curl the page then I see only one log entry but invoking the page
from the browser still shows 3 log entries.

Any idea why 3 requests are made from the browser ?

-Arun
2e321cc0efe9422d37165e922298494e?d=identicon&s=25 Cliff Wells (Guest)
on 2009-04-29 21:01
(Received via mailing list)
On Wed, 2009-04-29 at 20:42 +0200, Arun Gupta wrote:
>
> Any idea why 3 requests are made from the browser ?

Most browsers will use several separate connections per domain for
downloading separate elements (Firefox defaults to 8 for normal
connections, 2 for persistent connections).  Your keepalive settings for
Nginx can affect this number.

I believe wget can only use one under all circumstances.

Cliff
0d6e745fce90a0a70ce2a2e8923d2323?d=identicon&s=25 Aaron Starr (Guest)
on 2009-04-29 21:38
(Received via mailing list)
> Any idea why 3 requests are made from the browser ?
>
> -Arun

It looks to me like three requests were made, because it's getting
three different resources:

    GET /runlogs
    GET /stylesheets/scaffold.css?1240977992
    GET /favicon.ico

Probably because the HTML at /runlogs refers to the stylesheet and
icon, and the browser goes and gets them to display them. No?
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (arungupta)
on 2009-04-29 21:53
Ok that explains part of it!

curl (wget on Mac) is indeed using single request. I set
keepalive_timeout to 0 but still see 3 requests being made.

-Arun

Cliff Wells wrote:
> On Wed, 2009-04-29 at 20:42 +0200, Arun Gupta wrote:
>>
>> Any idea why 3 requests are made from the browser ?
>
> Most browsers will use several separate connections per domain for
> downloading separate elements (Firefox defaults to 8 for normal
> connections, 2 for persistent connections).  Your keepalive settings for
> Nginx can affect this number.
>
> I believe wget can only use one under all circumstances.
>
> Cliff
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (arungupta)
on 2009-04-29 21:55
> It looks to me like three requests were made, because it's getting
> three different resources:
>
>     GET /runlogs
>     GET /stylesheets/scaffold.css?1240977992
>     GET /favicon.ico
>
> Probably because the HTML at /runlogs refers to the stylesheet and
> icon, and the browser goes and gets them to display them. No?
Ok, that explains it!

I guess now static file caching needs to be enabled which will reduce
the trip to back-end servers, right ?

-Arun
14eddebaded16496d1198b2e43d44946?d=identicon&s=25 Jauder Ho (jauderho)
on 2009-04-30 00:32
You need a block that will cause nginx to serve static files directly.
Something like


    location ~* ^.+\.(css|js)$ {
        root /var/www/foo;
        access_log off;
        expires max;
        break;
    }
836cd8a8f9a053f5468d7487a13f808b?d=identicon&s=25 Chris Jackson (chrisj46)
on 2009-05-15 23:18
Arun Gupta wrote:
> I'm using nginx 0.6.36 for a load balancing a cluster of GlassFish Gem.
>
> Is there a debug level or statement that can be added to nginx.conf that
> will log the instance serving the request ?
>
> -Arun

you should switch over to a load master 2500 because the load master
2500 is an essential component of high-availability, clustering and
fault tolerance, all of which provide the infrastructure for reliable
Internet sites and corporate intranets.

<a
href="http://www.kemptechnologies.com/load-balancer-2500...
836cd8a8f9a053f5468d7487a13f808b?d=identicon&s=25 Chris Jackson (chrisj46)
on 2009-05-15 23:19
Arun Gupta wrote:
> I'm using nginx 0.6.36 for a load balancing a cluster of GlassFish Gem.
>
> Is there a debug level or statement that can be added to nginx.conf that
> will log the instance serving the request ?
>
> -Arun

you should switch over to a load master 2500 because the load master
2500 is an essential component of high-availability, clustering and
fault tolerance, all of which provide the infrastructure for reliable
Internet sites and corporate intranets.

http://www.kemptechnologies.com/load-balancer-2500...
This topic is locked and can not be replied to.