Tuesday, June 11, 2013

Scalability and Availability using Proxies

The first thing that comes to mind upon hearing the word proxy is some sort of distribution facade. That's more or less what I will be writing in the blog post with a bit more here and there. 

When I was in college the word proxy meant to call out someone else' attendance. So, If a student A is not present in the class, during the roll call ,a student B will reply in a 'Present' when A's roll number is called. This is the essence of proxies, they are a singular interface for all incoming requests in a cluster/multi-server environment. They give the appearance that you are every-time requesting a single server URL like www.xyz.com while it is actually the proxy that you are contacting. And then the proxy based on the distribution algorithm that it comes programmed with, pushes the request to any of the servers present behind it. This distribution mechanism is out of scope of this blog and I will hopefully cover it in a future blog.

Proxies are very basic level of scalability and availability. You can have a proxy upfront with two servers running in cluster. If you feel the need to scale-up, then add more servers to the system to make it scale up to the growing traffic demands. 
Also the proxy will make the system more available. So, one of your servers' goes down (read crashes), the proxy will direct all the incoming traffic to the other available servers in the cluster automatically. So, essentially your application/site is up and you do not lose business. 

There are two ways in which proxies are created in a system a forward proxy or just a proxy and reverse proxy. 
A forward proxy is used generally to segregate an internal network from the internet. You can control/filter content going in and out of the network. So in this case the application is more of securing the internal network against unintended use, attack or access. And the internal users are protected against any mal-ware or problem causing content online.

The Reverse proxy is what is generally used as a availability and scalability medium. The entire set of servers sitting behind a proxy and the requests are directed to each one of them depending upon the traffic that they are currently handling. It's a technique for scaling out more than scaling up, but it does have the desired effect nevertheless. 

Using this mechanism you can achieve more than just handling fail-overs or load distribution. The proxies can also be used as a caching mechanism to cache a lot of non-varying data being presented to the requesting clients. Which when done properly on a global scale can really boost up the application performance, or at-least give a mirage of faster response times. It can also be used to handle regionalization, which is some thing that most of the content delivery network products do, but on a much larger scale and they use HTTP caching mechanism to achieve this. Again that is some thing out of the scope of this article.

This proxy mechanism (read load balancing) can be set at the database levels too, which done in the desired way helps in achieving availability and scalability both. You can set up the data base as master-slave, multi master-slave, multi-master-multi-slave or buddy replication modes to get the maximum throughput and least load.



No comments:

Post a Comment