A friend of mine ask me about using ajax to create a small counter for his site, he wanted to update the counter every xx seconds to show how many users are visiting his site at the same time.
The idea is nice but after a 10 second thinking I’ve stopped him to implement such feature.
Why? Think about to use a small file (1kb) where you save the counter value.
Now, select as refresh time 5 seconds, every minutes a user will receive 12 refresh of the counter element (=12kb).
This isn’t a real problem for a single user but if the site has more than 100 users online? Every minutes the script will use quite 1Mb of server bandwith…
Do you see the path? If you use an ajax counter like this in a community forum with 100 different browser session, and is not rare that a user opens more than one session to read different posts, always online you’ll waste 60Mb/h => 1,4Gb day!!!
A good use of ajax should be very usefull, but a bad use will surely kill your servers…