'sudo nginx -s reload' and 'nginx -t' started to need a minute to complete

While using Ubuntu 10.10+Nginx0.9.3+php5-fpm 5.3.3-1ubuntu9.1:

Do you know of any reason for ‘sudo nginx -s reload’ and ‘nginx -t’
suddenly start needing almost a minute to complete?

while using:
server {
listen example.org:80;
server_name www.example.org .example.com 192.168.2.18;
rewrite ^(.*) http://example.org$1 permanent;
}
server {
listen example.org:80 default_server;
server_name example.org;
…/…

$ time sudo nginx -s reload
real 0m0.354s
user 0m0.336s
sys 0m0.012s

after adding:
server {
listen example.com:80;
server_name www.example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
server {
listen example.com:80;
server_name example.com;
…/…

$ time sudo nginx -s reload
real 0m56.152s
user 0m0.077s
sys 0m0.016s

$ nginx -V
nginx: nginx version: nginx/0.9.3
nginx: TLS SNI support enabled
nginx: configure arguments: --conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-client-body-temp-path=/var/lib/nginx/body
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi
–http-log-path=/var/log/nginx/access.log
–http-proxy-temp-path=/var/lib/nginx/proxy
–lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid
–prefix= --with-http_ssl_module --without-http_limit_req_module
–without-mail_pop3_module --without-mail_smtp_module
–without-mail_imap_module --without-http_split_clients_module
–without-http_uwsgi_module --without-http_scgi_module
–without-http-cache

$ cat /etc/hosts
127.0.0.1 localhost
192.168.2.17 mail.example.com example.com www.example.com example.org
www.example.org
192.168.2.18 mail.example.tld example.tld www.example.tld

cat /etc/network/interfaces
auto lo
iface lo inet loopback

Load IPTABLES firewall rules

pre-up iptables-restore < /etc/iptables.up.rules
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.2.17
network 192.168.2.0
netmask 255.255.255.0
broadcast 192.168.2.255
gateway 192.168.2.1
auto eth0:0
iface eth0:0 inet static
address 192.168.2.18
network 192.168.2.0
netmask 255.255.255.0
broadcast 192.168.2.255
gateway 192.168.2.1

Thank you.

M.

Hello!

On Mon, Dec 13, 2010 at 08:57:04PM +0000, Mark A. wrote:

rewrite ^(.*) http://example.org$1 permanent;

…/…

$ time sudo nginx -s reload
real 0m56.152s
user 0m0.077s
sys 0m0.016s

Most likely reason is example.com having problems with DNS
servers.

While reading/parsing configuration (which is done by both nginx
-t and nginx -s reload) nginx will try to resolve names in listen
directive. If it takes a while you’ll see large delays, exactly
as in your case.

Note that host names in proxy_pass directive are resolved as well,
so names there may delay loading as well.

[…]

$ cat /etc/hosts
127.0.0.1 localhost
192.168.2.17 mail.example.com example.com www.example.com example.org
www.example.org
192.168.2.18 mail.example.tld example.tld www.example.tld

You may want to check spelling for “example.com” here and in nginx
config.

Maxim D.

On Tue, 14 Dec 2010 01:28:14 +0300, Maxim D. [email protected]
wrote:

Most likely reason is example.com having problems with DNS
servers.

You were right, it was a DNS problem.

While reading/parsing configuration (which is done by both nginx
-t and nginx -s reload) nginx will try to resolve names in listen
directive.

I did not know that while testing nginx tries to resolve names (both in
listen and in proxy_pass).
It another a useful feature of nginx.
Knowing that would have made me think a DNS problem.

Thank you very much Maxim.

M.