Nginx + PHP-FPM is very slow on Mountain Lion Nginx + PHP-FPM is very slow on Mountain Lion nginx nginx

Nginx + PHP-FPM is very slow on Mountain Lion


One reason could be - as already suspected above - that your server works perfectly but there is something wrong with DNS lookups.

Such long times usually are caused by try + timeout, then retry other way, works, cache.

Caching of the working request would explain why your second http request is fast.

I am almost sure, that this is caused by a DNS lookup, which tries to query an unreachable service, gives up after a timeout period, then tries a working service and caches the result for a couple of minutes.

Apple has recently made a significant change in how the OS handles requests for ".local" name resolution that can adversely affect Active Directory authentication and DFS resolution.

When processing a ".local" request, the Mac OS now sends a Multicast DNS (mDNS) or broadcast, then waits for that request to timeout before correctly sending the information to the DNS server. The delay caused by this results in an authentication failure in most cases.

http://www.thursby.com/local-domain-login-10.7.html

They are offering to set the timeout to the smallest possible value, which apparently is still 1 second - not really satisfying.

I suggest to use localhost or 127.0.0.1 or try http://test.dev as a local domain

/etc/hosts

127.0.0.1 localhost test.dev

EDITIn OSX .local really seems to be a reserved tld for LAN devices. Using another domain like suggested above will def. solve this problem

http://support.apple.com/kb/HT3473

EDIT 2Found this great article which exactly describes your problem and how to solve it

http://www.dmitry-dulepov.com/2012/07/os-x-lion-and-local-dns-issues.html?m=1


I can't see anything in your configuration that would cause this behaviour alone. Since the configuration of Nginx looks OK, and this affects both static and CGI request, I would suspect it is a system issue.

An issue that might be worth investigating is whether the problem is being caused by IPv6 negotiation on your server.

If you are using loopback (127.0.0.1) as your listen address, have a look in /etc/hosts and ensure that the following lines are present:

::1    localhost6.localdomain6 localhost6::1    site.local cft.local

If this doesn't resolve the issue, I'm afraid you'll need to look at more advanced diagnostics, perhaps using strace or similar on the Nginx instance.


(this started as a comment but it's getting a bit long)

There's something very broken here - but I don't see anything obvious in your config to explain it. I'd start by looking at top and netstat while the request is in progress, and checking your logs (webserver and system) after the request has been processed. If that still reveals nothing, then next stop would be to capture all the network traffic - most likely causes for such a long delay are failed ident / DNS lookups.