views:

233

answers:

7

I've tried searching for this but it's pretty difficult to put into words.

Basically, our site will run fine for most users without any issues. Sometimes though, those of us who use the site pretty heavily all day will suddenly get completely bogged down. Everything just spins in place. The site itself is still fine - everyone else can still get to it, but the individual user is stuck. In fact, restarting the browser entirely doesn't generally fix the issue, even if you explicitly clear your cookies.

You can, however, generally open the site just fine by switching to a different browser. If you're bogged down in Firefox, you can usually open it up and continue working just fine in IE. This can happen both ways (you can bog down IE, and switching to firefox works).

Does this make any sense at all? It's like there's something breaking with the session, but I don't know what would cause this and the session should reset by restarting the browser and clearing cookies and whatnot.

Any ideas?

[Editing to clarify, sorry, should have included this to begin with] Server is a very basic LAMP stack on RedHat with Apache 2.2.3, PHP 5.2.11, MySQL 5.0.45 (we've considered upgrading MySQL but I don't think this is the issue here). It's a standard configuration for Rackspace, so I don't think we're doing anything exotic besides maybe the Zend Optimizer.

We're using a lot of javascript/jquery but it's all pretty standard stuff and I wouldn't expect a memory leak to not affect the other browser, though I may be wrong.

Also, our server's CPU and memory usage have never broken the 25% margin, even in spikes, and the spikes don't seem to correlate with this phenomenon.

+1  A: 

Sounds pretty much like you have some sort of session locking issue. You state that even removing cookies doesn't help, which makes session locks seem less plausible, but I don't have any details on your implementation so it's still possible.

I have two questions i'd need answered to gain some insight into the problem.

  1. Do you have a session open while streaming content and attempting to read from or write to the session on a different request?

  2. Have you've implemented your own sessions?

If you're answering yes or maybe to question 1, that's probably the root of your problem then.

If you're answering yes to question two, does the problem persist if you switch session management to standard php? You could have a bug in your session handling.

Kris
Yes, it could very well be that with multiple tabs open on the same session we're writing to the session while reading from it at the same time. I'll tell my guys to use one tab only for a while to see if that gets us somewhere. Is there any way around this?I'm using standard PHP sessions.
epalla
It's not just multiple tabs that cause multiple open requests, just loading any two or more resources at the same time, tabs by themselves aren't very likely to do that, unless you're also doing some AJAX.
Kris
There are several pages that use a lot of ajax. It's not uncommon for people on the team to open one or more of these pages in multiple tabs at the same time. Right now session locking is definitely where I'm leaning on this one.
epalla
I've just managed to lock it up. While one page was loading from ajax I opened another page that calls the session. This killed the site in firefox as mentioned. I was able to get to it in IE just fine. I manually deleted the session from the server and everything loaded right up. I'm not pretty convinced this is a session locking issue.Is there any alternative (besides DB-based sessions) that might solve this problem?
epalla
I'm afraid you'll just have to selectively open and close the session, personally i have my own DB based sessions, but just a backend to PHP's $_SESSION, and that'll still lock if you do it wrong.
Kris
+1  A: 

G'day,

It sounds like you're persisting some sort of info on the server side on a per-session basis.

Are you persisting session id's or user id's on the server? Maybe adding more and more information to some persisted data with each subsequent incoming request?

Maybe the incoming User Agent string is also involved which is why changing browser types works, where simply restarting a session in the same type of browser doesn't work?

Have you seen if stopping and restarting a session across a time boundary, e.g. the hour, or midnight, when using the same browser also resets the problem? Maybe try spoofing the UA string to see if that also resets the problem.

BTW What Apache modules are you running in your server? Also 2.2.3 is quite an old version have you considered upgrading?

Rob Wells
We're storing sessions on the server, yes. We don't re-initiate an old session via a cookie or anything like that though if the user closes the browser and comes back, so it should start a fresh session if they leave the browser.I'll definitely take a look at the sessions and see if manually deleting the session file will fix the issue. Nothing's out of the question for upgrading, maybe that will be next on our list.
epalla
@epalla, cheers. i'm really wondering if what you're persisting is just getting so large over time. Let me know what happens. BTW This is th esort of stuff I do for a *major* web site. (-: Good luck.
Rob Wells
I haven't had the chance yet to test this fully, but all the current session files that I see are under 1k in size (except two phpMyAdmin sessions for myself that have ballooned to a whopping 13 and 15k respectively). Our garbage collection isn't anything crazy fast, so I'd expect that if this is what was causing our time outs this morning I'd still have a few abnormally large sessions from that. I still don't understand why restarting the browser wouldn't resolve this isue?
epalla
@epalla, if you're presisting session info as a cookie then restarting wouldn't solve that. I'm beginning to wonder if it is some sort of client side leak you're experiencing now as @Nazarly suggests.
Rob Wells
A: 

It's look like to me that it is a Memory Leaks that your javascript creates. Check your process list and see how much memory browser consume in begining and after half an hour of browsing and reloading your website. If if memory consumption is significantly more than it suppose to be thats meen that you have to review your javascript code for any unreturned methods, unbreaked loops and so on. Usualy it helps.

Nazariy
Wouldn't a complete browser restart clear this out? I admittedly don't understand the mechanics of a memory leak.
epalla
Yes after you restart browser memory clears out. For example when I start Firefox it consume about 70Mb of my RAM, after few hours work under one website, with constant page refresh and catching events, browser consume more than 300Mb of RAM this is most common sign of memory leak in application. It is very hard to fix it when you are using minified libraries from third parties.
Nazariy
right, but that implies that a browser restart would fix the issue, yet it doesn't.
epalla
A: 

Interestingly no one has suggested advertisements as the cause (Nazariy's answer could be adopted to those though).

Basically check the advertisements shown on your site, there's a ton of crap in those things and they're always based on user recognition which would explain why restarting the browser doesn't help.

Esko
We do use analytics, but we have no other advertisements on the site.
epalla
A: 

I experienced this with a PHP app on Apache on RedHat too. I am still not clear about the cause but it went away after switching from persistent db connections to regular connections.

Gordon
We are not using persistent connections.
epalla
A: 

This has happened to me too, frequently, in fact. Completely stateless site, lot's of AJAX requests, after a while the site just becomes unresponsive. It's especially annoying during debugging. Here are some things you have to be aware:

  • Number of JS files loaded (it includes the ones you get using script requests) (You should probably delete the script tags created if you use that method)
  • Number of CSS files (for example, on IE, there is a hard limit of 31, I think)
  • Sometimes the browser can lock into a DNS resolution request
  • Some browsers have limits on the number of requests to domains (IE has 2) so if there is a request not fulfilled, all the others to that domain will have to wait

All this of course doesn't explain why it keeps hanging after you restart the same browser - though you haven't mentioned clearing your cache, so maybe there is a failed request that is sitting in your browser cache or some intermediate cache or proxy, so you can try to see if this happens if you completely turn caching off in your browser. (On Firefox this can be easily done using the Web Developer toolbar, for example.)

You should also see what requests hang, use Fiddler and Firebug to see that.

Gyuri
A: 

Memory leaks caused by javascript affect the browser, because it's all client side. Jquery compress or min you can't be sure where the problem is, and it is likely to be the cause problems, or the script using it.

dsavage