6 Strategies for Scaling BBC iPlayer
The BBC's iPlayer site averages 8 million page views a day for 1.3 million users. Technical Architect Simon Frost describes how they scaled their site in Scaling the BBC iPlayer to handle demand:
- Use frameworks. Frameworks support component based development which makes it convenient for team development, but can introduce delays that have to be minimized. Zend/PHP is used because it supports components and is easy to recruit for. MySQL is used for program metadata. CouchDB is used for key-value access for fast read/write of user-focused data.
- Prove architecture before building it. Eliminate guesswork by coming up with alternate architectures and create prototypes to determine which option works best. Balance performance with factors like ease of development.
- Cache a lot. Data is cached in memcached for a few seconds to minutes. Short cache invalidation periods keep the data up to date for the users, but even these short periods make a huge difference in performance. Caching doesn't have to be for a long time to see a benefit. Varnish is used to cache HTML pages. Much of the invalidation is time or action-based (e.g. someone adds a new favourite).
- Break the page into personalised and standard components. A common main page is created so that it can be cached separately from personalized data. This gives faster smoother viewing experience. Personalized elements are loaded using Ajax. Varnish's flexible caching policies are used to cache these elements. User favorite lists are cached for as little as a few minutes.
- Use lots of servers. Scaling is horizontal using a pool of servers. Web servers are stateless. Pages are served out of two data centers for high availability.
- Test the site before we launching. Load test to track down and fix problems before users see them.