Java EE Microservices Platforms & High Performance Java EE with JCache– jDays 2016

Photo of Steve Millidge by Steve Millidge

Recently I attended as a speaker at my second jDays, a great conference in a great venue in Gothenburg. jDays is a fantastic conference as it is small enough to easily meet people and network and discuss tech, while at the same time big enough to run multiple tracks so there is always a session on that you’ll be interested in. 

 

 

I did two talks at jDays. The first was a talk I have ran before about JCache and Java EE, the slides for the talk are on Slideshare and the code is available on GitHub. And the video is also available:

 

 

 

The second talk I inherited from a colleague of mine, who was unable to attend, entitled “Java EE Microservices Platforms, which is best”. Now given the title I thought the obvious answer was Payara Micro :) , so this left me with a dilemma, how to do a comparison session, that would be educational for the audience but unbiased, so I decided to let the code do the talking and implement the same microservice on three different platforms and walk the audience through the code so they could compare and contrast. The three platforms I chose were WildFly Swarm, Payara Micro and Spring Boot.

 

I chose to build a micro-service using real world data. Fortunately, in the UK the Government provides a number of Open Data resources I could use to build my microservice. I therefore chose a dataset that would be of profound interest to a conference in Sweden, I chose the UK’s planned roadworks database!

 

 

jdays_microservices.png

 

The architecture of my microservice was simple. First I wrote a Servlet to ingest the XML file from the Highways Agency into a MySQL database using JAXB and JPA. Then I wrote a RESTful service to query the data by road and region. This was implemented in Java EE for Payara Micro and WildFly Swarm and Spring for Spring Boot. You can get the code on GitHub. Now to be fair I am no expert in WildFly Swarm or SpringBoot so don’t criticise the code too much! I was pleasantly surprised at how fast I could pick up developing the Spring Boot service even though I’m a novice with Spring, I’m sure an experienced Spring developer can happily rip apart my Spring code. In a similar vein, I’m sure a WildFly Swarm expert can reduce my jar size. For the JavaEE microservice there were no code changes required to move between WildFly Swarm and Payara Micro, even the datasource definition in the web.xml ported across without change. 

 

Once I had created the code I then set out to measure the file size, memory footprint and boot times of the various microservice jars created. The results of which are below.

 

 

  Payara Micro WildFly Swarm Spring Boot
File Size    60MB +
   1MB war
   100 MB    26 MB
Boot Time    4s    4s    4s
Used JVM Heap
(after full GC)

   34MB

   Metaspace 63MB  

   35MB

   Metaspace 83MB  

   44MB

   Metaspace 51MB  

 

Conclusions

You can draw your own conclusions from the source code and the table above about which platform you prefer. The standout conclusion for me is that all the platforms are lightweight, small footprint and fast. 

Now I’m never going to convince a Spring developer to move to JavaEE however a developer who loves JavaEE can quite happily build microservices using the JavaEE apis and deploy with WildFly Swarm or Payara Micro. Stick with what you are familiar and most productive with.

 

Feel free to use my code as an example microservice and if you want to improve it just raise a pull request.

 

 

 

 

 

Related Posts

Comments