A lightweight Java application server on Raspberry Pi

February 18, 2014 | 3 min Read

Raspberry Pi is a trademark of the Raspberry Pi Foundation

As of recently, Oracle is providing a JVM for Raspberry Pi that performs well enough to use the Pi as an application server.

Raspberry Pi and Java haven’t been a great couple in the past, but with the new JVM that added native floating point operations this is history. If you are interested, here are some numbers that prove the performance improvements.

I am using Virgo Nano as my server of choice because it is lightweight and allows me to deploy bundles. Getting started is simple: the Oracle JVM is part of the standard Raspbian distribution and Virgo just needs to be downloaded and unzipped.

Getting started

First you need to get yourself a Pi and a SD card. Continue with the NOOBS installation from the raspberrypi.org/downloads page. The Raspbian image worked just fine for me.

wget https://download.eclipse.org/virgo/release/VP/3.6.2.RELEASE/virgo-nano-3.6.2.RELEASE.zip

Unzip and run the bin/startup.sh script.

Performance

The first startup may take a couple of seconds longer, because an initial provisioning is being performed. For subsequent starts, the startup time is between 20 and 30 seconds. Not great, but usually you start the server only once in a while.

[2014-02-18 07:48:43.094] startup-tracker Kernel starting. [2014-02-18 07:48:44.565] startup-tracker Kernel started. [2014-02-18 07:48:46.701] startup-readiness Virgo ready. Started for 24.520s.

Comparing this to the under 2 second startup on my 1.7 GHz Intel Core i7 processor, you may think that the Pi not quite up to the task. Things lighten up when you start using a deployed application. The simplest thing to start with is the built in admin console of Virgo.

https://yourPiIpAddress:8080/admin

Load time of the admin console overview page served by Raspberry Pi: 1.99 seconds.

Load time of the admin console overview page served by i7: 1.73 seconds.

The difference for serving this mostly static content is minimal. What I am most interested in is using the Pi as a server for mobile apps based on our Tabris framework, because this can allow you to use the Pi as a controller for various things with a state of the art mobile UI. So here come the performance numbers for the Tabris UI demo.

top - 10:16:30 up 2:33, 2 users, load average: 1.14, 1.29, 0.72
Tasks: 66 total, 1 running, 65 sleeping, 0 stopped, 0 zombie
%Cpu(s): 68.3us, 3.3sy, 0.0ni, 26.8id, 0.0wa, 0.0hi, 1.6si
KiB Mem:  448180 total, 182100 used, 266080 free, 10224 buffers
KiB Swap: 102396 total,      0 used, 102396 free, 71076 cached

PID  USER VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
2526 pi   1102m  80m 7908 S  69.0 18.4   8:32.39 java
2689 pi    4692 1420 1024 R   1.3  0.3   0:00.33 top  

Response times for a sample of 5 highly interactive concurrent users show that the Pi can be a reasonable Java application server in a home or even small business environment. While being pretty busy serving 6 requests per second, the average response time of 371 milliseconds qualifies the Pi for a number of interesting tasks. Stay tuned.