High traffic websites

I often work with sites that has a high user-base and pageviews that means one has to find techniques that help the webservers handle the load. As most often is the use is spread in specific peaks among the day. But how does one in the most efficient way handle load? Most commonly you have hardware loadbalancers and either virutal or physical servers taking the traffic in. But that will be expensive and a smaller site with high usage might not have the funds to buy into expensive loadbalancers and hardware. So how does one get the most out of a infrastructure?

The first part is to use any old structure as a template for the new since the best data will be gathered from the old environment. How high the load is on the servers, how many peaks per day the servers receive and so on. As a guideline take the highest peak and count 30 minutes before and after to get the highest pageview peak you have. This will be the low tier traffic and during which time you will either need to make some sacrifice and have longer load times or use more capacity to handle. The normal tier will be in 8 hours of the day (longer if you have a non-work related site). The high tier is when your site is not loaded and therefore fastest.

I have seen many combinations to this effect and the most efficient (unless you use things like AWS or similar) is to use a combination of two webservers. Namely Nginx and Apache.

Since Apache is a workhorse with more then a decade in the business this is in my opinion the best choice as a webserver and to loadbalance between several Apache servers I often use Nginx. With Apache in the backend handling the more CPU heavy PHP you have Nginx in the front caching and serving content to the clients with compression and speed. The whole idea is to use Nginx to serve the static content and give Apache only the dynamic either locally or on a separate  server. To find out more check the archives there you can find scripts and configurations that will help you in this process.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s