# Nginx + Thin cluster of 3. Which Thin took the request?

**URL:** <https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234>\
**Category:** NGINX\
**Created:** [February 10, 2010, 11:38am UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234 "2010-02-10T11:38:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 10, 2010, 11:38am UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/1 "2010-02-10T11:38:37Z")

</div>

Hi, I just managed to setup a front end web server with Nginx and then a  
cluster of 3 Thin servers behind it who serve instances of the same app.

At least the app responds properly through Nginx.  
After making a request, how can I find out which app actually processed  
the request? The only log I see growing is the development.log  
I have thin.300x.log files but don’t increase in size when requests are  
made…

Thanks

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 11, 2010, 12:18pm UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/2 "2010-02-11T12:18:47Z")

</div>

Anyone?  
I’m trying to get some logs using the http\_upstream\_ prefix but no luck  
yet…

Cheers.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 11, 2010, 12:32pm UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/3 "2010-02-11T12:32:49Z")

</div>

On Thu, Feb 11, 2010 at 12:18 PM, comopasta Gr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Anyone?  
> I’m trying to get some logs using the http\_upstream\_ prefix but no luck  
> yet…

Can you add a response header from within your app? something like  
X-I-Am-Pid with the pid of the serving process? or even just monitoring  
with  
top sorted by cpu usage (if 3 thins are active, it’s all 3, otherwise  
it’s  
not balancing!

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 11, 2010, 12:43pm UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/4 "2010-02-11T12:43:56Z")

</div>

Hello!

On Thu, Feb 11, 2010 at 12:18:47PM +0100, comopasta Gr wrote:

> Anyone?  
> I’m trying to get some logs using the http\_upstream\_ prefix but no luck  
> yet…

Well, probably you have no headers named Upstream-\* got from  
client. If you instead need headers you got from upstream - use

$upstream\_http\_…

instead.

Maxim D.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 17, 2010, 11:37am UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/5 "2010-02-17T11:37:03Z")

</div>

Hi again,

Thanks for the hints. I was trying to use $upstream\_http\_… but that  
didn’t print out anything.

This is all in development environment so no big loads or anything. Just  
testing the setup.

I actually managed to verify that the cluster is operative. By checking  
with Process.pid that I get responses from the three pids that belong to  
each server of the cluster.

But I would guess that Nginx should know to which app server is  
forwarding the request (?) I a more friendly way…

Cheers.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 17, 2010, 12:03pm UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/6 "2010-02-17T12:03:17Z")

</div>

On Wed, Feb 17, 2010 at 11:37:03AM +0100, comopasta Gr wrote:

> each server of the cluster.
> 
> But I would guess that Nginx should know to which app server is  
> forwarding the request (?) I a more friendly way…

Try to log $upstream\_addr.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [February 17, 2010, 1:32pm UTC](https://www.ruby-forum.com/t/nginx-thin-cluster-of-3-which-thin-took-the-request/183234/7 "2010-02-17T13:32:30Z")

</div>

Thanks Igor! I am pathetic at reading documentation 😛  
[http://wiki.nginx.org/NginxHttpUpstreamModule#.24upstream\_addr](http://wiki.nginx.org/NginxHttpUpstreamModule#.24upstream_addr)

Yes $upstream\_addr prints out the address of the server that handled the  
request!

Thanks!
