I'm planning on getting inexpensive dedicated hosting from a few providers to help distribute music files for a band.
I'd like to have a script running on the main server that polls the servers with the music files every minute or so, and then redirects users to the least used server to spread the load. If the remote server doesn't respond, it is taken out of rotation until it comes back up.
Can anyone suggest a good easy to install/configure script for this application, PHP + mySQL preferred.
The absolute easiest thing to do (that I can think of) would be to use round robin DNS. However, if a server went down it would not be automatically removed from the cluster -- Still, an easy solution to get you up and running.
I would also recommend checking out MySQL's docs on doing master/slave syncing
Thanks. Right now I'm likely to use a DNS failover scheme from a DNS provider that will monitor service availability and remove a servers IP if it goes down. It's not great, but its good enough, more or less (better than straight up round-robin DNS). I'd rather have something a little finer grained though.
I don't actually have any need for mySQL failover. I just was offering it as a potential piece of the infrastructure for maintaining state info on the front end server.
adaml, we really don't know how many downloads there will be, or how quickly they will come. The band's first album sold over half a million copies. The second sold far fewer, which isn't exactly suprising since the record company held it up for over a year and then released it with almost no promotion because they were too busy worrying about mergers over music.
The goal is to deliver as many downloads as possible with reasonable but not necessarily perfect reliability for the lowest cost possible. Being able to use multiple cheap hosts and add more cheap hosts as needed seems like a good way to do that. Some sort of commercial loadbalancer would add significantly to costs and wouldn't necessarily work with hosts placed at multiple providers for variety.
We don't need Linkin Park (gag) levels of popularity to blow through 4 or 5 TB or transfer in a month.
Thanks again for the suggestions. Other input is apreciated as well.
Try 1and1.co.uk or FastHosts.com they offer load balancing and should be able to spread the load even with a shared account.
Failing that you could use php :
when someone downloads
- query database
- check number of current downloads to number of maximum downloads
- select download mirror with the less amount of current downloads
- add 1 to the database on the download mirror which is in use