Jump to content


Photo

Server Management


  • Please log in to reply
1 reply to this topic

#1 Brendan

Brendan
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 27 June 2006 - 07:00 PM

I have a question involving database and server management. I have a community website in which songs and pictures can be uploaded, and blogs can be created with mysql. Eventually if all goes well, there will be need for multiple servers. Now i need to know how to prepare in advance for an increase in servers, so when people upload files to the servers, i will know which server each file is on, and also i need to know if i would need multiple sql databases if it were to get very big?

When you go to big sites such as myspace, you will see that pictures and songs are stored on seperate servers such as imageserver1.domain.com, imageserver2.domain.com. Now i need to know how to store the pictures on different servers when i upload it with php, and when the pictures are viewed how to look at the right server to view the picture.

How do these proffesional websited do it? I want to do it in the most practicle way possible.

Thanks

#2 adamwhiles

adamwhiles
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 27 June 2006 - 07:21 PM

Well about the how to know what server its on would be easy i think. I don't know how big sites do it, but this is how I would do it:

create a .txt file with my servers in it like so

image1.yourdomain.com
image2.yourdomain.com
image3.yourdomain.com
image4.yourdomain.com

Then I would pick a random server from that with php, so it divides up the pictures across the server:
$servers = "servers.txt";

$all_servers = file("$servers");
$ran_server = rand(0, sizeof($all_servers)-1);
$random_server = $ran_servers[$all_servers];

then $random_server would hold whatever server it chose and you could use that in your upload script and also put it into the database so you would know what server to use to link the image later.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users