Static storage Server?

Discussion in 'Programming' started by sid4444, Sep 30, 2008.

  1. #1
    Hi all,
    I have a question, how can I make a multi storage (server) image sharing site, that mean I want to make a image sharing site like imageshack, tinypic, photobucket etc. but I don't understand how can they store their images on many different storage server such as

    at imageshack.us:
    http://imgcash6.imageshack.us/Himg2...apphiresunsetsizedmu2.jpg&xsize=640&ysize=480,
    http://imgcash4.imageshack.us/Himg5...&filename=nature10yb8.jpg&xsize=640&ysize=480

    at tinypic.com:
    http://i35.tinypic.com/2q9l5jr.jpg,
    http://i37.tinypic.com/1ovwp2.jpg

    at photobucket.com:
    http://i392.photobucket.com/albums/pp7/magouillelafripouille/Monuments and landscapes/DSCN1984.jpg,
    http://i2.photobucket.com/albums/y31/friendofallcountries/Landscapes/101_0060.jpg.



    Any suggestion?
    Thanks.
     
    sid4444, Sep 30, 2008 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    It isn't that complicated. You can either use 1 server and have subdomains pointing to it, and set your apache server to make them virtual servers. Or you can have 1 main server with dns server such as bind/named. Then have subdomain pointing to different servers.
     
    Kaizoku, Oct 1, 2008 IP
  3. sid4444

    sid4444 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for reply.
    I understand your suggestion but I don't understand how they(above image hosting sites) choose what static server
    (like
    i392.photobucket.com or
    i2.photobucket.com
    etc.) is going to store the next uploaded file? Is there any php logic can do that job?
     
    sid4444, Oct 1, 2008 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    You can store all possible servers in 1 array.

    
    $servers = array('s1', 's2', 's3', 'a1', 'a2', 'a3');
    
    PHP:
    Then use the random function.

    
    $next_server = array_rand($servers) . '.photobucket.com';
    
    PHP:
    Then just reference the file with the server in a database.
     
    Kaizoku, Oct 1, 2008 IP
  5. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    but you probably need a script that checks the storage space left on one of them servers.
    random would only randomly drop it into one of them. A more complex script would check to see how big the file is that you're tyring to upload and then it would check the and drop it into the first storage space that had the available room. that way it wont create the URL path to the file until it knows what storage space it will go into. if and else and when successful.. generate the file path.

    thats my guess anyway
     
    ezprint2008, Oct 2, 2008 IP
  6. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #6
    just do a exec('df'); then
     
    Kaizoku, Oct 2, 2008 IP