8 Replies Latest reply on Oct 19, 2017 10:26 AM by wwang2016

    wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working

    mofou2

      Hello,

       

      I have set wildfly 10 as domain mode with:

       

      - 1xVM with Domain Controller (domain.xml and hsot-master.xml) and apache 2.4 + mod_cluster 1.3.1

      - 1xVM with Host Controller (host1.xml) and two server instances (server-one and server-two)

       

       

      proxy_cluster.conf

       

      LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so

      LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

      LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so

      LoadModule advertise_module /usr/lib/apache2/modules/mod_advertise.so

      LoadModule manager_module /usr/lib/apache2/modules/mod_manager.so

      LoadModule proxy_cluster_module /usr/lib/apache2/modules/mod_proxy_cluster.so

      LoadModule cluster_slotmem_module /usr/lib/apache2/modules/mod_cluster_slotmem.so

       

      <IfModule manager_module>

         PersistSlots On

         AllowDisplay On

         MemManagerFile /var/log/apache2/mod_cluster

       

         Listen 192.168.31.215:6666

         <VirtualHost 192.168.31.215:6666>

           <Directory />

              Require all granted

           </Directory>

           ServerAdvertise Off

           EnableMCPMReceive

          </VirtualHost>

       

      <VirtualHost *:80>

             ServerAdmin webmaster@localhost

       

            <Location /mcm>

               SetHandler mod_cluster-manager

               Require all granted

            </Location>

             CreateBalancers 1

             ProxyPass / balancer://sgpool stickysession=JSESSIONID|jsessionid nofailover=On

             ProxyPassReverse / balancer://sgpool

             ProxyPreserveHost On

       

              ErrorLog ${APACHE_LOG_DIR}/error.log

              CustomLog ${APACHE_LOG_DIR}/access.log combined

      </VirtualHost>

       

      </IfModule>

       

      domain.xml

       

              <subsystem xmlns="urn:jboss:domain:modcluster:2.0">
                  <mod-cluster-config advertise-socket="modcluster" proxies="proxy" balancer="sgpool" advertise="false" sticky-session-force="true" connector="ajp">
                      <dynamic-load-provider>
                          <load-metric type="cpu"/>
                      </dynamic-load-provider>
                  </mod-cluster-config>
              </subsystem>

      .....

       

      Because requests are balanced if I set the sticky session?

       

      Thanks

        • 1. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
          rhusar

          What do you need the proxy pass setting for? Moreover looking at your settings that does not seem like desired configuration.

          nofailoverOffIf set to On, the session will break if the worker is in error state or disabled. Set this value to On if backend servers do not support session replication.

          Also, you probably don't need sticky-session-force="true".

           

          Another thing, you don't  want to expose mod_cluster-manager on :80.

           

          Since you are using static proxy configuration, do you have the proxy setting configured? Is the server showing up in the mod_cluster management console (/mcm)?

           

          How do you test that sticky sessions do not work? You need to have a session created for it to stick.

          • 2. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
            mofou2

            Hello,

             

            I have set wildfly 10 as domain mode with:

             

            - 1xVM with Domain Controller (domain.xml and hsot-master.xml) and apache 2.4 + mod_cluster 1.3.1

            - 1xVM with Host Controller (host1.xml) and two server instances (server-one and server-two)

             

            I have done the following changes:

             

            apache 2.4.2

             

            <IfModule manager_module>

               PersistSlots On

               AllowDisplay On

               MemManagerFile /var/log/apache2/mod_cluster

             

               Listen 192.168.1.215:6666

             

               <VirtualHost 192.168.1.215:6666>

                 <Directory />

                    Require all granted

                 </Directory>

                 ServerAdvertise Off

                 EnableMCPMReceive

                 <Location /mcm>

                    SetHandler mod_cluster-manager

                    Require all granted

                 </Location>

                # Possible values include: debug, info, notice, warn, error, crit,

                # alert, emerg.

                LogLevel debug

                ErrorLog ${APACHE_LOG_DIR}/mod_cluster/error.log

                CustomLog ${APACHE_LOG_DIR}/mod_cluster/access.log combined

                </VirtualHost>

            </IfModule>

             

            <VirtualHost *:80>

                   ServerAdmin webmaster@localhost

             

                   CreateBalancers 1

                   ProxyPass / balancer://sgpool/ stickysession=JSESSIONID|jsessionid nofailover=On

                   ProxyPassReverse / balancer://sgpool/

                   ProxyPreserveHost On

             

                   LogLevel notice proxy:debug

             

                   ErrorLog ${APACHE_LOG_DIR}/error.log

                   CustomLog ${APACHE_LOG_DIR}/access.log combined

            </VirtualHost>

             

            wildfly 10 (domain.xml)

             

                    <subsystem xmlns="urn:jboss:domain:modcluster:2.0">
                        <mod-cluster-config advertise-socket="modcluster" proxies="proxy" balancer="sgpool" advertise="false" sticky-session-force="false" connector="ajp">
                            <dynamic-load-provider>
                                <load-metric type="cpu"/>
                            </dynamic-load-provider>
                        </mod-cluster-config>
                    </subsystem>

             

            .....

               <socket-binding-group name="ha-sockets" default-interface="public">
                    <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
                    <socket-binding name="http" port="${jboss.http.port:8080}"/>
                    <socket-binding name="https" port="${jboss.https.port:8443}"/>
                    <socket-binding name="jgroups-mping" interface="private" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
                    <socket-binding name="jgroups-tcp" interface="private" port="7600"/>
                    <socket-binding name="jgroups-tcp-fd" interface="private" port="57600"/>
                    <socket-binding name="jgroups-udp" interface="private" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
                    <socket-binding name="jgroups-udp-fd" interface="private" port="54200"/>
                    <socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
                    <socket-binding name="txn-recovery-environment" port="4712"/>
                    <socket-binding name="txn-status-manager" port="4713"/>
                    <outbound-socket-binding name="mail-smtp">
                        <remote-destination host="localhost" port="25"/>
                    </outbound-socket-binding>
                    <outbound-socket-binding name="proxy">
                        <remote-destination host="192.168.1.215" port="10001"/>
                    </outbound-socket-binding>
                </socket-binding-group>

             

             

            ...........

             

                <server-groups>

                    <server-group name="sgroup1" profile="custom-ha">

                        <jvm name="default">

                            <heap size="64m" max-size="512m"/>

                        </jvm>

                        <socket-binding-group ref="ha-sockets"/>

                        <deployments>

                            <deployment name="balancing-test.war" runtime-name="balancing-test.war"/>

                            <deployment name="sample.war" runtime-name="sample.war"/>

                        </deployments>

                    </server-group>

             

            Captura de pantalla de 2016-04-27 12:50:11.png

            i haven't session replication and i want sticky session


            when using the URL http://192.168.1.215/balancing-test/ from the same source it does not always go to the same instance of wildfly but varies between one and server-server-two


            Please, help

            • 3. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
              rhusar

              What does the balancing-test servlet look like?


              Do the headers show correct session id and route? curl --head http://127.0.0.1/

              • 4. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
                mofou2

                balancing-test is a example of Wildfly book

                 

                Captura de pantalla de 2016-04-27 14:13:12.png

                curl --head http://192.168.1.215/balancing-test/

                HTTP/1.1 200 OK

                Date: Wed, 27 Apr 2016 13:15:16 GMT

                Server: Apache

                X-Powered-By: JSP/2.3

                Set-Cookie: JSESSIONID=mlf0rczV3Z-iAxUO-z4k6cTD_TEjKVOLNzC8WJx0; path=/balancing-test

                Content-Type: text/html;charset=ISO-8859-1

                Content-Length: 152

                 

                curl --head http://192.168.1.215/balancing-test/

                HTTP/1.1 200 OK

                Date: Wed, 27 Apr 2016 13:15:19 GMT

                Server: Apache

                X-Powered-By: JSP/2.3

                Set-Cookie: JSESSIONID=HoDnWr9knnUvXTvC46G6LMiL2Aqnibo9bMkkMU8g; path=/balancing-test

                Content-Type: text/html;charset=ISO-8859-1

                Content-Length: 152

                 

                curl --head http://192.168.1.215/balancing-test/

                HTTP/1.1 200 OK

                Date: Wed, 27 Apr 2016 13:15:21 GMT

                Server: Apache

                X-Powered-By: JSP/2.3

                Set-Cookie: JSESSIONID=6tfD5ejNP06JLqY22QzzNacEOPrvIG_eRG47F-Dr; path=/balancing-test

                Content-Type: text/html;charset=ISO-8859-1

                Content-Length: 152

                 

                Wildfly fixed a JsessionID for each request instead of maintaining the same

                • 5. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
                  adityan

                  Hello Luis, I am similar issue on JBoss EAP 7. I am using mod_cluster 1.3.1 to set up load balancing cluster. I have used standalone-ha.xml instead of domain.xml.

                  Please refer to my question:

                  Load Balancing Cluster not working with Apache HTTP Server 2.4.6 and JBoss EAP 7

                   

                  Let me know if you have fixed this issue for Wildfly 10 and the solution for the same.

                  • 6. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
                    wwang2016

                    Hi,

                     

                    I have a similar problem with the domain mode cluster in that the two instances that showed up show the port number of 8009 + port offset

                     

                    I think this is incorrect, and it should be 8080 + port offset.

                     

                    But I have not found a way to make it to work

                     

                    Regards,

                     

                    Wayne

                    • 7. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
                      wwang2016

                      Hi All,

                       

                      I take it back.

                       

                      The mod cluster page should show the 8009 + port offset although the http port offset should be 8080 + port offset

                       

                      Thanks,

                      Wayne

                      • 8. Re: wildfly 10 (domain mode) + apache 2.4 + mod_cluster 1.3.1 sticky session not working
                        wwang2016

                        Hi All,

                         

                        I am using the default configuration of modcluster, and I got sticky session.

                         

                        My mod-cluster is v1.2.6.Final, and it is set up in a distinct virtual machine than the domain controller and host controller machines. I did not need to change any configuration of mod-cluster to work with cluster of either standalone servers or cluster of  servers running in domain mode

                         

                        All my previous tests on cluster related concerns were on a cluster of standalone servers. I will test these concerns with cluster of servers running in domain mode.

                         

                        Regards,

                         

                        Wayne