Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Hands-On Microservices with Spring Boot and Spring Cloud
Hands-On Microservices with Spring Boot and Spring Cloud

Hands-On Microservices with Spring Boot and Spring Cloud: Build and deploy Java microservices using Spring Cloud, Istio, and Kubernetes

Arrow left icon
Profile Icon Magnus Larsson AB
Arrow right icon
$19.99 per month
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9 (17 Ratings)
Paperback Sep 2019 668 pages 1st Edition
eBook
$32.99 $47.99
Paperback
$59.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Magnus Larsson AB
Arrow right icon
$19.99 per month
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9 (17 Ratings)
Paperback Sep 2019 668 pages 1st Edition
eBook
$32.99 $47.99
Paperback
$59.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$32.99 $47.99
Paperback
$59.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Microservices with Spring Boot and Spring Cloud

Introduction to Microservices

This book does not blindly praise microservices. Instead, it's about how we can use their benefits while being able to handle the challenges of building scalable, resilient, and manageable microservices.

As an introduction to this book, the following topics will be covered in this chapter:

  • How I learned about microservices and what experience I have of their benefits and challenges
  • What is a microservice-based architecture?
  • Challenges with microservices
  • Design patterns for handling challenges
  • Software enablers that can help us handle these challenges
  • Other important considerations that aren't covered in this book

Technical requirements

No installations are required for this chapter. However, you may be interested in taking a look at the C4 model conventions, https://c4model.com, since the illustrations in this chapter are inspired by the C4 model.

This chapter does not contain any source code.

My way into microservices

When I first learned about the concept of microservices back in 2014, I realized that I had been developing microservices (well, kind of) for a number of years without knowing it was microservices I was dealing with. I was involved in a project that started in 2009 where we developed a platform based on a set of separated features. The platform was delivered to a number of customers that deployed it on-premise. To make it easy for the customers to pick and choose what features they wanted to use from the platform, each feature was developed as an autonomous software component; that is, it had its own persistent data and only communicated with other components using well-defined APIs.

Since I can't discuss specific features in this project's platform, I have generalized the names of the components, which are labeled from Component A ...

Defining a microservice

To me, a microservice architecture is about splitting up monolithic applications into smaller components, which achieves two major goals:

  • Faster development, enabling continuous deployments
  • Easier to scale, manually or automatically

A microservice is essentially an autonomous software component that is independently upgradeable and scalable. To be able to act as an autonomous component, it must fulfill certain criteria as follows: 

  • It must conform to a shared-nothing architecture; that is, microservices don't share data in databases with each other!
  • It must only communicate through well-defined interfaces, for example, using synchronous services or preferably by sending messages to each other using APIs and message formats that are stable, well-documented, and evolve by following a defined versioning strategy.
  • It must be deployed...

Challenges with microservices

In the Challenges with autonomous software components section, we have already seen some of the challenges that autonomous software components can bring (and they all apply to microservices as well) as follows:

  • Many small components that use synchronous communication can cause a chain of failure problem, especially under high load.
  • Keeping the configuration up to date for many small components can be challenging.
  • It's hard to track a request that's being processed and involves many components, for example, when performing root cause analysis, where each component stores log events locally.
  • Analyzing the usage of hardware resources on a component level can be challenging as well.
  • Manual configuration and management of many small components can become costly and error-prone.

Another downside...

Design patterns for microservices

This topic will cover using design patterns to mitigate challenges with microservices, as described in the preceding section. Later in this book, we will see how we can implement these design patterns using Spring Boot, Spring Cloud, and Kubernetes.

The concept of design patterns is actually quite old; it was invented by Christopher Alexander back in 1977. In essence, a design pattern is about describing a reusable solution to a problem when given a specific context.  

The design patterns we will cover are as follows: 

  • Service discovery
  • Edge server
  • Reactive microservices
  • Central configuration
  • Centralized log analysis
  • Distributed tracing
  • Circuit Breaker
  • Control loop
  • Centralized monitoring and alarms
This list is not intended to be comprehensive; instead, it's a minimal list of design patterns that are required...

Software enablers

