March 29, 2016

Containers for Java Microservices

In the recent years there has been a lot of talks about microservices. There is not a clear definitions of what a microservice is and maybe more important how to build one.

But there are some clear characteristics for one:
  • Loosely coupled
  • Doing a small task/single-purpose
  • Clear API and preferably language-agnostic API
  • Etc.
But this microservice need to run in some container/server. You could of course always write everything from scratch, but that would be reinventing the wheel for some common problems like:
  • Pooling
  • Transaction (you want your business code to run in one transaction, e.g. 1. select (does object exists or fetch data), 2. insert, 3. maybe more insert for complex object insert)
  • Operation & Management
  • And maybe you need Security or Asynchronous behaviour
So what are the most popular containers? Two are
You could google comparison between them, but one good is

But how fast are these containers? To really answer this question you should of course performance test them. But a quick test would be to merely compare boot up time on my slow laptop.

Spring Boot. Followed Hello World example

Started Example in 3.959 seconds

Dropwizard. Followed Hello World example

Started @2504ms

JBoss EAP 6.4. Created a simple Hello World example with JAX-RS.

JBoss EAP 6.4.0.GA (AS 7.5.0.Final-redhat-21) started in 3987ms

So dropwizard started really fast, but not amazingly fast compared with JBoss, so the question arise how much better are these alternative container compared with classical Java EE container? And also be aware you are locking your code into a specific framework stack.

No comments: