memcached on solaris 10 for Roller4

Posted by Dick on August 08, 2008

I have a 2-node Glassfishv2 cluster running Roller 4 on Solaris 10
and discovered (the hard way) that memcached is the only safe caching option .

If you’re trying to run Roller on a Glassfish cluster, do yourself a favour and skim over
this checklist. You’ll thank me later, honest.

install memcached

(If you’re running Solaris Express or OpenSolaris, you can skip this bit.)

It’s part of Coolstack now (ignore the page banners, it’s for Solaris Intel as well).
They have a boatload of other things too
(Squid, Ruby, lighttpd and – ooh! – nginx), but I’m trying to stay focussed here.

I pkgadded CSKmemcached_1.3RC1_i386.pkg.bz2 on both nodes.
Bizarrely, the package didn’t include SMF bits, so I tweaked the ones from SXCE.
Help yourself:

curl -O http://files.hellooperator.net/solaris/smf/memcached
cp memcached /lib/svc/method
chmod +x memcached
curl -O http://files.hellooperator.net/solaris/smf/memcached.xml
cp memcached.xml /var/svc/manifest/application/database
svccfg import /var/svc/manifest/application/database/memcached.xml

tweak and enable memcached

I’m giving it 1 Gb of RAM for starters, tweak the “setprop” line below if you want to change it.

bash-3.00# svccfg -s memcached
svc:/application/database/memcached> setprop memcached/options=("-u" "nobody" "-m" "1024")
svc:/application/database/memcached> quit
bash-3.00# svcadm refresh memcached
bash-3.00# svcadm enable memcached

hook up Roller

First, add the roller memcached plugin to your WARfile:

wget https://roller.dev.java.net/files/documents/190/88023/roller-memcached-4.0.tar.gz
gzip -dc roller-memcached-4.0.tar.gz | tar xf -
cp roller-memcached/* $ROLLER_DIR/WEB-INF/lib

Then add this to $ROLLER_DIR/WEB-INF/class/roller-custom.properties


# Rollers caches aren't cluster safe, so use memcache instead
cache.defaultFactory=net.java.roller.tools.cache.memcached.MemcachedLRUCacheFactoryImpl
# any whitespace in this line will waste your afternoon
cache.memcached.default.servers=clusternode1:11211,clusternode2:11211
#debugging
log4j.category.net.java.roller.tools.cache.memcached=DEBUG

The other howtos I’ve seen all specify MemcachedLRUCacheFactory, which gave me ClassNotFoundExceptions (probably because it doesn’t exist?) -
the one above works fine.

Then rebuild your WARfile and redeploy.

Requests/sec has shot up from about 25/sec to over 350/sec, and it can stand a much higher concurrency level now (if you need a quick benchmarking tool, Siege builds well on OSX).
I trashed the webapp and rebuilt it yesterday (swapped out our awful DB2 backend for a proper database) and needed to svcadm restart memcached, but other than that it’s fire-n-forget.

 

(Credits : Dave Johnson is the Roller God, Trond Norbye wrote the SXCE SMF bits)

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. anjan bacchu Sat, 09 Aug 2008 20:32:59 GMT

    hi there,

    thanks for writing this up.

    How does Roller use Memcache ? Is this component modular ? Can other software use this easily ? Does Roller have a Terracotta/ehCache plugin, with similar functionality as memcache’s ?

    thank you,

    BR,
    ~A

  2. Dick Sat, 09 Aug 2008 21:50:43 GMT

    Hi Anjan

    Roller does page-level caching out of the box - i.e. it stores the content it sends to clients n a directory and serves those static files until they become invalid (when a comment or post arrives).
    This model works well for things like blogs where most of the pages aren’t session specific, and content is read much more often than its updated.

    The roller memcached plugin is a drop-in replacement for the file cache.

    Memcache is essentially just a distributed hash, which turns out to be very versatile, extremely simple (there are 2 operations in the API, get() and put()), and insanely fast.

    More importantly it’s language agnostic, you can use the same bunch of memcacheds to cache Rails apps, for example.

    Have a look at the memcached page for more information (top of post).

  3. anjan bacchu Sun, 10 Aug 2008 00:45:49 GMT

    hi dick,

    thanks for the response.

    memcached : I understood how’s it is used.

    Sorry, I was not being clear. My question was about the memcache plugin in Roller. I was asking along the lines of the possibility of the existence of a plugin for Terracotta/ehCache to do the same thing.

    2nd question : if such a plugin for Terracotta/ehcache existed, then, how modular is it ? What would it take to make any other content management system use it to work with
    1) ehcache/Terracotta
    2) memcached

    thank you,

    BR,
    ~A

  4. Dick Sun, 10 Aug 2008 09:47:42 GMT

    Oh, right :)

    I’ve no experience with TerraCotta or ehCache (heard good things about both but haven’t got round to looking at them yet). memcached is the only cache plugin I’ve seen for Roller.

    It could probably be tweaked to talk to whatever you like, so long as there’s a get/put/delete operation to map to. It’s all open source, take a look :)

  5. Confluence: Eric Mickelson Wed, 01 Oct 2008 17:47:10 GMT

    Installing memcached…

    Installation Instructions…

Comments