As we've already mentioned, we have a number of very good open-source tools that can help us both meet our expectations of microservices and, most importantly, handle the new challenges that come with them:

  • Spring Boot
  • Spring Cloud/Netflix OSS
  • Docker
  • Kubernetes
  •  Istio (a service mesh)

The following table maps the design patterns we will need to handle these challenges, along with the corresponding open-source tool that implements the design pattern:

Design Pattern Spring Boot Spring Cloud Kubernetes Istio

Service discovery

Netflix Eureka and Netflix Ribbon Kubernetes kube-proxy and service resources

Edge server

Spring Cloud and Spring Security OAuth Kubernetes Ingress controller Istio ingress gateway

Reactive microservices

Spring Reactor and Spring WebFlux

Central configuration

Spring Config Server Kubernetes ConfigMaps...

Technical requirements

This chapter does not contain any source code that can be downloaded, nor does it require any tools to be installed.

Learning about Spring Boot

Spring Boot, and the Spring Framework that Spring Boot is based on, is a great framework for developing microservices in Java.

When the Spring Framework was released in v1.0 back in 2004, it was released in order to fix the overly complex J2EE standard (short for Java 2 Platforms, Enterprise Edition) with its infamous and heavyweight deployment descriptors. Spring Framework provided a much more lightweight development model based on the concept of dependency injection (DI). Spring Framework also used far more lightweight XML configuration files compared to the deployment descriptors in J2EE.

To make things even worse with the J2EE standard, the heavyweight deployment descriptors actually came in two types:
  • Standard deployment descriptors, describing the configuration in a standardized way
  • Vendor-specific deployment descriptors...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand the challenges of building large-scale microservice landscapes
  • Build cloud-native production-ready microservices with this comprehensive guide
  • Discover how to get the best out of Spring Cloud, Kubernetes, and Istio when used together

Description

Microservices architecture allows developers to build and maintain applications with ease, and enterprises are rapidly adopting it to build software using Spring Boot as their default framework. With this book, you’ll learn how to efficiently build and deploy microservices using Spring Boot. This microservices book will take you through tried and tested approaches to building distributed systems and implementing microservices architecture in your organization. Starting with a set of simple cooperating microservices developed using Spring Boot, you’ll learn how you can add functionalities such as persistence, make your microservices reactive, and describe their APIs using Swagger/OpenAPI. As you advance, you’ll understand how to add different services from Spring Cloud to your microservice system. The book also demonstrates how to deploy your microservices using Kubernetes and manage them with Istio for improved security and traffic management. Finally, you’ll explore centralized log management using the EFK stack and monitor microservices using Prometheus and Grafana. By the end of this book, you’ll be able to build microservices that are scalable and robust using Spring Boot and Spring Cloud.

Who is this book for?

This book is for Java and Spring developers and architects who want to learn how to break up their existing monoliths into microservices and deploy them either on-premises or in the cloud using Kubernetes as a container orchestrator and Istio as a service Mesh. No familiarity with microservices architecture is required to get started with this book.

What you will learn

  • Build reactive microservices using Spring Boot
  • Develop resilient and scalable microservices using Spring Cloud
  • Use OAuth 2.0/OIDC and Spring Security to protect public APIs
  • Implement Docker to bridge the gap between development, testing, and production
  • Deploy and manage microservices using Kubernetes
  • Apply Istio for improved security, observability, and traffic management

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 20, 2019
Length: 668 pages
Edition : 1st
Language : English
ISBN-13 : 9781789613476
Vendor :
Oracle
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 20, 2019
Length: 668 pages
Edition : 1st
Language : English
ISBN-13 : 9781789613476
Vendor :
Oracle
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 163.97
Mastering Microservices with Java
$48.99
Java Coding Problems
$54.99
Hands-On Microservices with Spring Boot and Spring Cloud
$59.99
Total $ 163.97 Stars icon

Table of Contents

