Mastering Spring Boot 2.0
eBook - ePub

Mastering Spring Boot 2.0

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

Dinesh Rajput

Compartir libro
  1. 390 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Mastering Spring Boot 2.0

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

Dinesh Rajput

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Mastering Spring Boot 2.0 un PDF/ePUB en línea?
Sí, puedes acceder a Mastering Spring Boot 2.0 de Dinesh Rajput en formato PDF o ePUB, así como a otros libros populares de Computer Science y Programming in Java. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2018
ISBN
9781787125148
Edición
1

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...

Índice