What is Microservice?

Microservice is meant to convert large software into a number of pieces. Each piece focuses on a particular point of business. It is just like a little service with a microscopic scope for a specific target, compared to existing monolithic applications where the scope is very broad.

So, it divides the monolithic application into smaller microservices and manages and deploys these services as a single business goal; communication across these distributed services is a difficult task for developers. Use Spring Cloud to simplify integration between these distributed services.

As core Spring concepts are applied to application architecture, Spring enables a separation of concerns between the application components, such as loose coupling, which means the effect of the change is isolated, and tight cohesion, which means the code performs a single, well-defined task. Similarly, microservices exhibit the same strengths, that is, loose coupling between the collaborating services of the application, and you can change these services independently. Another strength is tight cohesion, which means an application service that deals with a single view of data; it also known as Bounded Contexts or Domain-driven design (DDD).

Advantages of Microservices:

These are following advantages if you are using the microservice architecture in your application:

  • Smaller code bases are easy to maintain
  • Easy to scale means you can scale individual components
  • Technology diversity means you can use mix libraries, frameworks, data storage, and languages
  • Fault isolation means component failure should not bring the whole system down
  • Better support for smaller, parallel teams
  • Independent deployment
  • Reduced team size also reduces the overhead associated with keeping a team focused and moving in one direction.

Disadvantages of Microservices:

Even though we have a lot of benefits with the microservices, it also has some challenges. Let’s see:

  • Difficulty to achieve strong consistency across services, such as maintaining ACID transactions within multiple processes
  • Because of distributed system, it’s harder to debug/trace
  • Greater need for end-to-end testing
  • How applications are developed and deployed
  • Communication across services and service-to-service calls

How do multiple microservices find each other? Solution: service discovery.

How do we decide which instance of a service to use? Solution: client-side load balancing.

What happens if a particular microservice is not responding? Solution: Fault Tolerance

How do we control the access of a microservice, such as providing security and rate limits? Solution: Service Security

How do multiple microservices communicate with each other? Solution: Messaging

Spring Cloud comes into the picture to provide the solution to all these challenges. Spring Cloud makes the development of distributed microservices quite practical by using leverage capabilities of the auto-configuration.

Spring Boot makes for easy development with the microservices:

  • You can create numerous services by using Spring Boot
  • You can expose resources via RestController
  • You can also consume these remote services using RestTemplate

Spring Cloud leverages capabilities for continuous deployment, rolling upgrades of new versions of code, quick rollback in case of defects, and running multiple versions of the same service at the same time.

Leave a comment