Tuesday, April 16, 2013

Adventure Time! Apache Karaf on Raspberry Pi

I usually work with Apache Karaf on very large systems (dozens of CPU cores, hundreds of Gigabytes of memory, blazingly fast IO subsystems), this project however I've had the pleasure of getting to play with a Raspberry Pi - a small, inexpensive computer which at its heart runs a 700 MHz Low Power ARM1176JZ-F Applications ProcessorCPU with 512MB ram.

Before I dive into the specifics of getting Apache Karaf to run on the Raspberry Pi, lets spend a little bit of time reviewing the base system:

Out of the Box


I ordered from Newark / Element 14 their Raspberry Pi Model B developers kit. Their kit shipped promptly, arriving with the Raspberry Pi Model B system board, miniature USB keyboard, USB mouse, USB powered HUB, AC/DC converter with mini-usb connector, a plastic enclosure, and a 4GB SD card containing a pre-installed copy of Raspbian (a Debian Linux distribution specifically for the Raspberry Pi). The only component I'd have to supply myself was a monitor that supported HMDI or an RCA connection, luckily I have a small LCD TV on hand with the HMDI port.

Assembling the kit took less than 5 minutes. The powered USB HUB wasn't strictly required for this build as the Raspberry has 2 USB ports built in - it is nice however to have the extra ports available to accept other devices such as memory sticks.

  With the miniature computer connected to my TV set I plugged in an ethernet cable, and the unit's power - a few seconds later the configuration screen appeared.

For my project I accepted the default configuration options, enabling the built in SSHD service so that I may operate the machine remotely from my Macbook.

Setting up my environment


To be able to start my Apache Karaf experiments I would have to collect three tools:

  1. A JDK for Raspbian "wheezy" (this version of the OS supports hard floating point - so the regular arm JDK6 and 7 builds won't work).
  2. The latest Apacbe Maven 3.0.x release.
  3. A Subversion client, so I could checkout the latest version of the Karaf 2.3.x code base.

Quickly setting up my environment, I set the machine to compile the Karaf 2.3.1 kit from tags... about an hour later (not bad considering the m2 repo population required) the kit was produced and ready to go!

There was a small hitch in getting the kit to start though. The JVM option "server" was not supported on the JDK 1.8.0-ea kit for ARM. A quick edit of the default java options in the bin/karaf start script to remove that flag resolved the immediate issue.

Issuing commands on Karaf's console worked as I'd expect them too albeit with some delay on more complex commands which is perfectly acceptable given the computer's specs.

AMQ Persistent Messaging - the only disk benchmark that matters ;)


For fun I downloaded Apache ActiveMQ 5.8.0 in order to run it's bundled KahaDB Disk Benchmark utility. The utility's purpose is to provide a guideline on the I/O subsystem performance of the host computer - the sync write statistic being of the most interest under normal operations given their role in persistent messaging. The score of the Raspberry Pi was quite favorable when compared to the Vostro 2420 I review several months ago in regards to sync writes. In all other scores however the stock SD card wasn't nearly as performant.

Returning to Apache Karaf on Raspberry Pi, I'm just starting to really dig into what improvements, bug fixes, and other concerns users would have trying to use the container on this platform. A sensible JVM tuning will not be practical until Java 1.8.0 is in full release, that said setting JVM min and max memory to fit within the Pi's envelope is a given (64 MB of the 512 MB ram is allocated to the frame buffer, leaving little for the OS and JVM). I look forward to other optimizations such as tweaking  garbage collection, perm gen, and stack setting.

This is going to be a fun on going project, be sure to drop back to my blog for updates.

2 comments:

Unknown said...

Nice blog with a pretty good description on what to do when you want to run Karaf on an RPI.
Just one more question, did you manage to cross compile the service wrapper for ARM? I recently got stuck on that topic.

Many greets and kind regards,

- Christoph

Richard said...

You, my good man, are at the bleeding edge :)