13

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?

Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64
  • Have you ever been able to get to the bottom of this? I am having a similar problem, which I think is related to If-None_match and If-Modified-Since I think. When I do a forced page refresh in FireFox and use HttpFox to watch what is going on I can see that these page components are all very slow, even though my Apache 2.4 is on the same box (win7x64) I've got the browser on. Like for you browser doesn't matter. And if I just browse to the page it's ok. It's just when I do a forced page refresh for testing. – Elliptical view Mar 06 '14 at 21:48
  • I haven't gotten to the bottom of it still. Resources randomly load slow for me like I said. 95% of the time any http request goes through instantly, and 5% of the time it hangs for either a really long time or forever. I don't think mine's related to the cache headers like you said, because I was using Chrome Developer tools with caching disabled, meaning I wasn't even sending those headers out. – Attila Szeremi Mar 07 '14 at 00:18
  • Sorry to hear that. Someday I hope to dig into the Apache source code and nail down what's going on, but that's a very big project. Good luck to you. And thanks. – Elliptical view Mar 07 '14 at 00:27
  • 1
    Interesting, I have the same problem RIGHT NOW. Only difference is debian jessie instead of ubuntu. Oh, and I can reproduce the problem by force-refreshing a png file. – griffin Mar 07 '14 at 00:27
  • Same here. So what parts are true and false for you in the list I made? – Attila Szeremi Mar 07 '14 at 00:34
  • Edit: wasn't mod_passenger, i just got the hang back ... - resource is static, problem also from other ip, with different clients, same for chrome webdeveloper really long receiving, no errors even with debug logging, sometimes 206, mod_passenger was enabled ; so really everything besides ubuntu is true for me from the list, apache is mpm-prefork package (don't know if you meant that with mpm) - still trying to get it to serve normally though ... – griffin Mar 07 '14 at 00:35
  • ls /etc/apache2/mods-enabled/ | grep '\.load$' | sed -e 's/\.load$//' | xargs #enabled modules on my side: access_compat actions alias auth_basic authn_core authn_file authz_core authz_groupfile authz_host authz_user autoindex cgi dav dir env expires fastcgi filter headers macro mime mpm_prefork negotiation perl php5 proxy proxy_fcgi proxy_http python reqtimeout rewrite setenvif socache_shmcb ssl status vhost_alias wsgi xsendfile – griffin Mar 07 '14 at 00:41
  • Then you have a different MPM. For me the modules are: access_compat alias auth_basic authn_core authn_file authz_core authz_host authz_svn authz_user autoindex dav dav_svn deflate dir env fcgid filter headers mime mpm_event negotiation passenger rewrite setenvif status – Attila Szeremi Mar 07 '14 at 11:46
  • Anyone resolve this issue? Experiencing now on a new AWS Ubuntu 14.04 box. – cerd Jul 07 '14 at 16:12
  • I've exactly the same problem on a Debian, did someone find a solution ? – Julien Macorigh Oct 17 '14 at 15:47
  • Another person with similar issue on Debian Jessie and Apache 2.4.10. Static assets randomly hang, taking up to 5 seconds to load, on a very underloaded fresh VPS. – Nate Beaty May 09 '16 at 15:46

1 Answers1

4

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.

Community
  • 1
  • 1
  • After searching around for an answer this one did the trick for my localhost running Apache 2.4.51 that was randomly taking 5+ seconds to load some CSS and JS files. – yaryar123 Nov 03 '21 at 20:09