Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
i'm just curious to know how you would run a website with a database on it's own server? i read that macrumors does that, and i've read other big sites doing it as well.

and i'm sure some sites have the database on multiple servers. how would you do that as well?

thanks
 
Well, when you connect to the database, you simply put in the remote address.
PHP:
<?php
$dbhost = 'http://remote.location';
$dbuser = 'user';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
?>
It's really no different than connection locally, just a different host name. In terms of multiple servers, you simply split your data into different databases, which are separated between them.
 
We've got two MySql servers running master master for a client. They also have 6 satellite web servers, but I'm guessing that may be overkill for your question.

There is no simple answer, but we use load balancers to even out the traffic, then a script to replicate everything instantaneously. Even writes go to one mysql server, odd writes go to the other mysql server, then they swap info within milliseconds. Therefore we have a redundant backup at all times along with doing backups every 2 hours, every night, once a week, and once a month. The duplicate mysql server evens out the load and acts as a real time backup.

Does that answer your question? You asked a big question at first, then your last comment seemed like you just wanted to connect to a database at a different ip so I don't know :)
 
We've got two MySql servers running master master for a client. They also have 6 satellite web servers, but I'm guessing that may be overkill for your question.

There is no simple answer, but we use load balancers to even out the traffic, then a script to replicate everything instantaneously. Even writes go to one mysql server, odd writes go to the other mysql server, then they swap info within milliseconds. Therefore we have a redundant backup at all times along with doing backups every 2 hours, every night, once a week, and once a month. The duplicate mysql server evens out the load and acts as a real time backup.

Does that answer your question? You asked a big question at first, then your last comment seemed like you just wanted to connect to a database at a different ip so I don't know :)

thank you for your reply! :) yes, that does help.

i have a few sites running off my own webserver, and i don't have a lot of traffic, but i do have priceless information. i might try and setup a backup mysql database on another machine if i can.

i do also want to know how to connect to a database with a different ip
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.