Jetpack Cron Timeouts Crashing PHP5-FPM (502 Gateway Errors)
-
Hello –
This post is for folks who might be facing the same issue I was dealing with recently and have finally rectified.
My Ubuntu LEMP (Nginx) server housing 11 WordPress websites was producing 502 Gateway errors on a regular basis – on average very 6 – 8 hours. I was able to fix the 502 error by restarting the php service:
sudo service php5-fpm restart
I then looked through my nginx error log (/var/log/nginx/error.log) and found this error:
2017/08/13 10:35:44 [error] 12375#0: *38647 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 162.158.222.55, server: ___.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.___.com"
This was likely a notice that PHP5 had crashed so I searched for errors leading up to this one. That is when I noticed that there were cron jobs timing out every 4-5 minutes:
2017/08/13 8:54:40 [error] 8925#0: *34 FastCGI sent in stderr: "PHP message: PHP Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/____.com/html/wp/wp-includes/option.php on line 0" while reading response header from upstream, client: 10.13.0.2, server: ____.com, request: "POST /wp/wp-cron.php?doing_wp_cron=1502639645.9681689739227294921875 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "modern-outfitters.com", referrer: "https://____.com/wp/wp-cron.php?doing_wp_cron=1502639645.9681689739227294921875"
I downloaded the WP Crontrol plugin and examined which cron jobs were occurring that often. Turns out there were two Jetpack sync cron jobs set to run every 5 minutes.
My server is running at below 25% load consistently, so I am against increasing the timeout length to greater than 30 seconds. That opens the door to memory leaks and endless processing.
I was unable to locate any solid solutions for changing the frequency of the cron jobs, and made the decision to simply deactivate Jetpack.
Now, my server load is consistently under 11% (a drop of 14%), my error logs have been clean save for a couple 404 issues on missing images being rendered, and all the sites on my server are running notably faster.
It has only been 8 hours since I’ve completed the change, but no downtime to report and the sites are humming along. Again, this post is for anyone dealing with similar issues.
- The topic ‘Jetpack Cron Timeouts Crashing PHP5-FPM (502 Gateway Errors)’ is closed to new replies.