Clustering and Load Balancing in Tomcat 5, Part 2
Subject:   Fail over utility, Load balancing with URL redirecting
Date:   2004-08-22 12:37:36
From:   srinip
Response to: Fail over utility, Load balancing with URL redirecting


Thanks for the feedback on Clustering and Load Balancing article.

Can you e-mail me the error message you are getting when using ServerUtil class. I have the configuration working on my home PC and am curious to see what kind of error message the load balance is throwing in your configuration.

Also, regarding URL redirecting it should work by redirecting the Http request to the available cluster member (this is a simple forward to the new URL). This should work with any URL (internal server or external). Let me know what's the server configuration you are using in your web application.


Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Fail over utility, Load balancing with URL redirecting
    2004-08-23 17:02:36  yogesh_prajapati [View]

    As such your server util class works fine but it always starts and stops MCastService as many times as no of rules configured in rules.xml. This process is repeated for ever single incoming request. I am not sure if this is a good approach to be adopted. During start/stop of this temporary McastService there are warnings generated on other tomcat instancess running "clusterapp", I have sent the stack trace to you via email.

    About Redirection: I had a look into Tomcat BalanceFilter code it uses response.sendRedirect(..) method. There should be provision for more than just redirect. (I know this is something beyond the scope of what you have done) As I understand from the real application needs , this should not be (and can not be) a simple forward to new URL because of two reasons:

    1. Size limitation on URL rewriting. What if your request has a number of parameters size of which spans over beyond the limit of data your URL could carry. I am talking about simple URL size limit in HTTP GET Vs HTTP POST secenarios.

    2. Redirecting to local internal server (where actual Tomcat server running) changes the URL on client web browser (in this case to local internal address as hardcoded in rules.xml) and hence not acceptable. I think there should exactly the same mechanism between Tomcat Worker and actual Tomcat Server as it has been between Apache and Tomcat to for request forwarding transparently.

    • Fail over utility, Load balancing with URL redirecting
      2006-03-17 06:36:55  ipolak [View]

      I had the same problem, so i created my own BalancerFilter class.

      On the point where the BalancerPortal class uses a hres.sendRedirect(encoded);

      I implement the following strategy:

      A) determine new URL (most of the time simple substring replacement)
      B) get content of that URL (using e.g. apache's org.apache.commons.HttpClient)
      note special treatment is necessary to handle POST requests, parameters need to be copied, but not all the request headers (since there is a length attribute which might give problems).
      C) write content on the reponse outputstream of the doFilter parameter.

      Note that in my current setup there is no security for the other nodes, but this could be implemented using htaccess rules by restricting clients to the ip of the balancer app.

      I think the neatest approach would be to be able to specify a Strategy object using the xml configuration of the balancer so you can plug-in your own strategy class for handling a request.

      Maybe I'll rewrite my solution in such a way.
      First I must now make sure that all my sessions are Serializable....:)
    • Fail over utility, Load balancing with URL redirecting
      2005-04-02 07:13:16  muki_man [View]

      im trying to use the article and it was really good. do you any idea to integrate Apache Axis in the cluster? thanks!