cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stev...@outerthought.org
Subject [WIKI-UPDATE] LoadBalancingWithModProxy Thu Dec 4 00:00:03 2003
Date Wed, 03 Dec 2003 23:00:03 GMT
Page: http://wiki.cocoondev.org/Wiki.jsp?page=LoadBalancingWithModProxy , version: 4 on Wed
Dec  3 23:08:40 2003 by TonyCollen

- It came out recently on infrastructure@apache.org a little "joke" about  mod_jk versus mod_proxy,
which is better, and so on...
?                                                                         -

+ It came out recently on infrastructure@apache.org a little "joke" about mod_jk versus mod_proxy,
which is better, and so on...
- Of course, I'm full-on promoting proxy, but my friends Noel J. Bergman  and Glenn Nielsen
had one question: how do I load balance a pool of  backend servlet container using mod_proxy?
This is a feature directly  supported by mod_jk, but there doesn't seem to be an easy way
to do  this with more "standard" (or distributed in the core of Apache 2.0)  modules.
?                                                                        -               
                                                   -                                     
                                -                                                        
                                                                                  -

+ Of course, I'm full-on promoting proxy, but my friends Noel J. Bergman and Glenn Nielsen
had one question: how do I load balance a pool of backend servlet container using mod_proxy?
This is a feature directly supported by mod_jk, but there doesn't seem to be an easy way to
do  this with more "standard" (or distributed in the core of Apache 2.0) modules.
- Well, there is a way: go down and buy a Cisco load balancer, because if  you need to have
that kind of environment, I'm sure you're going also  to have the money to buy one of those
nice little gadgets.
?                                                                         -              
                                                       -

+ Well, there is a way: go down and buy a Cisco load balancer, because if you need to have
that kind of environment, I'm sure you're going also to have the money to buy one of those
nice little gadgets.
- But wait, what if (for example) you don't want to go down the hardware route? As I outlined
in a page on the Cocoon Wiki available at  [ApacheModProxy], remember that also mod_rewrite
is one _very_ good friend.
?                                                                                        
                                              -

+ But wait, what if (for example) you don't want to go down the hardware route? As I outlined
in a page on the Cocoon Wiki available at [ApacheModProxy], remember that also mod_rewrite
is one _very_ good friend.
- And in case of load balancing, well, mod_proxy and mod_rewrite come together to offer a
pretty optimal solution, and incredibly enough,  available with only 5 lines of configurations
in your "httpd.conf".
?                                                                                        
                                                -

+ And in case of load balancing, well, mod_proxy and mod_rewrite come together to offer a
pretty optimal solution, and incredibly enough, available with only 5 lines of configurations
in your "httpd.conf".
- Let's point out that my description is based on the implementation provided by Jetty, as
I am familiar with its configuration, but other  servlet containers might just provide the
same functionality.
?                                                                                        
                                                 -

+ Let's point out that my description is based on the implementation provided by Jetty, as
I am familiar with its configuration, but other servlet containers might just provide the
same functionality.
- The feature "required" is the ability to specify a well-known string in the session manger,
so that each generated session will be identifiable  by Apache. In Jetty this feature is called
"WorkerName" and it is available on all session managers.
?                                                                                        
                                                        -

+ The feature "required" is the ability to specify a well-known string in the session manger,
so that each generated session will be identifiable by Apache. In Jetty this feature is called
"WorkerName" and it is available on all session managers.
- Now, to the Apache configuration. The first thing we have to do is to create a "RewriteMap"
file where all the different associations LBx ->  hostname:port will be kept. For example,
I call mine "balancing.conf", and here is what I have inside:
?                                                                                        
                                                     -

+ Now, to the Apache configuration. The first thing we have to do is to create a "RewriteMap"
file where all the different associations LBx -> hostname:port will be kept. For example,
I call mine "balancing.conf", and here is what I have inside:
- Now, in addition to all I've previously said on mod_proxy in the Wiki, this are the relevant
bits to make sure that Apache 2.0 will load  balance your web applications on all backend
machnes, and that it will do so by also keeping session affinity.
?                                                                                        
                                                 -

+ Now, in addition to all I've previously said on mod_proxy in the Wiki, this are the relevant
bits to make sure that Apache 2.0 will load balance your web applications on all backend machnes,
and that it will do so by also keeping session affinity.
- The first line (RewriteMap) will simply tell Apache to load a map called "SERVERS" of "rnd"
type. Look up what that means in the  mod_rewrite configuration, but it basically implies
that when I'm going to do a lookup for the server associated with the "ALL" key, I will be
 given one of the three different backend entries, randomly selected (for load balancing).
?                                                                                        
                                                                                         
                                                                                         
     -

+ The first line (RewriteMap) will simply tell Apache to load a map called "SERVERS" of "rnd"
type. Look up what that means in the  mod_rewrite configuration, but it basically implies
that when I'm going to do a lookup for the server associated with the "ALL" key, I will be
given one of the three different backend entries, randomly selected (for load balancing).
- Given our example, if the cookie looks like "jsessionid=XXXXX.LB2", the lookup will make
it so that the request will be proxied to  http://backend2.betaversion.org:8080/.....
?                                                                                        
                                           -

+ Given our example, if the cookie looks like "jsessionid=XXXXX.LB2", the lookup will make
it so that the request will be proxied to http://backend2.betaversion.org:8080/.....
- The second "RewriteRule" will do exactly the same of the first "RewriteCond/RewriteRule"
set, but will actually act on the request  URI. This works in case your client doesn't support
cookies (or, Cocoon folks, replace jsessionid with continuationid, and you have the flow 
load balanced in a second!).
?                                                                                        
                                          -                                              
                                                                                         
     -

+ The second "RewriteRule" will do exactly the same of the first "RewriteCond/RewriteRule"
set, but will actually act on the request URI. This works in case your client doesn't support
cookies (or, Cocoon folks, replace jsessionid with continuationid, and you have the flow load
balanced in a second!).
- So, if a request comes in as /webapp/index.jsp;jsessionid=XXXX.LB3, it will be proxied to
 http://backend2.betaversion.org:8888/webapp/index.jsp; jsessionid=XXXX.LB3 ...
?                                                                                        
  -

+ So, if a request comes in as /webapp/index.jsp;jsessionid=XXXX.LB3, it will be proxied to
http://backend2.betaversion.org:8888/webapp/index.jsp; jsessionid=XXXX.LB3 ...
- This rule simply takes any request not containing an appropriate session ID (cookie or URL)
and will proxy it to ONE OF the backend  servers at random, therefore literally balancing
your requests on a pool of backend servers.
?                                                                                        
                             ^^            -

+ This rule simply takes any request not containing an appropriate session ID (cookie or URL)
and will proxy it to ONE of the backend servers at random, therefore literally balancing your
requests on a pool of backend servers.
?                                                                                        
                             ^^

- Read the detailed documentation of mod_proxy and mod_rewrite, especially for the RewriteMap
directive, and you'll see precisely what  I mean...
?                                                                                        
                                             -

+ Read the detailed documentation of mod_proxy and mod_rewrite, especially for the RewriteMap
directive, and you'll see precisely what I mean...



Mime
View raw message