Overview

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.

Figure 1.13. You want the deployment of the microservice and the server it’s running on to be one atomic artifact that’s deployed as a whole between environments.

Figure 1.14. You can map the technologies you’re going to use directly to the microservice patterns we’ve explored so far in this chapter.

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.

FAQ

What is a microservice in the context of this chapter?A microservice is a small, loosely coupled, distributed software service that performs a limited number of well-defined tasks. The chapter emphasizes that microservices are designed to be independent and easier to manage than large monolithic applications.
How does a microservice architecture differ from a monolithic architecture?In a monolithic architecture, UI, business logic, and database access are packaged into one deployable application. In a microservice architecture, the application is broken into independent services, each with its own responsibility, allowing teams to build, test, and deploy separately.
Why do companies move from monolithic applications to microservices?Companies adopt microservices to reduce complexity, improve flexibility, support faster delivery, increase scalability, and improve resilience. Smaller services are easier to change, deploy, and scale independently than a large monolithic system.
What are the key characteristics of a microservice architecture?Key characteristics include small components with clear boundaries, independent deployment, communication through lightweight protocols like HTTP and JSON, technology-neutral service interfaces, and small teams owning specific services.
Why are Spring Boot and Spring Cloud important for microservices?Spring Boot simplifies building REST-based microservices with minimal code and without an external application container. Spring Cloud adds tools and integrations for operational microservice needs such as configuration, discovery, load balancing, routing, resiliency, security, logging, and tracing.
What problem does Spring Boot solve for Java developers building microservices?Spring Boot reduces the boilerplate involved in building Java services. It makes it easy to create REST endpoints, map HTTP requests to Java methods, serialize JSON, and run applications with embedded servers like Tomcat.
Why is the cloud a natural fit for microservices?Microservices are small, independent, and easy to deploy as separate artifacts, which fits well with cloud environments. The cloud makes it easier to scale services horizontally, start and stop instances quickly, and improve resilience through redundancy.
What cloud deployment models does the chapter introduce?The chapter introduces Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS). It also mentions emerging models such as Function as a Service (FaaS) and Container as a Service (CaaS).
Why does the book focus on an IaaS-based approach instead of PaaS?The author chooses IaaS to keep the examples more portable across cloud providers and to maintain control over the servers and infrastructure. PaaS can be convenient, but it may hide important details and create vendor-specific limitations.
What kinds of microservice patterns does this book say are necessary beyond writing code?The book says microservices require more than application code. You also need patterns for service granularity, routing, resiliency, security, logging and tracing, configuration management, and build/deployment automation to run them reliably in production.