Choosing a REST Framework for Microservices

DZone 's Guide to

Choosing a REST Framework for Microservices

Let's compare the performance of several RESTful frameworks for microservices.

· Microservices Zone ·
Free Resource

Every industry undergoes changes, and changes are inevitable. To adapt to the change and deliver, we need the right tool, so we have to look at the performance of existing tools on the market or in the open-source domain in software industries. Performance is particularly measured in terms of time, i.e., for a particular number of requests, how much time the system takes to respond.

Let's compare a few open-source RESTful frameworks' response times for a number of requests. Jersey and Resteasy have been chosen for server-side RESTful services. Standalone services like Spring Boot, Javalin, and Spark Java have also been chosen. Jersey, OkHTTP, and Unirest have been chosen for client-side services. 

Here, very simple code is used, which includes the java.home value, a normal Java String message, the current time, and the type of service (Jersey, Resteasy, etc), which is also a Java String. The "java.home" value gives an idea of which JDK is in use. Here, I have used JDK 8.

public String getData() {
  JSONObject data = new JSONObject();
  data.put("javaHome", System.getProperty("java.home"));
  data.put("data", "Hello World!");
  data.put("time", LocalTime.now());
  data.put("serviceProvider", "Resteasy");
  return data.toString();

Each RESTful service is being called 1,000 times in a loop, by three different RESTful clients in sequence, and the results are being displayed in the bar charts. The charts show the time taken in terms of microseconds for different servers and client services. 

Image title

Image title

Image title

Three figures are shown to build a perspective on how framework performance varies at different times. The above diagrams also show a few ideas about the performance of the REST framework on the server side and client side. It shows that Frameworks built upon Jetty Server are doing better as compared to others. Client frameworks like OkHTTP and Unirest are similar in terms of performance.

In spite of the above results, each framework has its own advantages and disadvantages. The standalone REST frameworks like Spark, Javalin and Helidon are easy to implement and are not confined to any technology stack, like Spring Boot. Jersey and Resteasy have the advantages of customization. I have not explored all the features of each framework, so it's an open debate. 

Here is the GitHub link for reference.

java, javalin, jersey, microservices, performance, rest, resteasy, spark java, spring boot

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}