Microservices Architecture & Containers — Part Two

Planning to cover key architectural concepts

Bhargav Shah
3 min readDec 17, 2017

In the last story of these series, we have covered the what is Microservices and Advantages of Microservices Architecture. Here we will understand what is Containers and what are the benefits of containers based architecture.

What is a Container?

To understand containers, we have to start with Linux cgroups and namespaces, the Linux kernel features that create the walls between containers and other processes running on the host. Linux namespaces, originally developed by IBM, wrap a set of system resources and present them to a process to make it look like they are dedicated to that process.

Linux cgroups, originally developed by Google, govern the isolation and usage of system resources, such as CPU and memory, for a group of processes. For example, if you have an application that takes up a lot of CPU cycles and memory, such as a scientific computing application, you can put the application in a cgroup to limit its CPU and memory usage.

Namespaces deal with resource isolation for a single process, while cgroups manage resources for a group of processes.

Container is a space where a single process (most of the time) runs in its own environment with its own dependencies but sharing OS kernal with other containers.

Containers v/s Virtual Machines

Containers v/s VM’s Architecture

VMs take up a lot of system resources. Each VM runs not just a full copy of an operating system, but a virtual copy of all the hardware that the operating system needs to run. This quickly adds up to a lot of RAM and CPU cycles. In contrast, all that a container requires is enough of an operating system, supporting programs and libraries, and system resources to run a specific program.

Do you need to run the maximum amount of particular applications on a minimum of servers? If that’s you, then you want to use containers

If you need to run multiple applications on servers and/or have a wide variety of operating systems you’ll want to use VMs.

Containers simply make it easier for developers to know that their software will run, no matter where it is deployed. They also enable what’s often called “microservices.” Instead of having one large monolithic application, microservices break down applications into multiple small parts that can talk to each other. This means different teams can more easily work on different parts of an application and, as long as they make no major changes to how those applications interact, they can work independently of each other. That makes developing software faster and testing it for possible errors easier.

List if available container engines

  1. Docker (https://www.docker.com/)
  2. CoreOS rkt (https://coreos.com/rkt/)

Get started with Docker for Mac

  1. Download and Install Docker for Mac (https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac)
  2. Check versions of Docker Engine
    $ docker --version
  3. Check versions of Docker Running Process
    $ docker ps
  4. Now Let’s download our first Docker image and run it
    $ docker run hello-world
    As we don't have “hello-world” image in local, Docker will pull it from Docker Hub. (https://hub.docker.com/)
The output of “hello-world” container image

Hurry !!! we have installed and run our first docker container on Mac.

In the next step of this series, we will understand Container Orchestrator and why we need them. I am also planning to write a blog on “Docker on Raspberry Pi 3” as well as “Building our first Docker Image” — so stay tuned.

Thanks for reading 👍🏻

--

--

Bhargav Shah
Bhargav Shah

Written by Bhargav Shah

Cloud Solution Architect at Walmart Japan

No responses yet