Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As I was load testing my site today (using blitz.io); despite lots of RAM (more than 50%) and CPU power (over 70%) available, results showed that my site started timing out at a certain number of concurrent users per second.

Nginx error log for my site (/var/log/nginx/example.com.error.log) showed something like this:

2013/02/12 19:03:57 [error] 13749#0: *3175 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 54.123.456.46, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "example.com"

Googling the error led me to this answer which states using TCP\IP connection instead of unix socket as the solution to the problem; as unix socket's "problems on high-load cases is well-known".

So, as suggested by the answer:

  • I replaced listen = /var/run/php5-fpm.sock with listen 127.0.0.1:9000 in /etc/php5/fpm/pool.d/www.conf

  • As there's no /etc/nginx/php_location on my distrio (Debian Wheezy), I did nothing about it.

  • Since I use fastcgi_pass unix:/var/run/php5-fpm.sock; in the Nginx configuration file for my site, i.e., /etc/nginx/sites-available/example.com, I replaced it with fastcgi_pass 127.0.0.1:9000;

Now the problem is, I get a 502 Bad Gateway error when I visit my website. Yes, I did reload Nginx and PHP-FPM. What am I doing wrong? (A total newbie here, doing my best to learn by doing.)

In case this is relevant, when I do sudo service php5-fpm restart, I get this error:

[FAIL] Restarting PHP5 FastCGI Process Manager: php5-fpm failed!

And this is happening only since I made the aforementioned changes. How can I fix this?

Please let me know if I should get more information.


UPDATE

The file /etc/nginx/sites-available/default says this:

#   # With php5-cgi alone:
#   fastcgi_pass 127.0.0.1:9000;

#   # With php5-fpm:
#   fastcgi_pass unix:/var/run/php5-fpm.sock;

So, does that mean, if my server is running PHP-FPM, it SHOULD, without a choice, use /var/run/php5-fpm.sock?

share|improve this question
    
Please paste your entire www.conf. –  mgorven Feb 13 '13 at 18:47

3 Answers 3

Sounds like (based on the 502 and the error message) that php-fpm service is failing to start.

Could something else be using port 9000? To check run:

sudo lsof -P | grep TCP | grep LISTEN

and look for something like TCP localhost:9000 (LISTEN). If there is, you could just use a different port, say 9001.

Good place to check would be the php-fpm error log. It may not be enabled by default. If you look at your php-fpm conf file (/etc/php5/fpm/php-fpm.conf on my system) you'll find the 'error_log' setting. This is the path to your error log. If this is commented out, un-comment it, restart the php-fpm service again and check what the contents of the log file say.

share|improve this answer
    
(1) No, port 9000 doesn't seem to be used by any other service. Here's the output of $ sudo lsof -P | grep TCP | grep LISTEN (2) here are the contents of PHP-FPM log file at /var/log/php5-fpm.log -- paste.kde.org/670802, I still dont understand what to do...?! –  its_me Feb 13 '13 at 18:12
    
Looks like it's still trying to use the file socket NOTICE: using inherited socket fd=6, "/var/run/php5-fpm.sock". Is there a listen setting in /etc/php5/fpm/php-fpm.conf? –  chrskly Feb 13 '13 at 18:13
    
No. But it has this: include=/etc/php5/fpm/pool.d/*.conf which probably means it includes /etc/php5/fpm/pool.d/www.conf, in which I did make changes as mentioned in my question. –  its_me Feb 13 '13 at 18:18
    
I got more information from sudo php5-fpm -t: paste.kde.org/670826 -- as shown in the error, line 33 of /etc/php5/fpm/pool.d/www.conf is this: listen 127.0.0.1:9000 –  its_me Feb 13 '13 at 18:40
[13-Feb-2013 18:35:00] ERROR: [/etc/php5/fpm/pool.d/www.conf:33] value is NULL for a ZEND_INI_PARSER_ENTRY
[13-Feb-2013 18:35:00] ERROR: Unable to include /etc/php5/fpm/pool.d/www.conf from /etc/php5/fpm/php-fpm.conf at line 33

It's not loading www.conf because it has an error at line 33, and so is probably falling back to defaults which use a socket.

share|improve this answer
    
The line 33 of www.conf is listen 127.0.0.1:9000 which I am using instead of listen = /var/run/php5-fpm.sock as the latter is causing time outs under load (as mentioned in my question). –  its_me Feb 13 '13 at 18:43

I used $ sudo php5-fpm -t command to test if PHP-FPM's settings are fine (if not, it'll show me some error/info).

So, here's what the output looked like:

[13-Feb-2013 18:35:00] ERROR: [/etc/php5/fpm/pool.d/www.conf:33] value is NULL for a ZEND_INI_PARSER_ENTRY
[13-Feb-2013 18:35:00] ERROR: Unable to include /etc/php5/fpm/pool.d/www.conf from /etc/php5/fpm/php-fpm.conf at line 33
[13-Feb-2013 18:35:00] ERROR: failed to load configuration file '/etc/php5/fpm/php-fpm.conf'
[13-Feb-2013 18:35:00] ERROR: FPM initialization failed

The error says, something's wrong in Line 33 of of /etc/php5/fpm/pool.d/www.conf, which happens to be this: listen 127.0.0.1:9000 (not so much of a coincidence, is it?).

After seeing it, I immediately compared it with other lines, and then it struck me, an = (equal-to sign) is missing!

So, this is what it's supposed to be: listen = 127.0.0.1:9000 and that fixed everything!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.