Mastering Spring Boot 2.0
eBook - ePub

Mastering Spring Boot 2.0

Build modern, cloud-native, and distributed systems using Spring Boot

Dinesh Rajput

Buch teilen
  1. 390 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Mastering Spring Boot 2.0

Build modern, cloud-native, and distributed systems using Spring Boot

Dinesh Rajput

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Learn to develop, test, and deploy your Spring Boot distributed application and explore various best practices.

Key Features

  • Build and deploy your microservices architecture in the cloud
  • Build event-driven resilient systems using Hystrix and Turbine
  • Explore API management tools such as KONG and API documentation tools such as Swagger

Book Description

Spring is one of the best frameworks on the market for developing web, enterprise, and cloud ready software. Spring Boot simplifies the building of complex software dramatically by reducing the amount of boilerplate code, and by providing production-ready features and a simple deployment model.

This book will address the challenges related to power that come with Spring Boot's great configurability and flexibility. You will understand how Spring Boot configuration works under the hood, how to overwrite default configurations, and how to use advanced techniques to prepare Spring Boot applications to work in production. This book will also introduce readers to a relatively new topic in the Spring ecosystem – cloud native patterns, reactive programming, and applications. Get up to speed with microservices with Spring Boot and Spring Cloud. Each chapter aims to solve a specific problem or teach you a useful skillset. By the end of this book, you will be proficient in building and deploying your Spring Boot application.

What you will learn

  • Build logically structured and highly maintainable Spring Boot applications
  • Configure RESTful microservices using Spring Boot
  • Make the application production and operation-friendly with Spring Actuator
  • Build modern, high-performance distributed applications using cloud patterns
  • Manage and deploy your Spring Boot application to the cloud (AWS)
  • Monitor distributed applications using log aggregation and ELK

Who this book is for

The book is targeted at experienced Spring and Java developers who have a basic knowledge of working with Spring Boot. The reader should be familiar with Spring Boot basics, and aware of its benefits over traditional Spring Framework-based applications.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Mastering Spring Boot 2.0 als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Mastering Spring Boot 2.0 von Dinesh Rajput im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Programming in Java. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2018
ISBN
9781787125148

Containerizing Microservice

This chapter will provide an introduction to containers, dockerizing the services built in the previous chapter, writing the Dockerfile and orchestrating the containers using docker-compose, and providing orchestration examples in Kubernetes.
In the previous chapter, we learned about microservice architecture and its advantages and challenges. One of the major challenges in the microservice-distributed application is the deployment of several microservices across multiple machines (VMs). How will they share common resources of VMs? In production, deploying and managing a system composed of many independent services is an operational complexity.
In microservice architecture, you create and deploy services independently, and you have to re-test your services after deployment on the same VMs. A microservice wouldn't impact on the other microservices, but you could never really guarantee that because the service is independent of the other services, it is using common resources of VMs.
In the favor of microservice architecture, containerized deployment is the topping on the pizza. The microservice is already autonomous by its functional service, but the containerization makes microservices more autonomous by self-containing the underlying infrastructure. So, containerization is making the microservices cloud-neutral.
In this chapter, we will introduce the containerized deployment of microservices and concepts of virtual machine images. Readers will get an understanding of building Docker images for microservices, which are developed with Spring Boot and Spring Cloud. We will also explore how to deploy Docker images in production-like environments, and how to manage and maintain these Docker images.
By the end of this chapter, you will have a better understanding of containerization and how to containerize a microservice developed with Spring Boot and Spring Cloud.
This chapter will cover the following points:
  • Introducing containers in the microservice architecture
  • Getting started with Docker
  • Dockerizing any Spring Boot application
  • Writing Dockerfile
  • Using docker-compose
  • Writing the docker-compose file
  • Orchestration using docker-compose
  • Introducing Kubernetes
  • Orchestration using Kubernetes
Let's look at these topics in detail.

Introducing containers to the microservice architecture

The microservice architecture is another approach to developing a distributed application. This approach is suitable for the agility, scale, and reliability requirements of modern cloud applications. As we know, a microservice application is decomposed into separate components independently to work together to achieve the whole system.
In microservice architecture, you can scale out independently on the specific functionality rather than unnecessarily scaling out other areas of the application. So, you can scale the resources, such as processing power or network bandwidth, for a specific microservice. But what about sharing infrastructures with another microservice? In this chapter, we will discuss this challenge. Containerization comes into the picture to solve the problem of sharing infrastructure between microservices and allowing microservices to be more autonomous.
Containerization allows you to run your microservices in a completely isolated environment. So, according to the containerization approach, a container is an artifact in which a microservice and its versioned set of dependencies, plus its environment configuration, are abstracted as deployment manifest files. The container contains all infrastructure-related dependencies, environment variables, and configurations. It is packaged together as a container image. And this image is tested as a unit and deployed to a host operating system.
Containerization is nothing but it is a different approach to development and deployment of the microservices. The container is an isolated and runnable instance of an image. That image contains everything required to run an application. In the container, an application can run without using the resources of another container or host machine. You also have full control over a container to create, delete, move, start, and stop this container using a CLI, such as the Docker client. Containers can be connected to each other using a network. A container acts like a separate, independent, and isolated physical or virtual machine.
Although a container looks like a physical or virtual machine, the containers use the technology and concepts very differently from virtual machines. Although a container runs an operating system, it has a file system, and it can be accessed over a network, just like a virtual machine. Let's see the following diagram on virtual machine:
As you can see in the preceding diagram, Virtual Machines include the application, the required dependencies, and a full guest operating system. Hypervisor is a computer software that shares and manages hardware. Let's see the following diagram about Containers:
As you can see in the preceding diagram, Containers include the application and its required dependencies. Unlike virtual machines, Containers share the Operating System and underlying Infrastructure with other containers. These are running as an isolated process on the host operating system. Because Containers share resources, they require fewer resources than virtual machines.

Virtual machines versus containers

Let's see the following differences between virtual machines and containers:
Virtual machines
Containers
Virtual machines include the applications, the required dependencies, and a full guest operating system
Containers include the applications and the required dependencies, and share operating systems and underlying infrastructure
Each virtual machine has its own guest operating system; because of this, it requires more resources
Because containers share resources, they require fewer resource, the minimal kernel of the operating system present for each container
The hypervisor manages VMs, environments
The container engine manages containers
You have to add specific resources for scaling
You can scale out containers by creating another container of an image
Fewer virtual machines can be created for the same hardware and resources
More containers can be created for the same hardware and resources
Virtual machines are virtualizing the underlying hardware
Containers are virtualizing the underlying operating system
A VM can take up several GB depending on guest OS
Containers don't require that many GB, because they share resources, they merely use dozens of MB
Virtual machines are generally more suitable for monolithic applications with high-security concerns
Containers are generally more suitable for microservice-based applications, or other cloud-native applications, where security is not the major concern
As we have seen in the previous table, VMs and containers cannot replace each other. So, we can choose according to application requirements and application architecture.

Benefits of a container-oriented approach

The following are the advantages of a container-oriented development and deployment approach:
  • A container-oriented approach eliminates the challenges that arise from inconsistent environment setups.
  • You can do fast application scale-up by instancing new containers as required.
  • Requires minimal usage of kernels on the operating system.
  • You can create the number of containers for a microservice, depending on application requirements.
  • You can easily...

Inhaltsverzeichnis