Amazon Cloud Technology--"Introduction to Containers" study notes | From the real world into the virtual world//Why containers and microservices become "good partners"

foreword

With an interest in technical learning, I opened the recommended "Introduction to Containers" course, wanting to have a basic understanding of containers, and finish the course in one go.

Let me briefly talk about my learning experience. The content is easy to understand. Starting from the history of containers, with the fun of storytelling, I feel the joy of learning and gradually enter the state of learning. This kind of learning feeling of getting better and better is still very good.

The content of the whole course is not particularly large, but it is very clear about the basic knowledge points of containers, specific technologies and the importance in microservice architecture.

Course Introduction

6ce1d3bb628b4934a2996830011cd85f.pngThe course explanation is very easy to understand and the course summary is also very good


text:

Next, I will share my study notes during the re-learning process and output

First of all what is a container?

What does it mean when we call something a container?

While container may sound like a generic term, know that it has a huge impact on the shipping industry

7e6ca955908e48948e0cb94840d89c21.png

The Evolution of History - The Real World

Similar things can always find out the law through induction and summarization, and the container is no exception.

for example:

Not so long ago, getting the physical cargo from point A to point B was a challenge, with odd-shaped shipments that some would hold and others wouldn't. Usually, people have to manually load the goods into these vessels, and people don't know how much goods can be contained in the vessels until they are filled with goods. The movement of goods is slow, inefficient and costly. Then came the container. Standardization of containers began in the 18th century and continued for 200 years until 1958 when Malcolm Mclean and Keith Tentlinger patented the current container for international shipping`. Standardized containers improve cargo handling on ships, and in addition, provide consistent, predictable storage units that can be easily transferred to trucks or rail. By focusing on containers rather than individual shipments, we have increased efficiency and increased productivity while significantly reducing costs to consumers.

With the evolution of history, the emergence of containers has improved the loading and unloading of goods on ships. Efficiency is improved and costs are reduced.

7d1dfb15ba094122ae2f3315e89de533.png

With the evolution of history, the emergence of containers has improved the loading and unloading of goods on ships.

The advantages of using containers are

  • Provides a predictable memory location
  • Focusing on containers instead of individual pieces increases efficiency and productivity while reducing costs for consumers

aa78ee15ab4147d98da5f2a967e66e55.png 755cc079acd24a4aae32a213384c322e.png

Now back from the real world to the virtual world


back to the virtual world

In a computing platform, a container is a standardized unit of software that can run quickly and reliably in any computing environment running a containerized platform. A container is a form of virtualization implemented at the operating system level. A container is an independent lightweight level package which includes everything needed to run the application.

For example: code, system tools, system libraries and settings.

 

 

A single server can host multiple containers, which can be services within a large enterprise application or stand-alone applications running in an isolated environment.

 This kind of picture can give a more concrete understanding of the content contained in the container


How do containers differ from other forms of virtualization?

  Virtualization classification

 ​​​​​​​

 As the level of technical achievement usually comes with an increased level of abstraction using bare metal servers one can build architectural layers

For example:

  • The application software layer of the infrastructure
  • Install an operating system on the server hardware Install all shared libraries on that operating system before installing applications that use those libraries, before installing applications that use those libraries

This has been going on for a long time The problem with this architecture is that it's extremely inefficient , whether you run it at 0% utilization or at 100% utilization the hardware cost is the same and you have to keep all the applications running Synchronization can run into problems if one application requires a newer version of a library but other applications running on the host are not compatible with this version. You can increase agility by placing a virtualization platform on top of the operating system. Now you have isolated the application and its library using the complete operating system that comes with the virtual machine, so you can use the current hardware to run more virtual machines, which greatly reduces the physical footprint. However, the disadvantage of virtual machines is that they contain a lot of virtual layers. In virtual machine instances, there are now four operating systems on the host instead of one which means more patches and updates are required and more space is taken up on the physical host. In addition, there is serious redundancy, the same operating system may be installed four times, and the same library may be installed three times. We can do better then we introduce containers.

The container runtime shares the operating system kernel, allowing you to create container images with a filesystem layer. Containers are lightweight, efficient, and fast. Compared with virtual machines, containers can be started and shut down faster so that the underlying hardware can be better utilized. You can share libraries on demand or provide different libraries for different applications. Each other does not affect each other and the container is highly portable. Since the container isolates the software from other layers, the code of each software can be executed indifferently in different environments.


Containerization is not an entirely new concept! , it has undergone a series of evolutions.

 ​​​​​​​

  • 2004 - Solar zones
  • 2000 年 - FreeBSD jails
  • 1982 - Unix chroot

Why are containers so popular right now?

One reason: the rise of Docker as a virtualization platform

Why use Docker as a virtualization platform?

28d80a520901401b807c454d29cddf3b.jpg

Docker was released in March 2013

  • Docker is a lightweight container virtualization platform
  • Provides tools for creating, storing, managing and running containers
  • Easily integrate with automated build, test and deployment pipelines

Docker has some of the most important advantages :

  • Docker Portable Runtime Application Environment
  • Applications and dependencies can be packaged into a single immutable artifact, called an image. Once a container image is created, it can be used anywhere Docker is supported
  • Ability to run different application versions with different dependencies concurrently
  • Faster development and deployment cycles
  • Improve resource utilization and efficiency

Many of these features are developer dreams and all of this comes back to agility


Much of the work behind containers comes from the concept of a container image, which is a read-only template that contains instructions for creating a container. You can create an image from scratch or use an image created by someone else and published to a public or private registry. An image is often Based on another image with some customizations.

For example:

You can build new images based on Ubuntu Linux images in the registry. However, in addition to the basic configuration for your application to run it also installs the web server and your application To build a new image, you can create a Dockerfile with a simple syntax that defines how to create and run the image. Every instruction in the Dockerfile creates a read-only layer in the image.

Example: Dockerfile

Simple example: ---The output is "Hello world"

FROM ubuntu:latest
CMD echo "Hello world"

Complicated example:

FROM openjdk:8
COPY /hello.jar /usr/str/hello.jar
CMD java -cp /usr/src/hello.jar
org.exemple.App

Docker example:

FROM centos:7
RUN yum -y update && yum -y install httpd
EXPOSE 80
ADD run-http.sh /run-http.sh
RUN chmod -v +x /run-http.sh
CMD ["/run-http.sh"]

 These layers are all read-only, so the container image is an immutable object, which is one of the factors that help the container image to be lightweight, small and fast


Related terms:
Docker images and containers

  • Container images are highly portable, immutable, read-only templates that can be ported to any environment that supports Docker, or stored in a registry for reuse.
  • A container is an example of a mapping from which one or more containers can be started. Each container uses a thin read/write layer on top of its existing image. This makes it possible to start containers quickly.
  • Multiple containers can share access to the same underlying image while still having independent data states.
  • When the container is deleted, the writable layer is also deleted.
  • The container's read/write layer keeps your application up and running while it's running.

dbb4c02e8ef24fe08e31a69b756576dc.png

 44dd3af2bcf149be88a2e65dee5404fe.png

Use a "copy-on-write" system to write changed files to the container's read/write layer.

Thus, multiple containers can share access to the same underlying image while still having independent data state. When a container is deleted, this writable layer is also deleted. The read/write layer of containers keeps your application up and running while it's running but it's not meant for long-term storage of data A unit of computation, not a unit of storage.


What are microservices?

In recent years, the term microservice has gradually aroused the interest and discussion of developers, so what is microservice?

Microservices is an architectural and organizational approach to software development designed to speed up deployment cycles.

Microservices can promote innovation and ownership, and improve the maintainability and scalability of software applications compared to traditional architectures.

As shown in the figure, the comparison between the traditional architecture and the microservice architecture:

2669412052cf4338bd6f530540c29aa3.png

97b18785f4e14f9aada513f74f6a63a8.png

First look at the traditional structure

For each application, all processes are tightly coupled, which means that if one process of the application experiences a spike in demand, the entire structure must be scaled. As the codebase grows, adding or improving features becomes more complex. Not only does this limit experimentation, it also makes it difficult to realize ideas

The monolithic architecture also increases the risk of application availability. Because of many interdependent and tightly coupled processes, the impact of a single process failure is magnified. And it is not difficult to see that there is a lot of redundancy in functionality between different applications

Now look at the microservice architecture

As shown in the figure, a total of three identical applications are running. Each application is built as an independent component that runs as a service. And communicate using lightweight API operations. Each service performs a function that can support multiple applications. All services used run independently. Services can therefore be updated, deployed, and scaled to meet the needs of specific application functionality

It is also possible to migrate from professional servers to an abstract hardware layer where microservices can be placed intelligently based on requirements such as performance and elasticity. All this disaggregation leads to faster iterations, automation, and overall agility. Supports fast boot, fast fail and fast recovery


What are the advantages of a microservices environment?

Containers are often associated with microservices environments

One of the most powerful factors driving the development of containers is the rise of microservices architecture, an architectural and organizational approach to software development designed to speed up deployment cycles. This approach promotes innovation and ownership and improves the maintainability of software applications. and scalability

  • Each application is built as an independent component that runs as a service and communicates using lightweight API operations
  • Each service performs a function that can support multiple applications, and the services used run independently

 Characteristics of Microservices

  • Decentralized innovative design
  • Smart End Nodes, Dumb Pipes
  • Take the form of a stand-alone product, not a project
  • design for failure
  • Disposability
  • Both development and production


 

The importance of containers in the microservice architecture , after doing the above understanding, we can understand why containers and microservices are "good partners"

  • Containers are the foundational technology underpinning modern microservices architectures.
  • Place microservices into containers. Containers take up less space and start faster. With a microservices architecture, developers can take full advantage of containers.
  • Decentralized innovative design, each container uses the most suitable language and technology for service operation, rather than requiring users to use a specific language or specific technology.

Summarize

summary:

  • A container is a standardized software unit. It runs fast and reliably in any computing environment running a containerized platform. Is a form of virtualization implemented at the operating system level.
  • Compared with other virtualization methods, containers have the advantages of lightweight, high efficiency, fast startup and shutdown, shared libraries on demand, more flexibility, and high portability.
  • Docker Containers, a lightweight container virtualization platform. Can provide tools to create, store, manage and run containers. It has the advantages of efficient transplantation, running applications with different dependencies and different versions at the same time, shortening the development cycle, and improving resource utilization.
  • Microservices is an architectural and organizational approach to software development designed to speed up deployment cycles.
  • Containers and microservices are "good partners". Containers are the foundational technology underpinning modern microservices architectures. Place microservices into containers. Containers take up less space and start faster. With a microservices architecture, developers can take full advantage of containers.
     

Personal feelings:

Through this Amazon cloud technology cloud native course study, I realized the container, the importance of the container and how useful it is, and learned the characteristics of the microservice architecture and the difference between it and the monolithic architecture , and why containers are the fundamental technology that supports the use of modern microservice architectures.

The content is easy to understand, starting from the history of containers, with the fun of storytelling, let me feel the fun of learning and gradually enter the state of learning.

 

Guess you like

Origin blog.csdn.net/weixin_73636162/article/details/127927065