Microservices Introduction

A microservice is a small, loosely coupled distributed service. Microservice Architectures evolved as a solution to the scalability and innovation challenges with Monolith architectures (Monolith applications are typically huge – more 100, 000 line of code). It allows you to take a large application and decompose or break into easily manageable small components with narrowly defined responsibilities.

Reasons for using Microservice:
In monolith application, there are few challenges:

  1. For a large application, it is difficult to understand the complexity and make code changes fast and correctly, sometimes it becomes hard to manage the code.
  2. Applications need extensive manual testing to ensure the impact of changes.
  3. For small change, the whole application needs to be built and deployed.
  4. The heavy application slows down start-up time.

Benefits of Microservices:

  1. Small Modules –
    Application is broken into smaller modules which are easy for developers to code and maintain.
  2. Easier Process Adaption –
    By using microservices, new Technology & Process Adaption becomes easier. You can try new technologies with the newer microservices that we use.
  3. Independent scaling –
    Each microservice can scale independently via X-axis scaling (cloning with more CPU or memory) and Z-axis scaling (sharding), based upon their needs.
  4. Unaffected –
    Large applications remain largely unaffected by the failure of a single module.
  5. DURS –
    Each service can be independently DURS (deployed, updated, replaced, and scaled).

Restrictions of Microservices:

  1. Configuration Management –
    As it becomes granular the headache comes for configuring the services and monitoring those. You need to maintain configurations for hundreds of components across environments.
  2. Debugging –
    Tracking down the service failure is painstaking job. You might need to look into multiple services across different components. Centralized Logging and Dashboards are essential to make it easy to debug problems.
  3. Automation – Because there are a number of smaller components instead of a monolith, you need to automate everything – Builds, Deployment, Monitoring etc.
  4. Testing –
    Needs a greater effort for end to end testing as it needs all the dependent services to be up and running.

Microservice Frameworks for Java:
There are several microservices frameworks that you can use for developing for Java. Some of these are:

  1. Spring Boot –
    This is probably the best Java microservices framework that works on top of languages for Inversion of Control, Aspect Oriented Programming, and others.
  2. Dropwizard –
    Dropwizard pulls together stable, mature libraries from the Java ecosystem into a simple, light-weight package that lets you focus on getting things done.
  3. Restlet –
    Restlet Framework helps Java developers build better web APIs that follow the REST architecture style.
  4. Spark –
    A micro-framework for creating web applications in Kotlin and Java 8 with minimal effort.

Others that you can consider include: Ninja Web Framework, Play Framework, RestExpress and Restx Framework.

Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Love to explore Java

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : RohitBanda

Article Tags :
Practice Tags :


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.