Score:0

Apache takes too long (+4s) to do anything (configtest, exec. PHP, etc)

cn flag

Note: using apache v2.4.6, PHP 7.2.24

I have deployed a PHP application on a CentOS 7 server using httpd. We have two environments (production and testing) and while testing is fast, production is slow.

After checking, it seems the main cause of slowdown on production is the fact that it takes up to 4 seconds to even start running the PHP scripts.

I placed a die; statement at the very beginning of the PHP scripts, and when accessing the site with Firefox, here are the response times:

  • 150ms for testing
  • 4s with production

What I find bizarre is that the production server is a clone of the testing server, so the PHP/Apache config is the same. The database is different, but I don't think that has anything to do with it since the long response times occur before any calls are made to it.

I looked online and saw it could be due to a "ServerName" directive, but I checked and the config files don't use it.

Are there log files I could look at to see what is taking Apache so long? I've also noticed that apachectl also takes way longer to execute on prod than on test. Even service httpd configtest which is instantaneous on test server takes a while.

us flag
First of all, PHP 7.2 has had its end of life at end of 2020. So you should upgrade to at least PHP 7.4 which is the currently supported option to avoid exploitable vulnerabilities. Is the production environment properly dimensioned for the traffic it receives?
in flag
The debug tools of your browser shows you pretty detailed how much time the segments of the request take. Check it.
vidarlo avatar
ar flag
In addition to what @GeraldSchneider mentions, check logs on the server for any failures.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.