Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache - resources randomly hang (resulting in slow page loads)

HTTP requests of resources randomly - about between 1-5% of the time (per resource, not per page loads) - take extremely long to be delivered to the browser (~20 seconds), not uncommonly hanging indefinitely even. (Server details listed in list at the bottom).

This results in about every 5th request to any page appear to hang due to a JavaScript resource hanging within the <head> tag.

The resources are css, js and small image files, served directly by apache (no scripting language), although page loads (involving PHP or Rails) also rarely hang, with equal chances as any other resource (1-5% of the time), so this seems to be an Apache Request related issue.

Additional information:

  • I've checked the idle workers on server-status and as expected, I still have 98% of my idle workers. Although this may be relevant as the hangings apply to static resources not served by FastCGI (the resources are static).
  • I am not the only one with this problem. Someone else is also having the same problem, and from a different IP address.
  • This happens in both Google Chrome and Firefox as HTTP clients.
  • I have tried constantly force refreshing the same JS file in a new tab. It eventually led to the same kind of hanging.
  • The Timing tab for Google Chrome reports 34ms waiting and 19.27s receiving for one of these hanging requests. Would that mean Apache already had the file contents to be delivered ready, only had trouble delivering it in a sensible amount of time?
  • error.log doesn't show any errors. There are some expected 404 and 500 errors in error.log, but those aren't related to the hanging; those are actual errors for nonexisting pages and PHP fatal errors.
  • I get some suspicious 206 Partial Content responses mostly for static content, although the hanging happens more often then those partial contents. I mostly get 200 OK responses everywhere and I can confirm indefinitely hanging resources that were reported as 200 OK in the apache access.log.
  • I do have mod_passenger installed for Redmine. I don't know if that helps, but suspiciously this server has it installed unlike all the other servers I worked with. Although mod_passenger shouldn't affect static content, especially not within a non-ruby project folder, should it?
  • The server is using Apache 2.4 Event MPM on Ubuntu 13.10, hosted on Digital Ocean.

What may be causing these hangings and how could I fix this?

like image 381
Attila Szeremi Avatar asked Nov 28 '13 17:11

Attila Szeremi


1 Answers

I had the same problem, so after reading this thread I tried setting KeepAlive Off in my apache config which seems to have helped- all resources have expected waiting times now.

Not a great "fix", but at least I am one step closer to figuring out the cause and pages aren't taking 15s to fully load in the mean time.

like image 187
Rusty Shacleford Avatar answered Nov 11 '22 14:11

Rusty Shacleford