Configuring couchbase in tomcat context.xml

We are trying to implement session management using couchbase in tomcat context.xml.

we have configured two couchbase instances in tomcat context.xml
We are facing issues when one couchbase instance fails.
when first couchbase instance goes down the entire session is losed and not redirecting to the second couchbase instance. The application is still pointing to the first membase instance.

Please find below configuration used.

The Application/tomcat should automatically point to the second active couchbase instance if any of them goes down.
Please advise if we have missed out any thing in the configuration.

First, let me start by stating that you are using memcached session manager, which is not developed nor supported by Couchbase…

I’ve tried to look a bit at the code, and it looks to me like the project takes Couchbase nodes into account (when the memcachedNodes parameter contains entries that start with http) but in this case relies on the bucket being a couchbase bucket, that is in a cluster and replicated). So basically it relies on the Couchbase cluster being administered and configured for fault-tolerance.

The project was apparently originally built to communicate with memcached instances. Since such caches have no notion of a cluster, it would maintain a connection to several instances and choose one server as the main and the other as the backup.

You may want to confirm all that with the project’s author, but I think that to use it with Couchbase, you have to use buckets of the couchbase type and administer the cluster yourself (ie. setup replication, monitor the cluster for failure, do failover and rebalance, etc…).

Note that the buckets are a mean of storing a backup of the sessions, which will always be primarily worked on from RAM:

If a tomcat dies all other tomcats will take over the work of the lazy/dead one and fetch the sessions from the appropriate memcached node(s) and serve this session from thereon.

Any body can moxi memcached proxy used for handling failover nodes.
help is appreciated

If you use the default bucket (required, since the plugin you’re using doesn’t know about authentication), you should just be able to use each cluster node at port 11211, since moxi runs on the server side there. any application that uses memcached should be able to use this without changes.

Thanks. It works fine with default bucket.

Hi All

We are using Spring webflow Project and couchbase(In Memory DB) for managing session’s. The Applicaton is configured in two tomcat instances in a cluster using apache loadbalancer

We are getting below exception in between flows.

org.springframework.webflow.execution.repository.NoSuchFlowExecutionException: No flow execution could be
found with key ‘e1s4’ – perhaps this executing flow has ended or expired? This could happen if your use
rs are relying on browser history (typically via the back button) that references ended flows.
at org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository.getCo
nversation(AbstractFlowExecutionRepository.java:178)

There is no issue when there is only one tomcat instance in the cluster (Apache loadbalancer). on seeing the logs we have noticed that new sessionid is being created in between flows for a same user.

Please find the configuration used

 <   
Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11311"	
memcachedProtocol="binary"
sticky="true"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" 
transcoderFactoryClass="de.javakaffee.web.msm.JavaSerializationTranscoderFactory"
/>

Any one could please help on this.

@raju_ayyappan I’m afraid we won’t be able to provide guidance on the issue reported, since none of the code you are using is tied to couchbase in any way - couchbase just does the “memcached” store on the backend. I’d recommend you to point your question towards a spring-focussed audience -> http://spring.io/questions

I have created a couchbase cluster and have configured two memcached nodes (n1:192.168.91.75:11211, n2:192.168.91.71:11211) if the first node goes down will tomcat able to continue with session’s from the second node (n2:192.168.91.71:11211) automatically with out tomcat restart?. As of now tomcat is not able to continue with the sessions and . Any one can help on this!!

Please find the configuration used

please find the error logs
.ch.SelectionKeyImpl@795b05ca
2015-12-20 08:28:05.981 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to failure to conne
ct to {QA sa=/192.168.91.75:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interest
ed=0}
java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:642)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:419)
at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:1403)

We tried using couchbase bucket and now failover/replication is working fine. But I under stand that the documents in couchbase are distributed among the nodes. for example if there are 4 nodes then the document will be splited 25% in each of the nodes. During a node failover we could see that application takes around >60 seconds to get the document from the failed node(i undersood since rebalancing is happening for recovering the data from failed over nodes to the other node). Since our use case is session data which is very critical the user cannot do any operations during rebalance.

It would be greatful if we can get the session data from the replica node quickly if a node goes down. Also does couchbase provide any pugin for handling tomcat sessions. right now we are using third party plugin for managing sessions as below