|
m.j.little
Date:: Oct 04, 2006
Time:: 08:48
|
I wasnt trying to insult your intelegence, oviously i dont know how much experence you have had. The last person i talked to about this had just finished doing hello world, so i hope your didn't take offence.
Clustering is not too hard, but it depends on the application, you can acutlaly setup DNS load balancing your self, which is a good way to test your application in advanced without needing dedicated servers, you can just use shared hosting accounts.
Create 2 A records for your domain www1 and www2 and point them to the correct IP addresses, then instead of an A record for www create 2 CNAME records pointing to www1 and www2, and there you have it a DNS round robin load balaced site.
From the coding point of view, If users are not uploading things, its very easy, just a simple case of coping the code to another server, and getting it to use the same mysql database.
If they are uploading things, you really have 2 choices, 1 get a good storange server on the backend that all servers connect to, or 2 do the balancing yourself, to do that you would need to monitor the disk usage, and get your script to change what server you upload images to. For example, when WWW1 is getting full, you make a small change in your code so that instead of uploads posting directly to WWW1 (this will bypass the load balancing, so that its forced to a perticular server) you get it to post directly to WWW2. doing this means that you must store the server the image is on in the database. Of course you dont actually have to use filebased storage, you could store images as raw data in the database, then has a PHP script to pull it from the database (so you have say image.php?imagename.jpg) this would also work, as when you use mysql cluster it would be avaliable on all servers all the time.
Mysql clusters very well, however if your not a server admin, you may wish to grab some help. If you think you may use mysql then you can use the same idea with your DNS as used for the www record. So you create db1 and db2 as A records then have multi CNAMES for db. Then you get php to connect to db.domain.com as the host instead of an IP address.
I have personally run a mysql database with 2 million records in a large table, it mysql was not to bothered about it, the only real limitation is the size of the HDD, which with 500GB HDD's avaliable and with RAID, you can get a pretty huge amount of storage.
The main thing you need to consider is how you are going to do your loadbalancing. DNS load balancing works, but if a server goes down, you will still have and outage. This is where hardware loadblancing and clustering comes into play, but you can still use the DNS to make upgrading easy.
If you consider that you are already too big for a single server, then we can simulate what you would need.
Personally i would recomend 2 webservers, 2 database servers and 1 master server.
The master server handles your email, ftp and also runs a few programs to make the clustering work (such as the mysql cluster manager program (cannot remember the exact name just now).
When you upload a file by FTP, you would need to setup a script to replicate that file onto both webservers which is not too complex. This would keep your scripts upto date, for client uploads, i would recomend using mysql storage as then you do not have to deal with moving client uploads between servers, or force them to upload to one server and store which server they are on. Your management server would also run a program to monitor the mysql cluster so that if a node goes down, it can be restored.
When developing make sure you use PHP5 and the latest mysql you can (4.1 i think it around a lot) as this will make clustering easier (If you use mysql3 you will have problems with your SQL syntax when you move to mysql cluster).
Hope this helps
|