Need An Explanation: TIME_WAIT for PHP5-FPM Stays Open for 60 Seconds

739 Views Asked by At

I ran into an issue the other day where my nginx web server stopped processing php scripts and gave a 504 Gateway Timeout. I've got php5-fpm setup on port 9000.

When I ran netstat | grep 9000 I got the following result, hundreds of times with different port numbers

tcp        0      0 localhost.localdom:9000 localhost.localdo:37XXX TIME_WAIT

And they didn't seem to clear up at all. I suspect I may have had a lot of traffic hitting my server, or a bad script somewhere. I shutdown a bunch of low priority sites from the server (I have about 10 different nginx site config files running) and things are behaving themselves again, however for every request to a php page netstat reports 1 of those 9000->37XXX ports open and it stays open for 60 seconds even though the page returns to the client almost instantaneously.

Is there a reason why it stays open for 60 seconds? And/or why doesn't the connection get reused? Do I have something configured incorrectly?

I'm worried that if I get a lot of traffic to one of my sites again that it'll just tie up all of the connections again and I'll see the 504 Gateway Timeout again, if in fact it was just a load issue and not a bad php script.

0

There are 0 best solutions below