Using Cloud-based Load Balancing To Horizontally Scale Effectively

In most typical web-server application setups, one or websites are hosted upon a single LAMP (Linux Apache MySQL PHP) computer. This computer is provided by either a cloud based host as a node or slice, or as a shared server as a packaged offering.

For most scenarios, the above is perfectly fine and will run most low-medium traffic blogging, corporate, e-commerce web applications with little bother. However, the problem that is apparent is when low to moderate traffic expands to sustained high traffic or even bursts of high traffic.

In the age of social media, platforms such as Reddit, Twitter, Facebook can lead to a web link being shared across the world in seconds. The snowballing effect can really test the limitations of not only the software code and web server configuration, but the underlying network hardware, processing power and memory available.

The point at which the software running is no longer within the capability of the hardware provided is when the web link will no longer be reachable. On Reddit the phrase ‘Hug of Death’ is used to describe this exact scenario. Links shared to the popular pages of Reddit are seen by millions of people and when all of these people attempt to follow the link within a short period of time, the hosting server can become overloaded.

When a website is stored upon a single computer the only option may appear to increase the underlying hardware capability to satisfy demand. Using Rackspace as an example, it is possible to achieve this (increasing RAM, processing power etc) but this requires re-building of the server and leads to complete downtime as the server is rebooted.

Horizontally scaling is the answer to this problem and involves, adding additional computers alongside the main server as and when required. Conversely, additional computers can be removed as and when they are no longer required.

To achieve this, the following terminology should be understood:

  • Cloud Database

    On a single computer/node/slice setup, installing MySQL or equivalent would fulfill the database requirement of the application. However, in order to efficiently scale the database needs to be separate from the server applications. We will use the Rackspace Cloud Database service. This provides a scalable and managed MySQL database service for a low hourly fee.

  • Load Balancer

    A load balancer sits as the main point of contact between an external content request and the servers in the background actually fulfilling the request. Rackspace provide a dedicated IP load balancer that is used as the IP on the domain A records. Traffic is billed between external servers and the load balancer but internal traffic is free of charge. A single load balancer can support 20,000 sustained concurrent connections and in huge spikes up to 100,000 will be fine.

  • Master Server

    A single computer/node/slice that is the main upload and configuration point. All changes made to this are propagated to any slave servers.

  • Slave Server

    One or more slave servers are kept up to date by the master server so remain in sync with any update pushed. At times of increased load, additional slave servers are added from backups, the master server updated with the internal IP’s of the slave servers and everything synchronised. Additionally, the slaver servers are added to the pool of servers behind the load balancer.

  • SSH Keys

    In order to allow the master server to automatically connect and maintain the slave servers, a public key is created on the master server and copied to the slave server(s).

  • Replication (Lsync)

    Lsync is used to do the heavy lifting of checking for updated files and copying across changes between the master and slave servers.

  • Reverse Proxy Server (Varnish)

    Varnish is an application used as the main port of call on the slave servers. It responds to incoming requests from the load balancer and decides (based upon rules set) whether to reply directly or relay the request back to the master server. It is useful when there are certain parts of the web application that must update files and therefore should be run by the master server.

  • Image Backups

    Rackspace allows the creation of full node (we’ll use this term from now on instead of computer) images. These images can be created at any stage and then used to re-deploy a live instance of the the configuration within the image. We will use image backups to create duplicate slave servers quickly – relying upon Lsync to keep them updated.

  • Content Distribution Network (CDN)

    A final thing to note is the use of a CDN for uploads of static files, which are possibly accessed frequently. Rather than serve these from the same nodes responsible for processing application data, it is beneficial to hand-off the responsibility to a CDN. This would require knowledge of uploading files directly to a CDN either manually or programmatically within the web application.

  • Optional: Memcached (Fast Key-Value Based Storage)

    An additional option for helping with high traffic scenarios is to utilise caching where possible to minimise database hits. We will go through installing a shared node for Memcached.

So, let’s get started. Read through the following collection of step-by-step.

By this stage, we have created a Cloud based database instance and copied existing databases across. Any application code should also be updated at this point to point to the Cloud databases in order to prevent the need for a future synchronisation of data.

