Development

Microservice Architecture with Spring Cloud


What are microservices?

Microservices is an architecture(service-oriented architecture) (SOA). In this architecture, applications are broken down into various services. The motivation behind this is separation and modularity.

Unlike monolithic architecture, microservices are more beneficial.
We don’t need to specify all business logic into a single software module. It leads to complexity and time-consuming debugging.

In the above diagram, as we can see, we have only one unit of application in a monolithic architecture. In a microservices architecture, we can see three different services.

Advantages of microservices are

  • Increases scalability
  • More flexibility
  • Modular architecture
  • Ease of introducing new features
  • More reliable and robust structure

Challenges in microservices

  • Cost management
  • Network latency and load balancing
  • High risk due to intercommunication between microservices
  • Complexity at the end to end testing

Health Care Example

Before jumping into spring cloud, let’s consider a simple healthcare microservices example that we’ll use while understanding spring cloud.

Spring Cloud

It helps us build microservices architecture with various components it provides. Spring cloud helps us manage communication, security threats, maintenance and fault tolerance with different components. Let’s see them one by one.

Spring Cloud Components

  • Spring Cloud Config Server
  • Feign Client
  • Service Discovery and Registry with Eureka
  • Spring Cloud Gateway
  • Resillience4j
  • Spring Cloud Bus

Spring Cloud -> Config Server

Its config server helps us to manage configuration at a central place for microservices instead of managing them at the individual level. It uses git repo to store configurations.

  • Ease of managing configuration of multiple microservices in a single place
  • Configurations can be managed with the application.yaml / properties files within a git repo
  • Each microservice can connect to the config server and get the required configurations

Spring Cloud -> Feign Client

Microservices need to communicate with each other to exchange information. Feign client can be used for that

  • Used for intercommunication between microservices

Spring Cloud -> Eureka Server

  • Eureka Server enables you to register every microservice you built; it is a service registry.
  • Also, it enables you to discover all registered microservices via the eureka server; it is called service discovery.

Spring Cloud -> Spring Cloud Gateway

  • A single, unified API entry point across one or more internal APIs
  • One more layer of security is added via the gateway
  • Ease of handling communication protocols

Spring Cloud -> Resilience4j

  • Circuit Breakers
  • Retry and Fallback
  • Rate Limiting
  • The entire Chain might fail because a single microservice
  • Circuit Breaker comes in for help to handle this
  • We can specify the response to the caller in terms of failure
  • We can limit no. of requests to service w.r.t. time

For any questions and inquiries, visit us at thinkitive

Tags

Abhay Ahire

Team Lead @Thinkitive

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close