I've got a small website that has about 5-10 administrators. I've set it up to monitor what each administrator is doing (adding items, removing items, etc). I had a list within our admin-panel that shows the previous 10 activities performed by the collective administration. Today, I decided to make this self-updating every 30 seconds.
My question is simple: is there any problem doing this? I'm calling a small bit of text with each request, and the request is likely only running on 3 or 4 computers at a time (reflecting the number of concurrent-administrators logged in).
$(document).ready(function(){
setInterval("activity()", 30000);
});
function activity() {
$("#recent_activity").load("../home/login #recent_activity .data");
}
Produces the following (or similar - only with 10 rows) with each request.
<table>
<tbody>
<tr>
<td><p>jsampson</p></td>
<td><p>logged out</p></td>
<td><p>28 minutes 27 seconds ago</p></td>
</tr>
<tr>
<td><p>jdoe</p></td>
<td><p>logged in</p></td>
<td><p>29 minutes 45 seconds ago</p></td>
</tr>
</tbody>
</table>
3-4 users every 30 seconds isn't very much at all. Even 300 users at that rate wouldn't be much at all.
You may want to check into these questions:
You can cache this as well, and it would be advisable especially if the query to generate the page is computationally heavy, but of course take into account what kind of lag you want in the most recent content being displayed.
You should cache this and only update the cache every 30 seconds.
No, there shouldn't be any problem at all. I do the same thing at 1 minute intervals for a notification system I wrote on my company's intranet portal. Any web server should be able to handle this, honestly.
It's really no worse (in fact, significantly better) than them, say, refreshing their browser every 30 seconds... Considering the significantly smaller data transfer, it would likely be something on the scale of 10-20 times better than refreshing it... or, about the same bandwidth of refreshing once every 5-10 minutes. :-)
No issue at all in my opinion. Sites that run on a much bigger scale (Betfair for instance) use hundreds of xhr calls per minute per connected client. Obviously they have much bigger hardware infrastructures but the browser copes fine.
I have sites that use a smaller interval and they scale to a few hundred concurrent users running from a sinlge webserver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With