3

I'm experiencing a weird issue with nginx + PHP-FPM hosted web app build with Symfony2. Basically, from time to time, there's a request that is not handled, instead the browser shows that it's waiting to start receiving (the wheel in chrome is spinning counter-clockwise).

I have nothing in error logs there that would help me identify the issue, neither in app log itself (Symfony 2.8), nginx nor php-fpm logs.

What is weird is there's no timeout at all, which would suggest php-fpm didn't even receive that request (right?).

Perhaps there's anyone who did experience such issues before and may know the probable cause?

Should I provide anything that would seem relevant (config files?), please do not hesitate to ask in comments.

user401676
  • 41
  • 1
  • 3

2 Answers2

2

I have the same issue. What I found is that if the process doesn't complete, then there are no log entries. So the request comes into nginx and is relayed to the upstream, php-fpm. php-fpm doesn't respond and nginx times out the upstream. php-fpm continues operating. So what I see processes building up over time stuck in flock() call. Looking at the stack, I found this was due to trying to obtain a file lock on a debug file. I suggest you check php-fpm's open files to see if anything is hung or running, lsof |grep php-fpm. Then use strace or gdb to debug the issue further.

In my case, I was calling file_put_contents with an exclusive lock, which, for whatever reason, PHP isn't able to get sometimes and just hangs, forever.

Backtrace

0 0x00007f03f7081a67 in flock () from target:/usr/lib/libc.so.6

1 0x000055db7b9ecae6 in ?? ()

2 0x000055db7b9e83ad in _php_stream_set_option ()

3 0x000055db7b93e78e in ?? ()

4 0x000055db7badf0a3 in execute_ex ()

5 0x000055db7bae6fad in zend_execute ()

6 0x000055db7ba34c65 in zend_execute_scripts ()

7 0x000055db7b9cfb89 in php_execute_script ()

8 0x000055db7b7a1543 in ?? ()

9 0x00007f03f6fbaf4a in __libc_start_main () from target:/usr/lib/libc.so.6

10 0x000055db7b7a230a in _start ()

0

Well NGINX its great, although it doesn't work out-of-the-box properly. You need some tuning. what have you done so far?

Look at this simple guide. There are many other parameters than those described here: https://www.nginx.com/blog/tuning-nginx/

The Backlog Queue Worker Processes Keepalive Connections HTTP2

And much more... In my case i once had a problem like this and i solved by increasing my queue limit (Backlog Queue)

lucasmx
  • 620
  • 1
  • 6
  • 12