I have a few public servers running, I'm writing an account system script. An idea just came to my mind: I will put my one server into other's folder and the other into its folder as well. So they will be able to use same database. The path in the script for server 1 will be something like "2ndserver/3rdserver/scripts/myscript'sname/database.txt". And for the second server it will be "3rdserver/scripts/myscript'sname/database.txt".
What do you say?
I think some problems may occur. There will be 1 database but three scripts which does the same job. Their processes may crash each other. I mean when script1 is deleting something from database it will writefile again and during that process script2's writelnfile may not write anything. Because it can occur between caching the file and then removing what to remove from cache and then rewriting cache to file. I mean some data can be lost. How to prevent it? Any idea?
If there would be two servers I could prevent it. I would make a status.txt file. When a scripts going to change database it would change to status as "using" after it checks if it is free. So when the other script comes it will wait the status to be free. After script1 is done, it will make status free and script2 will process. But I don't know what to do with 3 or more servers.
Sorry for the bad language, writing this from mobile.