Couchbase StateManager for XPages, Part 1

Wed Jan 29 15:08:55 EST 2014

  1. Couchbase StateManager for XPages, Part 1
  2. Couchbase StateManager for XPages, Part 2

The other day, I attended Tony McGuckin's Connect session on XPages scalability (a companion to his earlier Masterclass on performance) and I was inspired to try out a thought I had: could it work to use Couchbase to further push the bounds of XPages scalability?

If you're not familiar with Couchbase, it's a product similar to CouchDB, which is in turn essentially Domino-the-DB-server re-done for modern needs. Last summer, I wrote some data sources to use Couchbase data in an XPages app in much the same way that you use Domino documents and views.

In addition to Couchbase's nature as a document database, it has another layer from its lineage as a continuation of Membase: its basis is a key-value store, suitable for caching or storing data in a very fast and scalable way. This capability is potentially a perfect match for the needs of XPages state holding: when an XPage is stored in between requests, it's really just taking a Java object and storing it by key either in memory or on disk. By taking Couchbase's key-value capability and using it for this, you end up with something that may (pending testing) really crank up the scalability.

So I wrote a class to do it, and so far, so good: it stores and retrieves the XPages properly and even automatically obeys session timeout to clean up unneeded entries. When I get home, I plan to convert it into a plugin, but for now I've uploaded the Java file:

CouchbaseStateManager.java

To use it, install the Couchbase Java Client (I dropped it in jvm/lib/ext, since adding them as Jars in the NSF was trouble), copy that class into your NSF in the "frostillicus" package, and modify your faces-config.xml and xsp.properties files similar to:

faces-config.xml

<faces-config>
  <application>
    <state-manager>frostillicus.CouchbaseStateManager</state-manager>
  </application>
  ...
</faces-config>

xsp.properties

frostillicus.couchbase.statemanager.uris=http://10.211.55.2:8091/pools
frostillicus.couchbase.statemanager.bucket=default
frostillicus.couchbase.statemanager.username=
frostillicus.couchbase.statemanager.password=

Once you have it up and running, you'll start seeing serialized views being stored in your Couchbase bucket (which is basically like an NSF) keyed by replica ID and the unique XSP view ID:

I'm looking forward to trying this out in a real setup, where I have the XPage running on one server and pointed at a cluster of multiple Couchbase servers elsewhere. This should really play to the strengths of both: it would use JSF's capabilities to take a little work off of the plate of the XPage server while letting Couchbase do its job of spreading the data across its cluster, caching in memory, and so forth. Barring unfixable performance pitfalls, this could push XPages performance and scalability even further.

Commenter Photo

ps - Wed Jan 29 20:45:23 EST 2014

Just awesome. looking forward to reading more.

Commenter Photo

Matt Ingenthron - Wed Jan 29 22:05:30 EST 2014

Very cool.  I wasn't aware of XPages before but glad to see the Couchbase Java Client is working out well here.  Let us know if you have any ideas on how we can make it easier to integrate!

Commenter Photo

Michael - Thu Jan 30 00:20:42 EST 2014

Keep this good stuff coming!

One thing I noticed is that your class doesn't seem to be thread safe (at least the getClient()) part. Would this be needed in your environment? And if so, I can certainly help you out to make it safe.

Good work!

Cheers,

Michael

Commenter Photo

Sam Bridegroom - Sat Feb 01 11:24:22 EST 2014

Very cool stuff (as usual).

New Comment