All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Very strange problem with php-fpm
Hi, my name is Dacian, i own a OpenVZ VPS from hosthatch.com. I have 3xCore, 2GB RAM and SSD.
I use this VPS only for webhosting and i am using NGINX+PHP-FPM+MYSQL.
Recently i had big problems with php-fpm, like so:
I have a few wordpress websites, a prestashop website, and a Laravel 4 website, also i have a custom php website.
All was working well but now i have problems with the prestashop and laravel sites.
Randomly they become unresponsive, and they throw 504, 502 http errors, but in the same time the wordpress and custom site work perfectly. I have tryed to search the php error log, i made a complete reinstall of php-fpm, but still i have this random problems.
The load on the server is very low bellow 10% and i always use less than 256MB RAM.
I dont host porn or warez or games, just regular websites.
Anyone have any idea?
Comments
Hi.
Seems like you are not sure how to configure nginx & php-fpm correctly to handle the load.
Regular sysadmin should be able to fix that. I'm too.
P.S. There are no magic cure. It requires overview of situation & settings, to be able to assist.
@Profforg i am no master on system config but i think a low traffic website should have no problems, also this problems started happening without any reason, if someone can help, i can paste config files here.
prestashop and laravel are possibly different from the wordpress from more intensive use of sql, check your iowait, that might be the issue, since you have low memory, the sql caching in ram is low so eventually everything is done with the disk, be it even ssd.
query cache is much harder in shops than in wordpress.
disclaimer: a lot of guessing above, it may or may not be the case.
Without knowing much more, it sounds like php-fpm isn't configured to handle the requests. Given that you have 2 GB of RAM you should be able to make this work with little effort. You can try increasing the "max children" in the relevant php-fpm pool, but I would suggest enabling php-fpm's status to see what's going on; it will give you details about how it's handling requests. Try this page for a guide to set it up:
https://rtcamp.com/tutorials/php/fpm-status-page/
@slave2anubis let's start with error logs. check /var/log/nginx and /var/log/php-fpm for errors
Check your site (php) script code error bug poor scripting language plugin compatible etc blabala can caused problem too
some nginx errors that coincides with the 504 http errors
2014/11/03 07:52:41 [error] 20002#0: *124460 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 86.125.230.16, server: dev.phoneresq.eu, request: "GET /despre-noi HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dev.phoneresq.eu", referrer: "http://dev.phoneresq.eu/"
2014/11/03 07:55:37 [error] 20002#0: *124474 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 86.125.230.16, server: dev.phoneresq.eu, request: "GET /despre-noi HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dev.phoneresq.eu", referrer: "http://dev.phoneresq.eu/"
2014/11/03 07:56:32 [error] 20002#0: *124474 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 86.125.230.16, server: dev.phoneresq.eu, request: "GET /despre-noi HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dev.phoneresq.eu", referrer: "http://dev.phoneresq.eu/"
consider throwing varnish into the mix as well to ease some of the strain on php...
the php-fpm log is empty except: [03-Nov-2014 17:36:23] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
https://www.google.com/search?q=110:+Connection+timed+out)+while+reading+response+header+from+upstream&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=rcs
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 20
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 3
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 2
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 4
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500
@namhuy i have tried all the setting for that error, but with no success, its not the fastcgi timeout!
Also the Laravel website dose not use SQL connection, it serves only static content from the ssd.
not only fastcgi, did you try to put proxy_read_timeout 200; in location / ?
Yes i have tried all the solutions for from google, still is happening, randomly. I have a question, since this is a openVz container can there be a overselling problem that causes this type of problems?
Need modified fastcgi timeout for connect, send and read
This. View your php-fpm status before changing anything.
Example output:
@sleddog how should i do that?
Ok i found how to turn on the php-fpm status, i will do that and see if there is any problems there
have you fiddled with the php5/fpm/php.ini i.e ... double / treble input time / exec time and report changes ..
Also, request_terminate_timeout=30s (php-fpm.conf) adjust time accordingly
Edited-removed
If WordPress u can use nginx + hhvm instead of php-fpm .
@_lei Thank you for the suggestion!
I have talked with the vps provider and they made a offer for a lower spec KVM vps, what do you guys think?
The vps in question is: Package #2 from here
There shouldn't be anything wrong with using ovz for the requirements mentioned in the op... If you've decided to move to a new server... why not try reinstalling first... Shouldnt hurt
@ez2uk i have made a fresh install a few weeks ago, now i am on ubunutu 14.04!
Could you do it one more time... and this time with php5.4 and test the installation...
And before that, what php modules have you installed
Also, if something doesn't work on ovz what makes you think the same will work on KVM
Well since the CPU and Memory load is very low, i suspect maybe there is a problem with the SSD IO, sometimes i also get slow ssh speeds.
at zero load / test /conditions 1 MB/s io is more than enough.... (read low no of user)... Most of the shared hosting providers restrict disk io to 1MB/s (Godaddy for one... and I had an opencart site which went fine with connecting 100/s users on a loader.io test... without a single error)
And I can authoritatively say that the disk io is not the proplem here... it is the way php-fpm talks with nginx... you've got to check your nginx.conf. php.ini, fpm.conf, www.conf and your vhost files ....
I can't comment on slow ssh speeds without fully understanding the issue could be the disk, network, node cpu load or the url you are connecting to
hi, i have setup the php-fpm status page on a domain, now i should wait to see if there is any problems.
this is the status screen from php-fpm after a few days:
pool: www
process manager: dynamic
start time: 04/Nov/2014:18:46:42 +0200
start since: 148498
accepted conn: 1547
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 3
active processes: 1
total processes: 4
max active processes: 4
max children reached: 0
slow requests: 0
Is there anything in your nginx error log, not your php-fpm error log?
http://linuxthefish.net/www.conf.txt is the www.conf i use for high traffic sites, even 300 visitors a second on load testing is no problem - load does go to 3.0 but no errors in my webserver.