Introduction to Spring Cloud.

Reading Time: 2 minutes

As we are moving from the monolithic to microservice architecture. We need a framework that can easily make the distributed application. Spring Cloud is the answer.

Spring Cloud is a framework that is used for building the robust cloud application. Lets have little introduction to it.

Spring Cloud provides

  • Service registration and discovery
  • Distributed/versioned configuration
  • Service-to-service calls
  • Distributed messaging
  • Routing
  • Circuit Breakers
  • Load balancing
  • Global locks
  • Leadership election and cluster state

We will discuss first two features in this blog.

Service registration and discovery

Spring cloud provides many solutions for service discovery they are Eureka, Zookeeper, Cloud Foundry, and Consul.

What is service discovery?

In a distributed system, there are many services deployed which need to communicating(discover each other) with each other to perform some operation.

Let’s take an example, say we have service A which needs to communicate with service B. Service A needs to know the IP of Service B, this is done by the service discovery process.

Service discovery is a mechanism that have a central registry to maintain the network locations of all the microservices. If a new service come up or old one dies new information will be immediately register and deregisted itself.

Using spring cloud we can make service that will do the work of service discovery. To implement the service discovery you can go through my blog.

Distributed/versioned configuration

As we are making the distributed system we need to externalise our configuration. Why need it? Let discuss a scenario, in a service suppose a URL for a service got changes, we just need to update URL in the config server and refresh that client service configuration to use the updated URL.

If we don’t have the config server then we have to redeploy the service. We can make service using spring that can act as the config server.

Spring Cloud provide the following features.

  • HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content)
  • Embeddable easily in a Spring Boot application using @EnableConfigServer
  • Encrypt and decrypt property values (symmetric or asymmetric)

Config Client features (for Spring applications):

  • Encrypt and decrypt property values (symmetric or asymmetric)
  • Bind to the Config Server and initialize Spring Environment with remote property sources

Spring Cloud Gateway

This project of spring provide a library that can be used to provide an effective way to route to APIs and provide cross cutting concerns to them such as resiliency, monitoring/metrics, and security

Spring Cloud Gateway features:

  • Request Rate Limiting
  • Predicates and filters are specific to routes.
  • Circuit Breaker integration.
  • Spring Cloud DiscoveryClient integration
  • Easy to write Predicates and Filters
  • Path Rewriting
  • Able to match routes on any request attribute.
  • Built on Spring Framework 5, Project Reactor and Spring Boot 2.0

References

https://spring.io/projects/spring-cloud

Knoldus-blog-footer-image

Written by 

Priyanka Thakur is a Software Consultant having 6 months of experience currently working at Knoldus Software LLP. She has done MCA at BVICAM, GGSIPU. She has a graduation degree in BCA from JIMS, GGSIPU. She is familiar with programming language' s such as C, Java, and Scala. She also has interest in Angular and Docker and currently working on Logam. She is dedicated, focused and hardworking person. Her interests are in to face new programming challenges because she believes these challenges produce opportunity. She is keen to learn new technologies. In her leisure time, she prefers reading about mythology, watching movies.

Leave a Reply