Jump to content

Ajax... Few noob questions!


Kryptix

Recommended Posts

So, I love the idea of Ajax and I really want to get into it. But I have a few issues.

 

Say for example if I have a users table with 30,000 users registered, and a column `online` which dictates whether they're online or not... I then have a Ajax script saying something like, "There's currently 38 users online!" updating every second or so on a timer. This worked fine when I tested myself but as soon as you have 38 people on the site, that then turns into 38 queries a second... Which sent the CPU to 100%. :(

 

So the only way I can think of doing it, is by having a table dedicated to Ajax with stats like that updating every second, and then have the users simply query one entry rather than 30,000. It makes sense, but is there an easier way?

 

If that's correct, how do you go about running the query every second? Is that even the right way to do this?

 

Maybe you have a table with columns `online_count` and `time`, each time Ajax queries for the count it checks to see if it's more than a second old and if so, run the script to update it?

 

Am I thinking straight or am I way off?

Link to comment
https://forums.phpfreaks.com/topic/200982-ajax-few-noob-questions/
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.