1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Rep Power

    Concurrency in reading and writing files

    I have a website and part of my website needs to read/write a plain text file on server. most of the time we have between 50 to 100 concurrent online users and their actions on our site result to read/write certain file in which that is a temporary place holder for some other pages.

    So I want to know about concurrent read/write conflicts and what's the best practice to avoid that if that happened. How does my server manage these requests?
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    File locking. Open the file with a read/write lock, make the changes, and close (which unlocks) the file. Anything which tries to do so when the lock is engaged will wait until it disengages before continuing.

    Do you really have to deal with a file? Can't use a database?

IMN logo majestic logo threadwatch logo seochat tools logo