# Nginx slow connect

**URL:** <https://www.ruby-forum.com/t/nginx-slow-connect/217677>\
**Category:** NGINX\
**Created:** [March 8, 2012, 12:53pm UTC](https://www.ruby-forum.com/t/nginx-slow-connect/217677 "2012-03-08T12:53:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 8, 2012, 12:53pm UTC](https://www.ruby-forum.com/t/nginx-slow-connect/217677/1 "2012-03-08T12:53:13Z")

</div>

Im trying to diagnose a connection issue with nginx on debian. there is  
an delay of anything from 2-10 seconds on the connection, im using curl  
to test:

curl -o /dev/null -w “Connect: %{time\_connect} TTFB:  
%{time\_starttransfer} Total time: %{time\_total} \n” -s  
[http://example.com/forumhome.css](http://example.com/forumhome.css)  
Connect: 0.657 TTFB: 1.183 Total time: 7.150

Here is a pastebin of the tcpdump output for the curl request above:

> **[16:01:57.779354 IP x2x2x2.45182 \> xxx.www: Flags \[S\], seq 3482742138, win...](https://pastebin.com/2tdZHqFr)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

Server load averages 0.5 and never goes above 0.10

I have also tested using [webpagetest.org](http://webpagetest.org) from different locations and  
the same connection issue exists.

the files are served from an ssd mounted on another machine.

Linux main 2.6.32-5-amd64 #1 SMP Wed May 18 23:13:22 UTC 2011 x86\_64  
GNU/Linux

nginx conf:

```
user www-data;
worker_processes 4;
worker_rlimit_nofile 802768;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
use epoll;
worker_connections 60000;
multi_accept on;
}

http {

```

include /etc/nginx/mime.types;

# access\_log /var/log/nginx/access.log;

access\_log off;  
sendfile off;  
keepalive\_timeout 75;  
tcp\_nodelay on;  
keepalive\_requests 2000;  
connection\_pool\_size 8192;  
client\_body\_buffer\_size 1024K;  
client\_header\_buffer\_size 8k;  
client\_max\_body\_size 10M;  
fastcgi\_buffers 4 256k;  
fastcgi\_buffer\_size 128k;  
fastcgi\_busy\_buffers\_size 256k;  
large\_client\_header\_buffers 8 8k;  
ignore\_invalid\_headers on;

client\_header\_timeout 60;  
client\_body\_timeout 60;  
send\_timeout 60;

output\_buffers 8 32k;  
postpone\_output 0;  
server\_name\_in\_redirect off;  
server\_tokens off;

tcp\_nopush on;

gzip on;  
gzip\_min\_length 1100;  
gzip\_buffers 32 8k;  
gzip\_comp\_level 2;  
gzip\_types text/plain text/html application/x-javascript  
text/xml  
text/css text/javascript;  
gzip\_vary on;

include /etc/nginx/conf.d/_.conf;  
include /etc/nginx/sites-enabled/_;  
}

sysctl here → [kernel.sched\_child\_runs\_first = 0 kernel.sched\_min\_granularity\_ns = 3000000 - Pastebin.com](http://pastebin.com/iYEfv9xc)

site.conf:  
open\_file\_cache max=5000 inactive=20s;  
open\_file\_cache\_valid 30s;  
open\_file\_cache\_min\_uses 2;  
open\_file\_cache\_errors on;

```
server {

```

listen 80 ; ## listen for ipv4

server\_name [example.com](http://example.com);  
root /mnt/ssd/www/static;

location ~\* .(css|js)$ {

expires max;  
add\_header Pragma public;  
add\_header Cache-Control “public, must-revalidate, proxy-revalidate”;

}  
}

ifconfig eth0:  
eth0 Link encap:Ethernet HWaddr 00:15:17:26:b4:bd  
inet addr:x.x.x.x Bcast:x.x.x.x Mask:255.255.254.0  
inet6 addr: fe80::215:17ff:fe26:b4bd/64 Scope:Link  
UP BROADCAST RUNNING MULTICAST MTU:9000 Metric:1  
RX packets:1136534270 errors:0 dropped:0 overruns:0 frame:0  
TX packets:623191419 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:1000  
RX bytes:174357516836 (162.3 GiB) TX bytes:323522620298  
(301.3 GiB)  
Memory:e1a00000-e1a20000

cat /proc/cpuinfo:

model name : Intel(R) Core™2 Quad CPU Q6600 @ 2.40GHz

cat /proc/meminfo:

```
MemTotal: 4058884 kB
MemFree: 3366684 kB
Buffers: 117632 kB
Cached: 288320 kB

```

Posted at Nginx Forum:

> **[Nginx slow connect](https://forum.nginx.org/read.php?2,223627,223627#msg-223627)**
>
> Im trying to diagnose a connection issue with nginx on debian. there is an delay of anything from 2-10 seconds on the connection, im using curl to test: curl -o /dev/null -w "Connect: %{time\_connect} TTFB: %{time\_starttransfer} Total time:...
