Aditya Zaqi
Aditya Zaqi

Reputation: 303

nginx responds very slow on static files

While trying to see why my site is sometimes slow I have logged the response time. Just saw that even on static files my server sometimes responds in over 10 seconds. There seems to be no connection with cpu load: cpu never exceeds 15-20%. From the logs I have extracted the requests that take a long time(time is at end in format xx.xxx):

5.12.91.156 - - [14/Nov/2015:08:10:38 -0500] "GET /images/favicons.ico HTTP/1.1" 200 1150 "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 OPR/33.0.1990.58" 11.016 - .
109.98.160.230 - - [14/Nov/2015:08:10:48 -0500] "GET /images/favicons.ico HTTP/1.1" 200 1150 "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36" 10.570 - .
188.36.248.14 - - [14/Nov/2015:08:11:38 -0500] "GET /img/aaaaaa.jpg HTTP/1.1" 200 50415 "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36" 15.209 - .
31.13.112.119 - - [14/Nov/2015:10:05:47 -0500] "GET /img/bbbbbb.jpg HTTP/1.1" 206 42511 "-" "facebookexternalhit/1.1" 16.658 - .
31.13.112.118 - - [14/Nov/2015:10:05:47 -0500] "GET /img/bbbbbb.jpg HTTP/1.1" 206 42511 "-" "facebookexternalhit/1.1" 16.655 - .
77.119.130.173 - - [14/Nov/2015:10:06:19 -0500] "GET /css/stylo-1.css HTTP/1.1" 200 6933 "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36" 11.211 - .
173.252.73.112 - - [14/Nov/2015:10:08:42 -0500] "GET /img/cccccc.jpg HTTP/1.1" 200 78396 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" 19.288 - .
79.113.19.0 - - [14/Nov/2015:10:09:40 -0500] "GET /js/responds.js HTTP/1.1" 200 3627 "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0" 30.451 - .

my nginx config is very basic:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    log_format timed_combined '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent" '
    '$request_time $upstream_response_time $pipe';

    access_log /var/log/nginx/access.log timed_combined;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##

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

I can't figure out what the problem is :(

Upvotes: 2

Views: 1940

Answers (1)

Aditya Zaqi
Aditya Zaqi

Reputation: 303

I had to drop that VPS completely. I installed everything on a brand new VPS and everything is fine.

I still don't know what the problem was but since it doesn't happen on the new server I don't care what it was.

Upvotes: 2

Related Questions