How do you rewrite/recode a website to be scalable?

cakephp, php, ruby-on-rails, scalability, scale

Solution

This is a quite wide question, and it's going to be pretty difficult to give you a definite answer -- but a couple of ideas :

- First of all, do not pre-optimize !

- Make sure your application works ; that's the most important thing.

- And, only when it becomes necessary, start optimizing.

- PHP by itself generally scales well :

- Add a couple more Apache+PHP servers, load-balance your users

- And this tends to work really easily

- Filesystem doesn't scale that well / that easily :

- it's not shared accross servers

- sharing filesystem (with NFS, for instance) can sometimes cause problems.

- The database is generally the hardest part, when it comes to scaling :

- Having more than one "write" server is hard

- Having more than a couple of "read" servers, generally using replication, can become a pain for maintenance

- You'll have to think about sharding, one day or another, if replication is not enough.

- Use lots of caching : the more cache you can use, the less queries you'll make to the DB, the better it'll be

- memcached is great, and scales well : just add a couple of servers, and you get a couple of more GB or memory in your caching-cluster

- Using a reverse-proxy, so your Apache+PHP servers have less work to do, helps too.

And a quick couple of links that might give you some ideas :

- Database Sharding at Netlog, with MySQL and PHP

- Scaling WikiPedia with LAMP: 7 billion page views per month

Problem

How do you rewrite a website to be scalable?(traffic) I work with mainly PHP and some Ruby on rails and i know its a generic question. I'm just looking to increase my knowledge so any advice would be useful. Thank you in advance ;-)

Original source