Thursday May 18, 2006

Web Server 7 : Balance your load, Use Reverse Proxy

A “Reverse Proxy” ??? How ??

I mean a “Reverse Proxy”, a new integrated feature of Sun Java System Web Server 7. You can download it FREE. You may want to know, what is a Reverse Proxy?, what is the difference between a Reverse Proxy and Proxy? Reverse Proxy is a proxy to the WebServer, it act as a WebServer. That means, even though the content is served from the WebServer, person who access the Reverse Proxy will think that, the Reverse Proxy is the WebServer. In this way the actual WebServer is hidden from the user. Whereas in Proxy, the request is just forwarded through the proxy, So the actual WebServer is visible to the client.

Now let us talk about the load balancing feature of Reverse Proxy. What is a Load Balancer? To understand the answer to that question, let us consider a scenario. I have a web application which is used by millions of users. If I deploy this application on a single machine, then the load on that machine will be huge. Instead I will deploy this application on multiple machines (Cluster). Now I have to use some mechanism to share the load among these machines. Here comes the use of load balancing capability of Reverse Proxy into the picture. I configure my WebServer 7 as a Reverse Proxy to the above Cluster and provide Reverse Proxy's address to the users. So all the request will come to the Reverse Proxy, and it will route these requests to different machines in the cluster. There are three advantages.

  1. The actual WebServer is hidden from the server

  2. Load on each machine will be less

  3. High availability of the application.

Round robin algorithm is used for load balancing in WebServer 7. It supports session stickiness too.

You can use WebServer 7 for setting up a Cluster. WebServer 7 Cluster also supports session fail-over. In summary, WebServer 7 is a secured clusterable web server with embedded Reverse Proxy and Load Balancer.

Let us consider an example. For simplicity I am not creating a Cluster, instead am going to use two instances of different configurations (Say config1, Config2) as Cluster and an instance of RP as load balancer (Reverse Proxy). Also I am creating all the instances on the same machine. You can use Admin CLI commands (wadm) or Admin GUI to configure the above setup. The steps for creating such a setup is given below.

Using Admin CLI (wadm)

  1. Start Admin Server
    Execute <Install Root>/admin-server/bin/startserv command

  2. Start Admin CLI shell
    Execute <Install Root>/bin/wadm --user <admin user> --port <admin ssl port>
    You will get 'wadm' shell

  1. Create Config1
    wadm>create-config --http-port 8080 –-server-name config1 –-server-user root config1

  1. Create Config2
    wadm>create-config –-http-port 8081 –-server-name config2 –-server-user root config2

  1. Deploy same web application on the above configs
    wadm>add-webapp –-config config1 –-vs config1 –-uri /test <war file>
    wadm>add-webapp –-config config2 –-vs config2 --uri /test <war file>

  1. Create RP config
    wadm>create-config –-http-port 8082 –-server-name RP –-server-user root RP

  1. Create Reverse Proxy
           wadm>create-reverse-proxy –-config RP -–vs RP –-uri-prefix / --server http://<hostname>:8080, http://<hostname>:8081

  1. Create Instances
           wadm>create-instance –-config config1 <hostname>
           wadm>create-instance –-config config2 <hostname>
           wadm>create-instance –-config RP <hostname>

  1. Start Instances
           wadm>start-instance –-config config1 <hostname>
           wadm>start-instance –-config config2 <hostname>
           wadm>start-instance –-config RP <hostname>

Also you can use the new improved Admin GUI to configure load balancer (Reverse proxy). Do explore ....

I will discuss about the session stickiness support later.


About

regi

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today