# Upstream keepalive debugging

**URL:** <https://www.ruby-forum.com/t/upstream-keepalive-debugging/236432>\
**Category:** NGINX\
**Created:** [September 3, 2013, 2:42pm UTC](https://www.ruby-forum.com/t/upstream-keepalive-debugging/236432 "2013-09-03T14:42:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 3, 2013, 2:42pm UTC](https://www.ruby-forum.com/t/upstream-keepalive-debugging/236432/1 "2013-09-03T14:42:56Z")

</div>

Hi  
I seem to have an issue where the upstream keepalives aren’t being  
re-used

proxy\_http\_version 1.1;

upstream dev1 {  
server 10.0.0.11 max\_fails=0;  
keepalive 1024;  
}

location /  
{  
proxy\_pass [http://dev1](http://dev1);  
proxy\_set\_header Connection “”;  
}

On a separate server I run ‘ab -n 500 -c 500  
[http://10.0.0.10/test/blah.txt](http://10.0.0.10/test/blah.txt)’ … a few times waiting say 10 seconds  
between runs

on the main server I can do netstat between runs, here’s the results:

root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
2  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
260  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
758  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
950  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
1308  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
1748  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
1992  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
2316  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
2767  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
3063  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
3392  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
3491  
root@dev0:/root # netstat -n | grep “10.0.0.11.80” | grep “ESTAB” | wc  
-l  
3787

It shouldn’t ever need more than 500 connections to the upstream, but it  
keeps making more? and doesn’t stick to the 1024 limit…  
What’s going on?

nginx/1.4.1 / FreeBSD 9.1

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [September 3, 2013, 3:19pm UTC](https://www.ruby-forum.com/t/upstream-keepalive-debugging/236432/2 "2013-09-03T15:19:46Z")

</div>

Ah, let me guess - is the keepalive number “per worker”?

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [September 3, 2013, 3:25pm UTC](https://www.ruby-forum.com/t/upstream-keepalive-debugging/236432/3 "2013-09-03T15:25:02Z")

</div>

Hello!

On Tue, Sep 03, 2013 at 02:19:32PM +0100, Richard K. wrote:

> Ah, let me guess - is the keepalive number “per worker”?

Sure, and it’s what documentation explicitly states, see

> **[Alphabetical index of directives](http://nginx.org/en/docs/dirindex.html)**

: The connections parameter sets the maximum number of idle  
: keepalive connections to upstream servers that are preserved in  
: the cache of each worker process.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
