Jump to content

Multiple user requests modifying the database, race conditions?


b0r

Recommended Posts

Hello, I am new to php/ajax and I am currently building a web site. I am wondering how periodic update requests from users are handled by the server. If the database and website needs to be updated reguarly (every 30 sec or so) how would I do this? I read about cron jobs which would allow the database to be updated without user interaction but currently I am not in any position to use that.

 

I did think about just letting the requests from the users actually update the database but then i got worried about how to handle possible race conditions. If the script requested by the user contains logic between calls to the database then I assume it is possible for other requests to pre-empt the first request and all various problems might arise because of this.

 

My question is basically how I should go about to solve this. What I want is for the database to be updated correctly, data needs to be updated according to the time and value of other stored values in the database. If this update is separate from user interaction or not does not matter as long as no data is corrupted.

 

I guess it would be possible to solve this using transactions and smart queries but it doesn't sound like that is how it should be solved. Perhaps some sort of event scheduling in the database just using stored routines is a better choice. I am ranting now :P

 

Regards b0r.

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.