WildFly 8 Clustering and Session Failover (Tech Tip #16)

This blog contains a video tutorial on how to setup up HTTP session failover using WildFly 8. Specifically, it shows:

  • Introduction to WildFly and Managed Domain concepts
  • Setup up a 2-instance cluster
  • Deploy a WAR file to the cluster using centralized administration from admin console
  • Access the application on one node and add HTTP session attributes on it
  • Shutdown that instance and show HTTP session failover by accessing the application on other instance

Enjoy!

Be Sociable, Share!

51 thoughts on “WildFly 8 Clustering and Session Failover (Tech Tip #16)

  1. Hello, Arun.

    How are you?

    Congrats for great article, really very cool.

    Where I can get package http-1.0-SNAPSHOT.war ? I’d like to do some test in my lab.

    The package is private or public?

    Thank you.

  2. Arun,

    Thanks for the great article! I have one question – do we have to use Apache httpd for fail-over? If so, do we install Apache httpd together with WildFly? Would Apache httpd then replaces functionality of Undertow?

    Yu

  3. Yu,

    Apache httpd will only be the front end proxy. A future version of WildFly 8 will allow Undertow to be used as proxy as well, but not in WildFly 8.

  4. Hi Arun,
    Its a great article.. Thanks for that! I have one question for you, I am using 1 ELB and 2 Cent OS application server instance with JBoss. Where do you suggest to put the Domain controller? As that instance goes down then how system will work?

    Thanks
    Benay

  5. Domain Controller is used only for the administration purpose and is not used during runtime. The requested is routed to the server-group with individual instances.

    Domain Controller can be placed on either of the machine, or even on a separate machine as well.

  6. Hello Arungupta,

    Gr8 video..!!! i have configured my clustering jboss wildfly 8 by ur way,the war file is working in different ports.But i configured and connect localhost/mywarfile.xhtml with http 2.2.26 + mod_cluster combination to connect jboss wildfly and it is not working.so could you please help me out from this issue?

  7. Hello Arun,

    I have configured server-three as http:8340/mywar and server four as http:8440/mywarfile.if i started the jboss server i am able to access the locahost/myfilewar but when i stopped the server three i am getting below error.

    I am getting 503 Service Temporarily Unavailable
    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

    can you please tell what went wrong?

    Thanks & Regards,
    Mohammed

  8. Hello Arun,

    Thanks for you nice documentation and video.

    I’m currently running my JBoss cluster using S3Ping configuration in AWS under Elastic Load Balencer, and this configuration is active-active and my application is not working as expected with this configuration and its more suitable with active-passive configuration, So I followed this documentation – https://docs.jboss.org/author/display/WFLY8/WildFly+8+Cluster+Howto , It’s worked for me except mod-cluster configuration.

    As I mentioned above, running all the instances in AWS cloud, launch 3 instances
    1. Domain controller and Master
    2. Slave
    3 Mod-cluster

    Master-Slave configuration is working perfectly and mod-cluster configuration is not working for me.

    1. In mod-cluster configuration, how will detect my master/slave instances, because there is no such configs in VirtualHost file.
    2. Is this confiration will work in AWS infrastructure

    Please advise me to configure this. thanks in advance.

    Regards,
    Jithin

  9. Arungupta,

    please advise me to configure httpd.conf (apache side) configuration for your above video?

    Thanks & Regards,
    Mohammad

  10. Hello Arungupta,

    i have started two instances in standalone.xml by using below command,

    ./bin/standalone.sh -c standalone-ha.xml -Djboss.node.name=node1

    and another instance start by same but with port offset

    ./bin/standalone.sh -c standalone-ha.xml -Djboss.socket.binding.port-offset=100 -Djboss.node.name=node2

    i have configured my front end server (apache 2.4) by below configuration,

    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

    # Reverse Proxy

    BalancerMember ajp://localhost:8009/ route=node1
    BalancerMember ajp://localhost:8109/ route=node2
    ProxySet lbmethod=byrequests
    ProxySet failonstatus=404

    ProxyPass / balancer://mybalancer/ stickysession=JSESSIONID|jsessionid

    ProxyRequests Off

    Order deny,allow
    Deny from none
    Allow from localhost

    # Balancer-manager, for monitoring

    SetHandler balancer-manager
    Order deny,allow
    Deny from none
    Allow from none

    it is working fine when we connect through the apache but if i stop node1 and restart it
    i have got below warning

    WARN [org.jgroups.protocols.TP$ProtocolAdapter] (INT-1,shared=udp) JGRP000031: node2/web: dropping unicast message to wrong destination 109fb003-b554-43f3-463f-183b82e95308

    after that if i access the warfile through apache i have got an error like

    ERROR [org.apache.jasper] (default task-1) JBWEB005015: The JSP container needs a valid work directory [E:\jboss_3\standalone\tmp\cluster-demo.war]
    2014-06-24 12:31:10,318 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to //cluster-demo/index.jsp: org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

    please help me to overcome from this issue..!

    Thanks and Regards,
    Mohammad

  11. Hi Arungupta,

    Thanks for your quick reply..! i have already posted in jboss forum too. but there is no solution for this issue.

    Thanks & Regards,
    Mohammad

  12. Hi Arun
    I followed your tech tip very closely. I now have a domain controller running 2 host (2 different machines). I Also used your test code that you provided. Every thing works on every host (which runs 2 servers each). Can you please tell me how to get the hosts to “talk” to each other? For example if I add info on host 1, how do I get Host two to show that info?
    Thanks in advance

  13. Hi Arun,
    I configured wildfly in two system(master and slave) and able to control from center domain controller all the instances, but in my slave I am getting following exception

    Server:server-four-slave] 06:32:05,826 ERROR [org.hornetq.core.server] (default I/O-1) HQ224018: Failed to create session: HornetQClusterSecurityException[errorType=CLUSTER_SECURITY_EXCEPTION message=HQ119099: Unable to authenticate cluster user: HORNETQ.CLUSTER.ADMIN.USER]

    And session are not replicated in my slave instances but session replication is working properly in all instances of master host.. can you please suggest me whats going wrong do I need to do any special configuration?

  14. Hello Arun,

    This is a very good Article. I am involved in a project that requires setting up a HA using Wild Fly on multi nodes. The configuration should be Load Balancing and not just Fail-over.

    Could you point out to any resource that could help me with this?

    Regards,
    Vivek Raman

  15. Great video Arun! Very detailed and informative! That was cool how you showed the session data being failed over transparently. Does that easy failover also work for JEE websockets? If so, is there any additional configuration required to make that work? If not, is there a plan to make this work? I am just not sure if the websocket connection is considered part of the session data that gets failed over or if there are additional steps required.
    Thanks in advance,
    Fino

  16. Fino,

    Stay tuned for a blog on WebSocket connection failover, coming shortly. WebSocket clients have to reconnect on failure, and this would act as failover.

  17. Hi Arun, Is there any information on how to use mod_cluster? Also is it possible to use failover with the CDI ViewScope? I’m seeing that the data is being lost when loading balancing between hosts. Any chance for a more realistic example?

  18. Hi Arun,
    we wanted to upgrade our JBoss7 servers to wildfly.
    But we have problem during our “logout” action where we are invalidating the sessions.

    While a long-running conversation is started and we are invalidating the session, we are getting exceptions and the WildFly server is completly blocked. We need to restart it.

    Exception is always thrown with WildFly version 8.1 and 9.0alpha1.
    Also the hudson build #1439 ip to #1449 are not working.

    But using the HudsonBuild #1334, everything is working as expected.
    We have already posted in the forums, but didn’t yet got an anwer:
    https://developer.jboss.org/thread/249822

    The forum post has a link to a demo war where we can reproduce the problem.

    Thanks for any help,
    Tom

  19. Hi Arun,

    I’m running one clustered active-active Jboss7 application in AWS using ELB(autoscaling) with S3Ping module, I want to upgrade Jboss7 to Wildfly8. S3Ping supports in Wildfly8 or is there any other way I can achieve this configuration ?

    Regards,
    Jithin

  20. >>A future version of WildFly 8 will allow Undertow to be used as proxy as well, but not in WildFly 8<<

    Hi Arun,
    I am currently using WildFly v8.2.0 , does this allow Undertow as proxy or is Apache httpd still used as proxy ? how can i find it ?

  21. arun,
    Could you please throw some pointer towards setting-up a similar (master-slave) cluster environment from the same machine by running multiple instances of Wildfly in it ?

  22. Hi Arun,

    Very helpful article. Thank you!

    Can you point me to any documentation or a solution to a scenario where the domain controller is taken offline? Such as a crash, or the host machine is shutdown or otherwise rendered inaccessible?

    With my testing I’m finding that when the domain controller dies, the host controllers will remain available, but the session failover no longer works. How should this be handled? I’ve looked at the –backup and —cached-dc options but it didn’t seem to be complete or address this situation.

    I’m using Jboss-as-7.1.1.Final, has anything changed with regards to this situation in wildfly 8?

    Thanks.

  23. i had much the same problems as AWS in Azure.
    I think it’s down to the fact that there is no multicast configured.

  24. i had much the same problems as AWS in Azure.
    I think it’s down to the fact that there is no multicast allowed in cloud systems.

  25. Dear Arun. Thanks very much for this nice article!

    I have one question about WebSockets related to clustring / replication. We see very nice in your Demo, that the HTTP Session is replicated. Now lets imagine the following: We have a cluster with let’s say 2 wildfly instances A and B. There is also a JavaScript Web Application, which opens a WebSocket; it is connected to wildfly instance A. Now, an event happens, which sould be sent over the WebSocket; but the event is raised on instance B. Now I have a problem: wildfly B does not have the possibility to access to the WebSocket connected to server A. How can I send my event? Is there also a replication mechanism built in for that? Or how can I deal with such situation?

    Thanks in advance for your help!
    – badera

  26. Badera,

    WildFly don’t do per message WebSocket load balancing, the connection to the back end server is 1:1, so all WebSocket messages will go to the same backend server.

    In general web socket apps should be architected to be able to handle a disconnect and reconnect anyway, so if a node falls over then the client should just reconnect.
    Per message load balancing is more a feature of the load balancer than backend server, but even then there are lots of issues (e.g. if you attempt to re-use connections you have no way of tracking which remote client you are actually talking too, and establishing a connection per message is going to suck performance wise).

  27. Dear Arun,
    Where can I search info about how to configure wildfly to do only backup session replication on only one node in a server group ?
    By default, if there are 10 nodes in server group session will be replicated to all of them ?
    I would like it to be replicated to only one backup node, how can I do it ? Where can I find such info ?

    BR

  28. Hi Arun,

    I am looking into running WildFly cluster in Azure. Do you suggest using Docker? If so, should I use VM or service option?

    Thanks for advice,
    Yu

  29. Thanks for the video. When I configure multiples servers on the same machine, the session replication works, but when I connect a slave machine, the replication does not work. I added the “distributed” attribute on the web.xml but still not able to replicate on different machines. Any suggestion?

Leave a Reply

Your email address will not be published. Required fields are marked *