Microservices 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.
Monolithic architecture and 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
- Increases scalability
- More flexibility
- Modular architecture
- Ease of introducing new features
- More reliable and robust structure
Challenges
- Cost management
- Network latency and load balancing
- Complexity at the end-to-end testing
Health Care Example
Let’s take an example
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
Config server uses the 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.
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
- 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