Jump to content

Infinite Loops | Server Strain?


dreamBox

Recommended Posts

Hi all,

 

I am working on a project where I need to monitor accounts and suspend features associated with them if their deposited balance runs out.

 

To do this I'm thinking it might be best to have a script running with an infinite loop that constantly refreshes but I'm not sure what kind of strain this might put on the server.

 

The pseudocode would look something like this:

 

while (1) {
  For each row in database {
    If balance <= 0 {
       mysql query - account_status = suspended
    }
  }
}

Please note (obviously) this is psuedocode and not actual code.

 

I'm just concerned about how I would stop this script timing out, and what kind of impact it would have on server performance?

 

Is there any better way to do this?

 

Happy to discuss,

 

dB

Link to comment
https://forums.phpfreaks.com/topic/223186-infinite-loops-server-strain/
Share on other sites

why repeatedly check rows that may have had no activity since the last check, when checking the balance whenever a row is updated may be easier and take less server time?

ie

A) query to update balance (this query should already contain some unique field value so as to only update a particular row)

B) query to check value of new balance - if balance <=0 - suspend

 

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.