n3mesis125 Posted July 10, 2008 Share Posted July 10, 2008 Is looping a page every second or two bad when it calls an SQL Select query to the database? The reason I do this is for an online/offline status check and to output it to the page? I need it in real-time but I'm not sure if this would crash mysql or would be too much of a server load? Thanks, n3m. Quote Link to comment https://forums.phpfreaks.com/topic/114187-looping-a-page-that-queries-a-select/ Share on other sites More sharing options...
rmbarnes82 Posted July 11, 2008 Share Posted July 11, 2008 Hi, If you're going to do this you really should use some form of query caching, I don't know if MySQL does this automatically. What you really want to be worried about is Denial Of Service. If too many people use this webpage at the same time, apache will probably turn of because it is receiving too many requests too quickly. Google 'denial of service' for more info. I think what you have to ask yourself is: does it really matter to the users if the data refreshes every second, or could it be every 10 seconds? Also you could use ajax to just update the part of the page that was dynamic, rather then reload the whole page each time. Robin Quote Link to comment https://forums.phpfreaks.com/topic/114187-looping-a-page-that-queries-a-select/#findComment-587131 Share on other sites More sharing options...
auro Posted July 11, 2008 Share Posted July 11, 2008 Ya rmbarnes82 is right. Nemesis, 'Denial of service' happened with me. My pages were not like that. Page loads were nearly 20/sec and queries per second were 200+/sec My webhost stopped my database. Quote Link to comment https://forums.phpfreaks.com/topic/114187-looping-a-page-that-queries-a-select/#findComment-587200 Share on other sites More sharing options...
Andy-H Posted July 11, 2008 Share Posted July 11, 2008 TBH I had a users online pahe that refreshed every 60 seconds and no-one complained, as soon as my site went down however, I recieved about 100 msn messages complaining. The way I see it, if you can't decide between two website features,BETA test them and compromise on the least popular. Quote Link to comment https://forums.phpfreaks.com/topic/114187-looping-a-page-that-queries-a-select/#findComment-587209 Share on other sites More sharing options...
auro Posted July 11, 2008 Share Posted July 11, 2008 Andy such things really matter when traffic is huge. Also most of the shared hosting providers restrict the CPU usage to 4 percent. They'll warn you if your site consumes a lot of resources. Quote Link to comment https://forums.phpfreaks.com/topic/114187-looping-a-page-that-queries-a-select/#findComment-587216 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.