Out of Sync servers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Out of Sync servers

Post by Terriator »

Heya,

I currently have a cluser with 2 web servers and a few database server behind them. Problem is, that occasionally there's a big time difference between the 2 web servers. My website being a online game, it's essential that each user receives the same timestamp from the various scripts; it's really going crazy when the user on 1 server is 300 seconds ahead of the user on the other server.

I've contacted my server admins about the issue, and they keep syncing the 2 servers; they however haven't found any permanent solution to the problem.

So, I was thinking, is it a) possible to set the server time with a PHP script, so I could resolve the issue myself? b) is it possible to retrieve all timestamps from some reliable external source?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Out of Sync servers

Post by Eran »

This is a common problem in distributed systems. However, if the cluster is a local network it is very disturbing that the servers can fall 300 seconds behind each other.
How are the servers kept in sync? do they use replication, federated tables or other clustering solutions?
For an intermediate fix, you can assign a user session to one server IP, and have that server serve him all the information until the session expires. This way at least from the user perspective the data is consistent.
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Re: Out of Sync servers

Post by Terriator »

I don't have any information about how they keep the servers in sync..

Currently, each user is assigned to a seperate server, but it's still a big issue, since there's a lot of time-related user interactions (battle-system etc.)

Could I somehow get all the timestamps from one server?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Out of Sync servers

Post by Eran »

If you could, then you have to wonder - why do you need two servers anyway? isn't it to split the load between them?
Without knowing the setup between the servers it's hard to offer good solutions
Post Reply