We have also optionally created a shared instance hosting the memcached application. Again, any application code using the caches should be updated to point to the new shared ip.

The next stage is to create the actual server setup. This includes the following:

  • Create a Master Server.
  • Create an initial Slave/Clone Server.
  • Creating a Load balancer to place infront of the servers.

Read the full step-by-step for creating servers for load balancing.

Category: cloud server

Tags: cloud horizontal load balancer scaling server

0 comments

Login or Register to post comments.

My Work!

Value My Car Android app logo

Value My Car Android app

Value any car for free - all makes and models available.

Get a free valuation of any car based on car depreciation trends for the specific make and model, the price you paid, your length of ownership and mileage covered. You can find out how much a car purchased at any point during its life-cycle will continue to depreciate.

view app
Value My Car iOS app logo

Value My Car iOS app

Value any car for free - all makes and models available.

Get a free valuation of any car based on car depreciation trends for the specific make and model, the price you paid, your length of ownership and mileage covered. You can find out how much a car purchased at any point during its life-cycle will continue to depreciate.

view app
NiceAreas.co.uk Website logo

NiceAreas.co.uk Website

Search For UK Areas Based on any Criteria

A number of tools to help research parts of the UK down to postcode sector level using multiple datasets and a variety of data combination and aggregation.

Including crime, house prices, travel links, jobs and more!

visit website
Mortgage Calculator Expert iOS app logo

Mortgage Calculator Expert iOS app

This comprehensive mortgage calculator includes eight different calculators in one app!

Adjust repayment types, rate types, initial offers/periods, base rates, terms, SVR's, overpayments, collars/caps, any fees (add to loan or upfront), mortgage start dates, simulated rate changes and more!

view app
Mortgage Calculator Expert Android app logo

Mortgage Calculator Expert Android app

This comprehensive mortgage calculator includes eight different calculators in one app!

Adjust repayment types, rate types, initial offers/periods, base rates, terms, SVR's, overpayments, collars/caps, any fees (add to loan or upfront), mortgage start dates, simulated rate changes and more!

view app
Amazon Alexa Skills logo

Amazon Alexa Skills

Multiple Alexa Skills

Voice-first (with additional display elements too) skills for Alexa devices.

Including:

BrainPickers! Guess The ... series of games.

SalaryBee - Salary calculations by voice.

TheMoneyCalculator - Finance calculations by voice.

NiceAreas - Property valuations, Area information and census information by voice.

Who Said That? Friends Quiz.

..plus...more to come!

visit website
UKTaxCalculators.co.uk iOS app logo

UKTaxCalculators.co.uk iOS app

The UK's most comprehensive FREE tax calculator app

The website condensed into a full featured and easy to use iPhone/iPad/iPod app!

Check tax on any income source, compare salaries and much more!

view app
UKTaxCalculators.co.uk Android app logo

UKTaxCalculators.co.uk Android app

The UK's most comprehensive FREE tax calculator app

The website condensed into a full featured and easy to use Android app!

Check tax on any income source, compare salaries and much more!

view app
UKTaxCalculators.co.uk Amazon app logo

UKTaxCalculators.co.uk Amazon app

The UK's most comprehensive FREE tax calculator app

The website condensed into a full featured and easy to use Amazon app!

Check tax on any income source, compare salaries and much more!

view app
UK Tax Pro iOS app logo

UK Tax Pro iOS app

Calculate UK Tax on any income type with single or multiple income sources.

Get a full breakdown of your tax, print/email from within the app.

Full compliment of professional features such as rates and allowances, news, guides and calendars.

view app
Parcel Dogs Game For iOS logo

Parcel Dogs Game For iOS

This 'top-down' racing game involves the player taking the role of Jim, our Speedy Parcel delivery dog. Now Jim has to go around his picking up parcels with the help of his map but has a hard time of it thanks to his nemesis Crazy Dave.
visit website
UKTaxCalculators.co.uk Website logo

UKTaxCalculators.co.uk Website

The UK's most comprehensive FREE online tax calculator suite

