I have php-fpm 7.0 and nginx 1.11.6 in FreeBSD 10.3.

Sometimes I get 504 timeout even when the server has a lot of free resources.

Nginx waiting answer from php-fpm 30 seconds. I write application logs and see that most longest php process worked 24 seconds. I also got 504 error for processes that work less than second.

Slow log enabled and should log all longer than 12 seconds and slow log empty.

I try write logs from shutdown handler to catch long time processes, but they all work much faster than 30 seconds.

Admins said that looks line nginx doesn't get answer from php-fpm.

Now I am confused and I don't know what I should be looking for. Which log can I enable that could help me find the issue. What symptoms can I also check?

  • How does nginx connect to php-fpm? Unix sockets or TCP? if it's the former, can you try to move to TCP? – Pedro Perez Apr 2 '19 at 16:30
  • We use Unix sockets. I ask admins does they use TCP. – Hayate Apr 2 '19 at 16:38
  • Right. I can't find the supporting documentation now, so take this with a pinch of salt, but you may be hitting a limit of either number of simultaneous connections or number of new connections per second with UDS. This may be tuneable as well. Your admins may want to consider looking into that. – Pedro Perez Apr 2 '19 at 17:18
  • Admin try both of them and they try use a sniffer, found that php-fpm sometimes don't return content to nginx. Code works well, all logic works with less then second, all applications logs on their place, and then nginx just waiting until timeout. We have still no idea at this point :D – Hayate Apr 3 '19 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.