Author Topic: One database, multiple servers  (Read 1354 times)

0 Members and 1 Guest are viewing this topic.

Offline utkesmer

  • Major(1)
  • Posts: 44
One database, multiple servers
« on: August 19, 2012, 07:39:30 am »
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.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: One database, multiple servers
« Reply #1 on: August 19, 2012, 12:28:12 pm »
It's not good to handle any bigger databases with server scripting anyway. Non-threaded, frequent use of file functions may cause lag spikes, and performance of string operations is pretty low.
Have you seen this? http://forums.soldat.pl/index.php?topic=42012.0
« Last Edit: August 19, 2012, 12:31:41 pm by tk »

Offline utkesmer

  • Major(1)
  • Posts: 44
Re: One database, multiple servers
« Reply #2 on: August 19, 2012, 02:22:16 pm »
It's not good to handle any bigger databases with server scripting anyway. Non-threaded, frequent use of file functions may cause lag spikes, and performance of string operations is pretty low.
Have you seen this? http://forums.soldat.pl/index.php?topic=42012.0

It's not something I can use I think. There are too many things to study and practice.

Whatever, I already gave up on creating that kind of a system.

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: One database, multiple servers
« Reply #3 on: October 15, 2012, 04:41:06 am »
Just in case somebody got the same problem: http://forums.soldat.pl/index.php?topic=39486.msg483544#msg483544