Today, large scale websites are amazingly complex systems. As a result of this (and other factors), many websites eventually run into problems such as cost, performance and scalability. In fact, the problem is so ubiquitous that it’s not highly uncommon for websites to undergo major re-engineering once they hit a certain size threshold, in order to effectively keep up with growth and demand.
Fortunately, there are concepts and methodologies that, if followed correctly and consistently, will help minimize the aforementioned problems.
One such important concept is choosing the right Web Application Stack. The stack is made up of various layers (see diagram below). At each layer of the stack, there are several technologies to choose from. Often they are interchangeable, resulting in many different combinations depending on what suites the business needs best (cost wise, performance wise etc.).
As a demonstration, I will be talking about the popular video website, YouTube. The reason I have picked YouTube is because it is well known and widely used, and also because it’s Web Application Stack is one that is very widespread on the World Wide Web today. It’s called LAMP.
LAMP is an acronym that stands for Linux – Apache HTTP Server – MySQL – PHP/Perl/Python. As you can see, it’s made up of all the technologies used at various levels of the stack. As I mentioned earlier, the levels are quite interchangeable, which is why you have other competing stacks such as:
Windows Server – Apache HTTP Server – MySQL – PHP/Perl/Python
Windows Server – IIS – MSAccess – PHP/Perl/Python
Windows Server – IIS – SQL Server – ASP.NET
One of the most prominent reasons this stack has become popular is because of its free of cost, open source status. Many of todays big websites such as Google, Facebook, Youtube, Gmail, Digg, Wikipedia and Flikr use the LAMP stack.
Before proceeding further, lets define what scalability means. Scalability refers to the amount of data a website contains, and also the number of users it can simultaneously support. A scalable website is one that can easily support additional users and traffic by expanding hardware and bandwidth, without making changes to the software or structure of the website. If a website structure cannot cope with additional users, it has reached its scalability threshold.
Where does LAMP come in to all of this? Well firstly, as mentioned above, LAMP consists of free software, which makes it the perfect choice for Cost Effective scalability. As far as scalability itself is concerned, the software in LAMP, such as PHP allow for horizontal scalability. Each layer in the stack can expand and grow on its own, without having any unwanted effect on the other layers.
At this point, I’d like to mention the difference between scaling up and scaling out.
Scaling Up: This refers to upgrading already existing equipment, e.g. adding more RAM to the database server
Scaling Out: This refers to expanding the number of equipment working simultaneously, e.g. adding a second database server
Most times scaling up is more cost effective than scaling out, however over time scaling up will reach its limits and scaling out is inevitable.
Software in the LAMP stack encourages and supports scalability.
MySQL – Some of the ways in which MySQL supports scalability is by providing:
Scalability for read-intensive applications through multiple slaves
Scalability for read/write-intensive applications using multi-master replication and partitioning
Scalability for heavily used web sites using MySQL Cluster
In the case of YouTube, we know the following to be true today:
– Uses NetScalar for Load Balancing
– Uses a LAMP implementation with Python
When YouTube first started off, it hosted only a handful of videos and did not require much hardware or bandwidth. Over the past 5 years, this has changed dramatically, and the LAMP software bundle has allowed YouTube to stay alive without crashing.
Commoditization of hardware, bandwidth and software has meant that prices have gone down lower, and it is much more feasible now. Since LAMP uses Open Source software, reusing existing code libraries means we can now *stand on the shoulders of giants* so to speak. No time is wasted re inventing the wheel.
Apart from this, there is also the concept of having a light weight model. In YouTube’s case, this can be seen by noticing how similar and uniform all the pages are. The use of templates in PHP means that the design of the entire website can be uniform and centrally controlled and expanded, without an increase in overhead. In other words, PHP templates allow greater versatility and much easier access when editing content.