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
Share on other sites

  • 1 year later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.