Chapter 1. Welcome to the cloud, Spring
The chapter introduces microservices as a response to the growing pain of large, monolithic applications that are hard to change, test, and deploy across multiple teams. It explains that microservices are small, loosely coupled services with clear boundaries, each owning a narrow business responsibility and able to be built, deployed, and scaled independently. This approach helps organizations reduce coordination overhead, move faster, and design systems that are more flexible, resilient, and scalable.
It then connects microservices to the cloud, showing why cloud environments are such a natural fit for this architecture. The chapter distinguishes among infrastructure, platform, and software as a service, and argues that microservices work especially well on cloud infrastructure because services can be replicated quickly, scaled horizontally, and isolated when failures occur. It also notes emerging deployment models such as containers and serverless functions, while emphasizing the benefits of cloud elasticity, redundancy, and operational efficiency.
The chapter positions Spring as the Java ecosystem’s core toolset for building this style of application, especially through Spring Boot and Spring Cloud. Spring Boot simplifies REST-oriented service development with minimal code, while Spring Cloud adds support for the surrounding needs of microservices, including configuration management, discovery, routing, fault tolerance, security, messaging, tracing, and deployment pipelines. The chapter closes by stressing that microservices are more than just service code: successful systems require careful attention to patterns, infrastructure, and repeatable deployment practices.
Figure 1.1. Monolithic applications force multiple development teams to artificially synchronize their delivery because their code needs to be built, tested, and deployed as an entire unit.
Figure 1.2. Using a microservice architecture our CRM application would be decomposed into a set of microservices completely independent of each other, allowing each development team to move at their own pace.
Figure 1.3. Spring Boot abstracts away the common REST microservice task (routing to business logic, parsing HTTP parameters from the URL, mapping JSON to/from Java Objects), and lets the developer focus on the business logic for the service.
Figure 1.4. Your Spring Boot service will communicate the endpoints exposed and the port of the service via the console.
Figure 1.5. The response from the /hello endpoint shows the data you’ve requested represented as a JSON payload.
Figure 1.6. The different cloud computing models come down to who’s responsible for what: the cloud vendor or you.
Figure 1.7. Microservices are more than the business logic. You need to think about the environment where the services are going to run and how the services will scale and be resilient.
Figure 1.8. When designing your microservice, you have to think about how the service will be consumed and communicated with.
Figure 1.9. Service discovery and routing are key parts of any large-scale microservice application.
Figure 1.10. With microservices, you must protect the service caller from a poorly behaving service. Remember, a slow or down service can cause disruptions beyond the immediate service.
Figure 1.11. Using a token-based security scheme, you can implement service authentication and authorization without passing around client credentials.
Figure 1.12. A well-thought-out logging and tracing strategy makes debugging transactions across multiple services manageable.
Summary
- Microservices are extremely small pieces of functionality that are responsible for one specific area of scope.
- No industry standards exist for microservices. Unlike other early web service protocols, microservices take a principle-based approach and align with the concepts of REST and JSON.
- Writing microservices is easy, but fully operationalizing them for production requires additional forethought. We introduced several categories of microservice development patterns, including core development, routing patterns, client resiliency, security, logging, and build/deployment patterns.
- While microservices are language-agnostic, we introduced two Spring frameworks that significantly help in building microservices: Spring Boot and Spring Cloud.
- Spring Boot is used to simplify the building of REST-based/JSON microservices. Its goal is to make it possible for you to build microservices quickly with nothing more than a few annotations.
- Spring Cloud is a collection of open source technologies from companies such as Netflix and HashiCorp that have been “wrapped” with Spring annotations to significantly simplify the setup and configuration of these services.