• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Loadbalancing: Apache -> mod_rewrite; session lost

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to loadbalance several backend servers (JBoss - Jetty). I also have restriction not to use ajp13(because it can not support SSL protocol). Thats why I use Apache + mod_rewrite + mod_proxy. We have 3 servers:
http://server_one:8080/somecontext/
http://server_two:8080/somecontext/
http://server_tree:8080/somecontext/
The modification in httpd.conf
Listen 80
<VirtualHost _default_:80>
RewriteEngine on
RewriteLog logs/proxy_rewrite.log
RewriteLogLevel 9
RewriteMap server rnd:/conf/rproxy.conf

RewriteRule^(http|https)://.* - [F]
RewriteRule ^/$/somecontext/[R]
RewriteRule ^/(.*)$to://${server:web}/$1
RewriteRule ^to://([^/]+)/(.*) http://$1/$2 [P,L]

ProxyRequestsOn
ProxyPassReverse / http://server_one:8080/
ProxyPassReverse / http://server_two:8080/
ProxyPassReverse / http://server_tree:8080/
</VirtualHost>
the file rproxy.conf contains:
www server_one:8080|server_two:8080|server_tree:8080
So far, so good. I can access http://server/ and mod_rewrite randomly chooses one of the servers ant distributes request to it. It is reverese proxied to http://server/context, so the end user is not aware for the real name of the server. But the problem is that there is no mechanism like "sticky sessions" provided (like in ajp13), so once I log in.. i the next request I am happily distributed to other server where no session is exported. Can someone help me with any idea on how to overcome this? Is there a mechanism of Session Replication in JBoss. Any suggestions, links, literature.
Thanks in advance.
[ July 11, 2003: Message edited by: Deyan Sultov ]
 
Deyan Sultov
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the answer:
RewriteMap element can distribute load between them. But since Apache is not a load-balancer and no mechanisms like "sticky session" is supported (as in ajp13) each successive request can end up on a new server where session is lost. Thats why we have to implement clusterind and HTTP Session replication:
1. Ensure that jbossha-httpsession.sar is found in \all\deploy.
2. Ensure that cluster-service.xml is found in \all\deploy and properly configured.
3. Add to \all\deploy\jbossweb-jetty.sar\META-INF\jboss-service.xml
<Set name="store">
<New class="org.jboss.jetty.session.ClusterStore">
<Set name="actualMaxInactiveInterval">604800</Set>
<Set name="scavengerPeriod">3600</Set>
<Set name="scavengerExtraTime">900</Set>
</New>
</Set>
4. Add to web.xml
<web-app>
<distributable/>
.......................
<web-app>
5. Run jboss with run -c all parameter.
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic