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:
listen = /var/run/php5-fpm.sockwith
listen 127.0.0.1:9000in /etc/php5/fpm/pool.d/www.conf
As there's no
/etc/nginx/php_locationon 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
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.
/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