Spring Cloud ComponentsThere are the following components:
ConfigurationSpring Cloud configuration components provide server-side and client-side support for externalized configuration in a distributed system. We can manage the external properties with config server for applications across all environments. Spring Cloud config server can use Git, SVN (Apache Subversion), filesystem, and Vault to Store config. Config clients (microservice app) retrieve the configuration client from the server on startup. Service DiscoveryThe service discovery is the automatic detection of devices and services over the network. In other words, service discovery is how an application and microservices connect in the distributed environment. Service discovery implementations include both:
There are two discovery patterns: Client-side discovery and Server-side discovery.
In the above figure producer is a software that sends a message to a message broker (Service Registry). A consumer is also a software that receives the message and processes it. Circuit BreakersNetflix has created a library called Hystrix. It implements the circuit breakers pattern. Circuit breakers calculate when to open and close the circuit and what to do in case of failure. When all services fail at some point, the circuit breaker handles these failures gracefully. The circuit breakers have three states: OPEN, CLOSED, and HALF-OPEN State. CLOSED State: If the Circuit breaker is in the CLOSED state and all calls pass through to the supplier microservices. It responds without any latency. OPEN State: The circuit breaker returns an error calls without executing the function. HALF-OPEN State: The circuit turns to HALF-OPEN state when a function execution is timed out. It test that underlying problem still exists or not. It is a monitoring and feedback mechanism. It makes a trial call to supplier microservices to check if it has recovered. If the call to the supplier is timed out, then the circuit remains in the OPEN state. If the call return success, the circuit-switched to the CLOSED state. The circuit breaker returns all external calls to the service with an error during the HALF-OPEN State. Routing and MessagingThe cloud application made up of many microservices so the communication will be critical. Spring Cloud supports communication via messaging or HTTP request. Routing uses Netflix Ribbon and Open Feign while messaging uses Kafka or Rabbit MQ. API GatewayAPI Gateway allows us to route API request (external or internal) to connect services. It also provides a library for building an API gateway on the top of Spring MVC. Its aims to provide cross-cutting concerns to them, such as security and monitoring. Features of API Gateway
TracingSpring Cloud's other functionality is distributed tracing. Tracing is a single request to get data from the application. Tracing results in an exponentially larger number of requests to various microservices. We can add Spring Cloud Sleuth library in our project to enable tracing. Sleuth is responsible for recording timing, which is used for latency analysis. We can export this timing to Zipkin. Zipkin is a distributed tracing tool specially designed for analyzing latency problem inside the microservice architecture. It exposes HTTP endpoint used for collecting input data. If we required to add tracing in our project, we should add the spring-cloud-starter-zipkin dependency. In the microservices, the input traffic volume is so high, so we cannot collect an only certain amount of data. For that purpose, the Spring Cloud Sleuth provides a sampling policy. The sampling policy allows us how much input traffic is sent to Zipkin for analysis. To enable this feature, we have to add the spring-cloud-sleuth-stream dependency. Cl Pipeline and TestingSpring Cloud pipeline is an opinionated (self-important) pipeline for Jenkins and Concourse, which creates pipeline automatically for the application. The building, testing, and deploying in various services is critical to having a successful cloud-native application. The Jenkins pipeline provides a set of the tool designed for modeling simple and more advanced delivery pipeline as code. The definition of a pipeline is written into a text file called Jenkinsfile. The pipeline has two syntaxes: Declarative and Scripted pipeline. These syntaxes are divided into two parts: Steps, and Stages. Steps are the fundamental part of the pipeline as they tell the Jenkins server what to do. Stages are the major part of a pipeline. Stages logically group a couple of steps, which displayed on the pipeline's result screen.
Next TopicMain projects of Spring Cloud
|