Vaadin 7 and Tomcat cluster

I set up a testing environment with clustering to test the behaviour of vaddin when a host crashes. It is simply two hosts that shares sessions with Delta manager. The UI has the preserve on refresh annotation. In UI I also set a session atrribute and all works fine while the host the first served the request is still working (sticky session). However, when that host fails, the UI also fails, althought the host that assumes the requests of the crashed one can properly show the attribute set on session after a refresh. Before refresh, the user sees a message of failed synchronization. I am assuming that all UI properties are not beeing stored in HTTPSession, correct? I that the desired behaviour? Is it possible to support clustering with Vaadin as descrided above?

Hi,

everything in the vaadin ui state are indeed in the HTTPSession. For other code (yours) all bets are off and you have to make sure it’s stored in the session also.

Can’t say off the bat what could be wrong in your case, but I’ve seen a few clustering configurations running vaadin apps and those have worked just fine. How does the UI fail? Do you get any exceptions? Can you try your clustering configuration with some simple (non-vaadin) servlet and first confirm that it works with that?

-tepi

I receive a synchronization failure message in notification. Using the same configuration, a non Vaadin application works, also, as I said, an attribute inserted in Vaadin Session can be accessed in the other host when the first one crashes.

Are you using push in your vaadin application? The push connection probably won’t survive a server change. I haven’t actually tried it but I’d think so.

No. It is just the example application created by eclipse with the addition of insertion of new attribute in session. Nothing more.

Alright, so push should be disabled then. I just checked tomcat api and noticed this in the DeltaManager javadoc: “The DeltaManager manages replicated sessions by only replicating the deltas in data.
For applications written to handle this
, the DeltaManager is the optimal way of replicating data.” As far as I know, no specific support has been written into vaadin for this. Can you try StandardManager?

It works! Thank you, Teppo. I wonder if it can work with streaming push, I´will try that.

Great that you got it working!

About push, both the load balancer and possible proxies on the way must support streaming in order for it to function properly. Usually the issue is that some part tries to do some caching which will ofcourse break the streaming communication. I’m not sure which load balancers would support streaming so you’ll need to do some research on that.

-tepi

Hi,

I got the same problem like Andre got and I have added

into my tomcat server.xml file but I am getting the same problem. The notification I am getting is “Internal Error” and the web page freez when a tomcat instance is killed. And I am getting an exception too.


May 18, 2014 9:00:24 PM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
javax.servlet.ServletException: No UIProvider returned a UI for the request.

Can U please help me.

Try with delta manager. It worked with the session delta manager.

Hi Andre,

I have allready useing the Delta Manager for session replication but It didn’t work for me. When I saw this port I change the configureations for Standerd Manager. But that also not working. Is there any special configureations that we need to add for tomcat inorder to implement cluseter environment for Vaadin Apps.

Thanks

My cluster environment is behind an apache httpd configured with mod_jk. You have to set jvmRoute in tomcat server.xml and the worker.properties must have small timout times in order to allow apache a rapid redirection to an alive server. Besides this, nothing special is required.

Hi Andre,

I am using
HAPROXY
as my
load balancer
and I have mentioned my
server.xml
config file in tomcat server. I think everything is ok in that file. Can you tel me is ther any problem with my configrations.
And in my vaadin App I am using HTTP session that is taken using VaadinService.

[b]

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
    <Listener className="org.apache.catalina.core.JasperListener" />
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

    <GlobalNamingResources>  </GlobalNamingResources>

    <Service name="Catalina">

    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost" >
        <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">

            <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
                
                <Manager className="org.apache.catalina.ha.session.DeltaManager"
                    expireSessionsOnShutdown="false"
                    notifyListenersOnReplication="true"/>

                <Channel className="org.apache.catalina.tribes.group.GroupChannel">
                    <Membership className="org.apache.catalina.tribes.membership.McastService"
                                address="228.0.0.6"
                                port="45566"
                                frequency="500"
                                dropTime="3000"/>
                    <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                            address="auto"
                            port="4000"
                            autoBind="100"
                            selectorTimeout="5000"
                            maxThreads="6"/>

                    <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
                        <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
                    </Sender>
                    <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
                    <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
                </Channel>

                <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
                <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" enabled="true" sessionIdAttribute="true"/>
                
                <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
                <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
            </Cluster>


            <Realm className="org.apache.catalina.realm.LockOutRealm">
                
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
            resourceName="UserDatabase"/>
            </Realm>


            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
            prefix="localhost_access_log." suffix=".txt"
            pattern="%h %l %u %t &quot;%r&quot; %s %b %S" />

        </Host>
    </Engine>
