The Spring Cloud project is an umbrella project from the Spring team that implements a set of common patterns required by distributed systems, as a set of easy-to-use Java Spring libraries. Despite its name, Spring Cloud by itself is not a cloud solution. Rather, it provides a number of capabilities that are essential when developing applications targeting cloud deployments that adhere to the Twelve-Factor application principles. By using Spring Cloud, developers just need to focus on building business capabilities using Spring Boot, and leverage the distributed, fault-tolerant, and self-healing capabilities available out of the box from Spring Cloud.
The Spring Cloud solutions are agnostic to the deployment environment, and can be developed and deployed in a desktop PC or in an elastic cloud. The cloud-ready solutions that are developed using Spring Cloud are also agnostic and portable across many cloud providers such as Cloud Foundry, AWS, Heroku, and so on. When not using Spring Cloud, developers will end up using services natively provided by the cloud vendors, resulting in deep coupling with the PaaS providers. An alternate option for developers is to write quite a lot of boilerplate code to build these services. Spring Cloud also provides simple, easy-to-use Spring-friendly APIs, which abstract the cloud provider's service APIs such as those APIs coming with AWS Notification Service.
Built on Spring's "convention over configuration" approach, Spring Cloud defaults all configurations, and helps the developers get off to a quick start. Spring Cloud also hides the complexities, and provides simple declarative configurations to build systems. The smaller footprints of the Spring Cloud components make it developer friendly, and also make it easy to develop cloud-native applications.
Spring Cloud offers many choices of solutions for developers based on their requirements. For example, the service registry can be implemented using popular options such as Eureka, ZooKeeper, or Consul. The components of Spring Cloud are fairly decoupled, hence, developers get the flexibility to pick and choose what is required.
The Spring Cloud project is an overarching Spring project that includes a combination of different components. The versions of these components are defined in the spring-cloud-starter-parent
BOM.
In this book, we are relying on the Brixton.RELEASE
version of the Spring Cloud:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>
The spring-cloud-starter-parent
defines different versions of its subcomponents as follows:
<spring-cloud-aws.version>1.1.0.RELEASE</spring-cloud-aws.version> <spring-cloud-bus.version>1.1.0.RELEASE</spring-cloud-bus.version> <spring-cloud-cloudfoundry.version>1.0.0.RELEASE</spring-cloud-cloudfoundry.version> <spring-cloud-commons.version>1.1.0.RELEASE</spring-cloud-commons.version> <spring-cloud-config.version>1.1.0.RELEASE</spring-cloud-config.version> <spring-cloud-netflix.version>1.1.0.RELEASE</spring-cloud-netflix.version> <spring-cloud-security.version>1.1.0.RELEASE</spring-cloud-security.version> <spring-cloud-cluster.version>1.0.0.RELEASE</spring-cloud-cluster.version> <spring-cloud-consul.version>1.0.0.RELEASE</spring-cloud-consul.version> <spring-cloud-sleuth.version>1.0.0.RELEASE</spring-cloud-sleuth.version> <spring-cloud-stream.version>1.0.0.RELEASE</spring-cloud-stream.version> <spring-cloud-zookeeper.version>1.0.0.RELEASE </spring-cloud-zookeeper.version>
Each Spring Cloud component specifically addresses certain distributed system capabilities. The grayed-out boxes at the bottom of the following diagram show the capabilities, and the boxes placed on top of these capabilities showcase the Spring Cloud subprojects addressing these capabilities:
The Spring Cloud capabilities are explained as follows:
Many of the Spring Cloud components which are critical for microservices' deployment came from the Netflix Open Source Software (Netflix OSS) center. Netflix is one of the pioneers and early adaptors in the microservices space. In order to manage large scale microservices, engineers at Netflix came up with a number of homegrown tools and techniques for managing their microservices. These are fundamentally crafted to fill some of the software gaps recognized in the AWS platform for managing Netflix services. Later, Netflix open-sourced these components, and made them available under the Netflix OSS platform for public use. These components are extensively used in production systems, and are battle-tested with large scale microservice deployments at Netflix.
Spring Cloud offers higher levels of abstraction for these Netflix OSS components, making it more Spring developer friendly. It also provides a declarative mechanism, well-integrated and aligned with Spring Boot and the Spring framework.