24 Chapters
Section 1: Getting Started with Microservice Development Using Spring Boot Chevron down icon Chevron up icon
Introduction to Microservices Chevron down icon Chevron up icon
Introduction to Spring Boot Chevron down icon Chevron up icon
Creating a Set of Cooperating Microservices Chevron down icon Chevron up icon
Deploying Our Microservices Using Docker Chevron down icon Chevron up icon
Adding an API Description Using OpenAPI/Swagger Chevron down icon Chevron up icon
Adding Persistence Chevron down icon Chevron up icon
Developing Reactive Microservices Chevron down icon Chevron up icon
Section 2: Leveraging Spring Cloud to Manage Microservices Chevron down icon Chevron up icon
Introduction to Spring Cloud Chevron down icon Chevron up icon
Adding Service Discovery Using Netflix Eureka and Ribbon Chevron down icon Chevron up icon
Using Spring Cloud Gateway to Hide Microservices Behind an Edge Server Chevron down icon Chevron up icon
Securing Access to APIs Chevron down icon Chevron up icon
Centralized Configuration Chevron down icon Chevron up icon
Improving Resilience Using Resilience4j Chevron down icon Chevron up icon
Understanding Distributed Tracing Chevron down icon Chevron up icon
Section 3: Developing Lightweight Microservices Using Kubernetes Chevron down icon Chevron up icon
Introduction to Kubernetes Chevron down icon Chevron up icon
Deploying Our Microservices to Kubernetes Chevron down icon Chevron up icon
Implementing Kubernetes Features as an Alternative Chevron down icon Chevron up icon
Using a Service Mesh to Improve Observability and Management Chevron down icon Chevron up icon
Centralized Logging with the EFK Stack Chevron down icon Chevron up icon
Monitoring Microservices Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9
(17 Ratings)
5 star 29.4%
4 star 11.8%
3 star 11.8%
2 star 11.8%
1 star 35.3%
Filter icon Filter
Top Reviews

Filter reviews by




Chris Jan 29, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book. It's the most thorough examination of this topic I have seen to date. The example code is worth its weight in gold, even if it has a few minor problems. Just knowing that it worked as written for the author provides the reader with a baseline from which to work that is very valuable as a reference design / starting point. If you intend to try to go through all the examples on Windows, you will run into many issues, and it will take you longer. The test-em-all.bash script works on Git Bash for the first 12 chapters or so. I had some good luck with the Windows Subsystem for Linux - Ubuntu in the later chapters, but I will probably switch to a cloud instance or use my MacBook for the last 4 chapters. Again, this is a great book, well worth the price.
Amazon Verified review Amazon
Roy Feb 28, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a a great book if you want to get the flow of micro service pattern using spring cloud. Excellent, the way author explained the concept. the source code works and the examples are real cases you would encounter if you are lucku to work on spring microservices project.if you get a build error on springfox-swagger dependencies, add the dependencies in product-composite-service. Not sure this was not documented on errata page implementation('org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE')
Amazon Verified review Amazon
magdi amer Oct 04, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Best book I have read about the topic. It goes from generic concepts to details, making the learning process easy
Amazon Verified review Amazon
A reader in Denver Oct 04, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've finished the first 6 chapters of this book and it's the best Spring book I've read. It uses Spring Boot 2.1 with JDK 12 so it may be the only up to date book on Spring Boot available right now. Most other Spring books are in need of an update for Spring Boot 2 and current versions of the JDK.The author smartly includes source code for each chapter which allows easily seeing the changes from one chapter to another as the book progresses. And his source code builds and runs correctly, which is not the case for some other Spring books. The author and technical reviewer did quality work.The book uses Docker containers right from the early chapters including docker-compose. The third section of the book covers Kubernetes, which I haven't gotten to yet. I'll post an update to this review if needed as I complete this book.This is not an introduction to Spring Boot so it probably shouldn't be your first book on Spring Boot. This is the book to get if you want to know the state of the art in Spring Boot microservices and how they are actually deployed and orchestrated.
Amazon Verified review Amazon
Stefan Klose Jan 20, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Sehr empfehlenswert. Aus meiner Sicht wird auf Praxisrelevante Themen didaktisch hervorragend eingegangen und die Beispiele sind qualitativ sehr hochwertig (ladet die aktuelleste Version bei GitHub runter). Ich habe die Kubernetesbeispiele so erweitert, dass sie auf der Google Kubernetes Engine laufen mit den jeweils akutellen Komponenten. Mit dem Einsatz von Skaffold und JIB eine gute Übung.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.