Jump to content

page refresh issues


kairno

Recommended Posts

you know the online user feature in the forums.. i need to make something like that but almost real-time. i now have an ajax script that checks the database every second, as you know it's not efective, and also take s about 405 of my cpu for 1 user... i'd like to know if there's a way to lower the cpu usage... any and all help will be appreciated...

Link to comment
Share on other sites

that i know... i was wondering if there's a way to "tell" the script to check the database >only< when an event occurs {a user loggs in / out}

 

the issue is that the application i'm developing is more complex than a forum , and i need to update a page when an event occurs on the database, and not check it every second ... just to pin-point the issue i'm having ...

Link to comment
Share on other sites

What you are trying to do in inherently problematic.

1. There's no way to guarantee that your users will log-out. As such your database will be out of synch with what is really going on.

2.There's no 'interupt' style mechanism available to have a change in the database propagate to a user's browser.

 

You can count the number of active sessions. See: http://www.olate.co.uk/articles/131. [i haven't tried this code out myself.]

 

If hitting your database is what is costing you, try using a file. However you have to handle concurrency issues yourself when you do this.

 

 

 

 

Link to comment
Share on other sites

@ PHP_PhREEEk

found a perl script that can handle events through a unix pipe, but i have no idea on how to refresh the pages ... ajax is too resource consuming ( the code i have now ), but i'll try different codes...

@pierre

well... the session count might be helpfull... thanks

 

i've been searching for a solution for this problem for about 2 weeks... but nothing...

Link to comment
Share on other sites

>found a perl script that can handle events through a unix pipe

 

You would just be trading accessing the database from within PHP to accessing from within a PERL script that does a shell query. Either way, you're still accessing the database every n number of seconds. Not sure that's going to provide the solution for the high load.

 

In a situation like this, it would obviously be recommended you have a separate and dedicated MySQL server. That is how a large corporate database would handle it, but for the average user, this wouldn't be cost effective...

 

>ajax is too resource consuming

 

Can you elaborate on this? The javascript portion of AJAX runs on the client side, so there is no extra burden on the server. The requests and resulting data it sends for a browser update is usually smaller than a whole page (that's the point to AJAX, anyways), so it is supposed to be less of an overall load. What you may be experiencing here is, again, the constant and consistent hammering of the MySQL service. It doesn't matter what script does the hammering, it's the hammering itself that is going to ultimately cost memory and cycles.

 

Keep us posted... it's an interesting venture!

 

PhREEEk

Link to comment
Share on other sites

sorry for the delay :D

 

happy :D

 

the answer is this {as far as the latest posts on several forums :D}

 

there's a software called sql-proxy it's soewhat of an interface... it can {supposedly} intercept queries and "do something"

and that to me means : do the requested queries and then WRITE A FILE on the server... and that's precisely what i need. instead of requesting and doing queries on the database every second i'm only doing them when the file says there's beed activity :D

 

wish me luck .. it might be just crazy enough to work :D

 

Edit : i'll set the topic as solved if the sql proxy thing works :D

Link to comment
Share on other sites

Ok I know Im a real noob but I have seen things like what you are talking about (I think). Their solution is to use cron jobs to update info for their pages?? I have used this with a linux setup as well as windows when I set up a game called Alien Assault Traders. Just a thought!

 

Thanks,

Link to comment
Share on other sites

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.