Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

Learn how modern cloud architectures use of microservices has many advantages and enables developers to deliver business software in a CI/CD way.

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.

@GET
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.

Discover how to deploy pre-built sample microservices OR create simple microservices from scratch.

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

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}