504 error on one VirtualHost on dedicated server

borayeris

Member
Jan 28, 2015
21
4
53
cPanel Access Level
Root Administrator
Hi,

I have 60 sites on my server. Sometimes one site freezes or gives 504 error. I understand if all freezes because of overload but how can one virtualhost freeze?

When that site freezes I htop and saw many

UserOfFrozenDomain /usr/local/apache/bin/httpd -k start -DSSL

Other apache instances of domains runs and ends perfectly at that time.

What should I monitor?

PS: I use php-fpm.
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
460
113
UK
cPanel Access Level
Root Administrator
My understanding of a 504 error (sometimes referred to as a 504 Gateway Timeout Error) is when a website on one server did not get a timely response when requesting data from another server.

An example might be calls to JavaScripts that are hosted on some other server, or calls to embedded videos that are hosted on YouTube or dynamic API content like a Facebook Timeline that is being displayed inside a WordPress page.

You may want to audit the code and see if the particular hosted domain in question uses an unusual amount of calls off-server to complete its build of a requested page. You might also want to ensure the IP's of any external calls are whitelisted in your firewall software so that they don't get accidentally blocked and prevent a page from completing its build.

Ultimately, it should be possible to have the page return ...something... rather than a 504 error in the event of the upstream data not being available.

Hope this helps

***EDIT***

As you are using PHP/FPM you might like to explore using the request_terminate_timeout setting in PHP to set a higher value.

Full details from PHP: Configuration - Manual
 
Last edited:

borayeris

Member
Jan 28, 2015
21
4
53
cPanel Access Level
Root Administrator
My understanding of a 504 error (sometimes referred to as a 504 Gateway Timeout Error) is when a website on one server did not get a timely response when requesting data from another server.

An example might be calls to JavaScripts that are hosted on some other server, or calls to embedded videos that are hosted on YouTube or dynamic API content like a Facebook Timeline that is being displayed inside a WordPress page.

You may want to audit the code and see if the particular hosted domain in question uses an unusual amount of calls off-server to complete its build of a requested page. You might also want to ensure the IP's of any external calls are whitelisted in your firewall software so that they don't get accidentally blocked and prevent a page from completing its build.

Ultimately, it should be possible to have the page return ...something... rather than a 504 error in the event of the upstream data not being available.

Hope this helps

***EDIT***

As you are using PHP/FPM you might like to explore using the request_terminate_timeout setting in PHP to set a higher value.

Full details from PHP: Configuration - Manual
Thanks for suggestions.

"calls to JavaScripts" aren't they client side? How can JS affect host?
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
460
113
UK
cPanel Access Level
Root Administrator
"calls to JavaScripts" aren't they client side? How can JS affect host?
Many of the libraries that are used in the JS are Hosted on other servers eg Google Hosted Libraries | Hosted Libraries | Google Developers

In theory, this results in you always calling the latest and greatest and best performing and most secure version** of the file without having to constantly update it yourself.

The trade-off is that you rely on another server to supply you with resources, and if that other server is overloaded or off-line, the resource may never arrive.

** AND you depend on the security of the server that is hosting the resource you need !!
 

borayeris

Member
Jan 28, 2015
21
4
53
cPanel Access Level
Root Administrator
Many of the libraries that are used in the JS are Hosted on other servers eg Google Hosted Libraries | Hosted Libraries | Google Developers

In theory, this results in you always calling the latest and greatest and best performing and most secure version** of the file without having to constantly update it yourself.

The trade-off is that you rely on another server to supply you with resources, and if that other server is overloaded or off-line, the resource may never arrive.

** AND you depend on the security of the server that is hosting the resource you need !!
You missunderstand me. Javascripts are called by the browser. How can it affect the server?
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
460
113
UK
cPanel Access Level
Root Administrator
You seem to be struggling with understanding how the HTML/PHP/(whatever) builds the JavaScript code that it sends to the client web browser for execution.

This article might help: What Is JavaScript and How Does It Work?

We don't care how or where the code is executed, we DO care about the server resources it consumes in order to collect the runtime libraries and routines it needs to then send to the client web browser.

Maybe a cPanel analyst can approach explaining this from a different angle in a way that makes more sense to you.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,224
463
Hello @borayeris,

I recommend searching the PHP-FPM error logs (/opt/cpanel/ea-php$$/root/usr/var/log/php-fpm/error.log) for entries appearing at the time of the error to see if you notice any specific output. You'd replace ea-php$$ with each specific version of PHP (e.g. ea-php70) that PHP-FPM is utilized with on your system. The global Apache error log (/usr/local/apache/logs/error_log) is also worth reviewing.

Thank you.
 
  • Like
Reactions: borayeris