The Tax Calculator provides a full breakdown of tax for PAYE, CIS or Self Employed individuals providing options for Pension Calculations, Tax Codes, NIC Letters, Bonuses, Salary Sacrifice Schemes and more.

For people with multiple income sources, the UK Tax Calculators Wizard calculates every UK tax across all incomes in the same manner a tax return would.

visit website
Walleto.co.uk Website logo

Walleto.co.uk Website

The first truly easy to use, free online budget planner

There has never been an easier way to forecast your finances in less 5 minutes!

The budget calculator takes all your income details, across any type of income, calculates the taxes due, subtracts your expenses (both from extensive presets to your own defined expenses). You are presented with an online forecast, comparisons with other users with similar households as well as a printable report version to use as income and expenses chart.

visit website
TheMoneyCalculator.com Website logo

TheMoneyCalculator.com Website

Full featured online mortgage and loan calculators

You can use this website to calculate mortgage payments, forecast future interest rate effects, calculate remaining balances, check debt consolidation options, plan your savings, plan your pension as well as plan for your future house purchase. A lot of planning made easy!

Find a professional mortgage adviser or financial adviser online through our UK-wide network.

visit website
WhereDidMyTaxGo.co.uk Website logo

WhereDidMyTaxGo.co.uk Website

Ever wanted to know where the UK Government has been spending YOUR tax payments?

The WhereDidMyTaxGo.co.uk website takes your gross income since 2003, calculates your taxes (PAYE only), and uses the Governments expenditure data to give you an approximation of how much of your actual payments were spent where.

The personalised aspect of this website is a unique use of Government data.

visit website
TaxPenny.co.uk Website logo

TaxPenny.co.uk Website

Finding an Accountant the Smart Way

TaxPenny provide an online platform for accountants and those seeking an accountant to connect. Potential clients describe their circumstances, the work required and set a maximum price rage. Quotes are returned to clients within 1 working day. Accountants are able to search for new clients through various criteria and bid auction style for leads or purchase adhoc.

visit website
World Tax Calculator iOS app logo

World Tax Calculator iOS app

Compare Tax and Cost of Living of Major Economies

Calculate and/or compare taxes for major economies across the world, see differences in take home pay and see a cost of living comparison with a list of common purchases people make.

view app
World Tax Calc Android app logo

World Tax Calc Android app

Compare Tax and Cost of Living of Major Economies

Calculate and/or compare taxes for major economies across the world, see differences in take home pay and see a cost of living comparison with a list of common purchases people make.

view app

My Blog!

27/01/15 19:37:10

Using Cloud-based Load Balancing To Horizontally Scale Effectively

In this quick guide, we will go through what is required to convert an existing singular LAMP setup to a horizontally distributed network of servers sitting behind a Load Balancer. This guide will utilise a number of services from Rackspace Cloud.

cloud server

0

19/12/14 11:13:49

Creating Servers For Load Balancing

In this step-by-step guide we create the underlying server structure required for successful load balancing.

cloud server

0

14/09/14 14:40:59

Creating a Shared Memcached Cloud Instance

Key-value memory based storage can be a significant performance boost, as well as load reducer, for database heavy websites. Follow our step-by-step guide to setting one up using the Memcached application.

cloud server

0

27/06/14 12:12:01

Copying Data Across From Existing MySQL Databases to a Cloud Database

Now that you have created a database in the cloud, how do you get it populated as quickly as possible. Follow our step-by-step guide.

cloud server

0

27/03/14 13:14:05

Converting a Single Node MySQL Application to a Cloud Databases Instance

Switching from an existing single database application to a database in the cloud requires two steps. First is to actually create the cloud database instance. The second is to migrate your existing data across. We describe the steps required.

cloud server

0

.. or read all of my blog!

Get in touch!

Do you have any questions for me? An idea for an exciting new website or mobile application? Maybe you just want to leave a comment regarding one of my websites or apps? If yes then you've found the right place!

Complete the form below and I will get back to you as soon as possible. If you would prefer to get in touch via Twitter, you can reach me there using @rayarmanappdev.