I have a quite small VPS on AWS (EC2 t2.nano) that is running an nginx server. while sometimes a sudo service nginx reload
or nginx -t
is blazing fast, most of the time it is horribly slow (>60 seconds) without any load on the server.
There are ~10 server blocks defined as proxies 3 of them with ssl enabled.
nginx-t -v
does not give any clue, why it is so slow, I cannot find anything in the logs. RAM and CPU usage are quite low during that.
how can I investigate what makes a reload of nginx that slow, what are common thing, I could look for? DNS Resulutions? My upstreams are all defined as e.g.
upstream ent-pbmcom {
ip_hash; # for sticky sessions
server 10.0.2.52:8080;
}
...
server {
...
location / {
add_header X-Block "ent-pbmcom";
add_header X-Upstream $upstream_addr;
add_header X-Requested-Host '$host';
proxy_pass http://ent-pbmcom;
proxy_set_header X-Real-IP $remote_addr; # http://wiki.nginx.org/HttpProxyModule
proxy_set_header Host $host; # pass the host header - http://wiki.nginx.org/HttpProx$
proxy_http_version 1.1; # recommended with keepalive connections - http://nginx.org/$
# WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
}
}