Scaling PHP applications
June 8, 2012 Leave a comment
Drupal and WordPress are ranked among Alexa’s Top 20 websites which gets more than 100 million page views per day. Drupal and WordPress are supported by PHP and here we will explain how these these websites cope with the load factor for improved user experience. In this connection, PHP scaling techniques, software stack, user stories and real-life statistics are provided to substantiate the high performance of these sites.
Scalability of a web application
Scalability is the ability of your application to handle any growing capacity (infrastructure and codebase) to serve web pages by easily adding more servers, or increasing the power of each server.
Scaling up application server (Vertically)
When a web app is scalable, this means you can enhance the overall power of the server (CPU, memory, etc) without any change in the software. It uses lot of the resources available and hence it becomes difficult to implement. But, this isn’t a good strategy for scaling, even though it adds resources to a single node in a system. Because the server has hardware limitations when you try to increase the power of a single server. Furthermore, the first bottleneck is typically the bandwidth (I/O), and not the CPU or memory, so this helps some, but it goes in the wrong area.
Scaling out in Multi-Server environment
When scaling up server does not work for you, try the scaling out option which involves adding more nodes to a system. This is not offered by VPS or other hosting companies. You can use multiple servers and distribute the traffic. You can easily implement scaling out in multi-server environment. In order to overcome the bandwidth (I/O) issue on the web server, you have to just distribute the load equally. You need a special kind of load balancer which intelligently forwards requests between all the web servers.
Persistent Load balancer
No changes in software architecture
- When the server goes down, all the session data will be lost
- Load balancer is the bottleneck
- Persistent Load balancer is costly
Scaling down (Horizontally) - The best way to improve high traffic web application
Scaling down for business is significant since companies want to pay only for what they use. For example, if you want to use 5 servers for a couple of hours in a day, you have to pay only for those five servers – for two hours only. However, normal hosting charges for the servers is paid on a monthly basis, regardless of the actual usage.
Scaling a PHP application
Scaling out an application, regardless of the type of hosting, involves the following four steps:
1. Use the new server given by the hosting provider
2. Setup the server and configure the server software
3. Setup your application on the server and
4. Setup a persistent load balancer to distribute the local data located across multiple servers