Hosting one site on two servers

He has: 2 posts

Joined: Nov 2007

Hi

The help I've seen people receive in the forums is exellent so I'd like to throw a query in.

I have a site hosted with a particular host and would like to arrange for a copy of the site (exact replica - databases and all) to be available on a second (unrelated by datacentre) server. This is intended as a backup or failsafe - my thoughts are that if one of the two servers are down, the remaining dns entries would point to the other server for the site to be retrieved.

Can this be done by simply adding dns pointers to the new server's dns servers . . or is ther going to be problems with sql databases and the precise 'pointers' in the database entries which may point specifically to the server name whenever the databases are queried? (if that makes sense!)

Thanks in advance.

Tom

greg's picture

He has: 1,581 posts

Joined: Nov 2005

Without remote accessing other servers or mysql DB's, as you never said that is what you wanted, you are effectively running a seconds site, 100%
just the same as if one site was all about car racing and the other site was all about how to cook the perfect roast chicken
they are seperate

So whatever server a user is pointed to/sent to/accesses they will be served the files from that server
so the PHP code will be used on the server they are on, and the DB will be on the server they are on
and the DB will be accessed with those PHP files on that same server

if you backup the DB from the current server and then on the second server import it, all the table names, table fields, data etc will be exactly the same
the db name is likely to be slightly different though, as some servers create db names with a specific name first
like hostwebsitename_yourdbname

So I guess all you need to change is the mysql username/password/location and possible db name as appropriate for the second server, in your php file that specifies all this

if you have user input that is saved in the db, such as member registration/log in then that is entirely different
as they will only register with the server they are on, and their details will only be saved in that servers DB
and if they one day are sent to the other server, their details will not be in the DB

you are probably better off getting a decent reliable host in the first place, then any downtime will be minimal
and save you running two servers with double the cost for those few hours a month you might have downtime
is that really worth it?
if you dont have a reliable host I can point you towards one my site uses, which is a remarkable service (not affiliated with me whatsoever)

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Looks like you are trying to load balance your site. You can do it the DNS way like you mentioned. This article explains it better:

http://content.websitegear.com/article/load_balance_dns.htm

Some More information that can help you out (may get a bit technical):

http://content.websitegear.com/article/load_balance.htm
http://forum.cheapbooks.com/index.php?showtopic=354

Hope this helps.

He has: 2 posts

Joined: Nov 2007

Thanks a million greg and pr0gr4mm3r.

Yes, the idea is/was to load balance and have reserve access to a site if one server was to be down.

The thought was to have one server in the UK and the other in the US both running the same site (I currently have hosting accounts in both countries which, for the last year or so, has had minimal disruption).

Greg, I overlooked the obvious in relation to membership databases - very glad you highlighted that point.

I was aware that the databases would have to be 100% replicas of oneanother - that may be a challenge in itself!

Thanks guys. . . I knew I could rely on some good advice!

greg's picture

He has: 1,581 posts

Joined: Nov 2005

tm1;225923 wrote: This is intended as a backup or failsafe - my thoughts are that if one of the two servers are down, the remaining dns entries would point to the other server for the site to be retrieved

I presumed you wanted this purely as a backup only for when the main server is down

although it's used for various things, multiple servers with load balancing is 'usually' used when a website requires more power/juice than one server can efficiently handle
if there are many simultanious connections for example, apache has limitations

but you stated you already have more than one server, so perhaps you have space to do this where it wouldn't be extra costs (or small cost, whatever)
If that's the case, and it's only a reserve server used ONLY when the main server is down, then you can manually update the backup db
that is a pain though, and there are automated options

but one thing to consider is when (if) the main server goes down, anything on the backup site that uses data from the DB that is user inputted wont be on the back up server since the last backup
so if a backup was done at 10pm and a user registers at 10:30pm, and downtime happens before another backup is done that user wont have access to their account on the backup site

As you say the hosts you have are reliable, you should consider what is the likelyhood of downtime, and how many users you expect to update their DB details or register (or whatever you have that is stored in the DB from user input)

So then you could consider limiting the backup site for accessing only, by that I mean users can use the features that use the stored data from the DB (or whatever) but nothing can be changed/updated in the DB
I have no idea of what is on your site, but perhaps that will work in your circumstance

if you have many members and many features which use DB data from user input then you might want to consider something more stable and more frequent for them

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.