kairno Posted December 7, 2007 Share Posted December 7, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 MySQL is extremely memory and CPU intensive. Any script or process that is going to access the database every second is going to put a hurt on resources... PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-408833 Share on other sites More sharing options...
kairno Posted December 7, 2007 Author Share Posted December 7, 2007 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 ... Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-408845 Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 How can you know an event has occurred in the database without querying it? PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-408970 Share on other sites More sharing options...
pierre Posted December 7, 2007 Share Posted December 7, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-408986 Share on other sites More sharing options...
kairno Posted December 7, 2007 Author Share Posted December 7, 2007 @ 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... Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-409160 Share on other sites More sharing options...
PHP_PhREEEk Posted December 8, 2007 Share Posted December 8, 2007 >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 Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-409475 Share on other sites More sharing options...
kairno Posted December 13, 2007 Author Share Posted December 13, 2007 sorry for the delay happy the answer is this {as far as the latest posts on several forums } 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 wish me luck .. it might be just crazy enough to work Edit : i'll set the topic as solved if the sql proxy thing works Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-414236 Share on other sites More sharing options...
Kryllster Posted December 13, 2007 Share Posted December 13, 2007 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, Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-414259 Share on other sites More sharing options...
PHP_PhREEEk Posted December 13, 2007 Share Posted December 13, 2007 Thanks for the update! Hope you get it to work! PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80619-page-refresh-issues/#findComment-414268 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.