</Service>
[/b]

I don’t see anything wrong with your configuration. Mine is different because I don’t use a multicast membership, but that is not probably the problem. I don’t have experience with HAProxy so I cannot help you with this, but you can do some tests the see if the problem is with HAProxy or the tomcat configuration itself. I don’t know your level of experience so this is maybe a silly question, but are you sure that tomcat can keep the session? I mean, have you tried to access your application directly from tomcat and then restart it? Your session is kept? If not, something is wrong with your application and not with the cluster configuration. Maybe some non-serializable data is in the session. If this is not working the cluster won’t either.

Hi Andre,
I have changed by load balancer and now I am using Appache web server and yet I am getting the “Internal error” nottification when a tomcat server is down. But I don’t loose any data in my session. My worker.properties conf:

[b]
#define the worker List
worker.list=tomcatnode1, tomcatnode2, loadbalancer

#define tomcatnode1 worker
worker.tomcatnode1.port=8009
worker.tomcatnode1.host=IP_ADDRESS
worker.tomcatnode1.type=ajp13
worker.tomcatnode1.lbfactor=1
worker.tomcatnode1.socket_keepalive=True
worker.tomcatnode1.socket_timeout=10
worker.tomcatnode1.socket_connect_timeout=10000

#define tomcatnode2 worker
worker.tomcatnode2.port=8009
worker.tomcatnode2.host=IP_ADDRESS
worker.tomcatnode2.type=ajp13
worker.tomcatnode2.lbfactor=1
worker.tomcatnode2.socket_keepalive=True
worker.tomcatnode2.socket_timeout=10
worker.tomcatnode2.socket_connect_timeout=10000

#define loadbalancer worker
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcatnode1,tomcatnode2
worker.loadbalancer.sticky_session=True

Any suggesstions…!!!
[/b]

Try this:

[b]
worker.list=loadbalancer

worker.tomcatnode1.port=8009
worker.tomcatnode1.host=IP_ADDRESS
worker.tomcatnode1.type=ajp13
worker.tomcatnode1.socket_connect_timeout = 1000
worker.tomcatnode1.recover_time = 10

worker.tomcatnode2.port=8010
worker.tomcatnode2.host=IP_ADDRESS
worker.tomcatnode2.type=ajp13
worker.tomcatnode2.socket_connect_timeout = 1000
worker.tomcatnode2.recover_time = 10

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=tomcatnode1,tomcatnode2
worker.loadbalancer.method=s
[/b]

Hi Andre,

I have checked with your worker property config file but it didn’t worked for me. Here is my mod_jk config file:

[b]
#Load mod_jk module
LoadModule jk_module modules/mod_jk.so

Where to find workers.properties

JkWorkersFile conf/workers.properties

Where to put jk logs

JkLogFile logs/mod_jk.log

Set the jk log level [debug/error/info]

JkLogLevel info
#send requests for worker loadbalancer
JkMount /examples/* loadbalancer
JkMount /* loadbalancer
[/b]

And I am using vaadin
7.0.4, Java 1.6,Tomcat 7.0.42
versions and I am getting this exception after one of my tomcat instance is down.


May 18, 2014 9:00:24 PM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
javax.servlet.ServletException: No UIProvider returned a UI for the request.

I have attached my test application and it’s a maven project. If you can can you check whether is it working in you environment.
14025.zip (14.3 KB)

Can´t you try with a more recent version of Vaadin?

I have tried with vaadin 7.1.0 and java 1.6. What are the versions that you are using for vaadin, tomcat and java?

Vaadin 7.2, Java 1.7 and Tomcat 7.0.53. My server.xml contains what follows:





















Do not forget to set jvmRoute in your connector.