September 21st, 2011, 03:36 AM
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?
September 21st, 2011, 12:27 PM
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?