A glimpse of microservices with Docker and Kubernetes

0
16532

The microservices architecture is a variant of service oriented architecture. It develops a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API.

‘Microservices’ is a compound word made of ‘micro’ and ‘services’. As the name suggests, microservices are the small modules that provide some functionality to a system. These modules can be anything that is designed to serve some specific function. These services can be independent or interrelated with each other, based on some contract.

The main function of microservices is to provide isolation between services — a separation of services from servers and the ability to run them independently, with the interaction between them based on a specific requirement. To achieve this isolation, we use containerisation, which will be discussed later. The idea behind choosing microservices is to avoid correlated failure in a system where there is a dependency between services. When running all microservices inside the same process, all services will be killed if the process is restarted. By running each service in its own process, only one service is killed if that process is restarted, but restarting the server will kill all services. By running each service on its own server, it’s easier to maintain these isolated services, though there is a cost associated with this option.

How microservices are defined

The microservices architecture develops a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API.

Microservices is a variant of the service-oriented architecture (SOA) architectural style. A SOA is a style of software design in which services are provided to the other components by application components, through a communication protocol over a network that structures an application as a collection of loosely coupled services. In the microservices architecture, services should be fine-grained and the protocols should be lightweight. The benefit of breaking down an application into different smaller services is that it improves modularity and makes the application easier to understand, develop and test. It also parallelises development by enabling small autonomous teams to develop, deploy and scale their respective services independently.

These services are independently deployable and scalable. Each service also provides a kind of contract allowing for different services to be written in different programming languages. They can also be managed by different teams.

Figure 1: Microservices – application databases
Figure 2: Microservices architecture

The architecture of microservices

Microservices follows the service-oriented architecture in which the services are independent of users, products and technologies. This architecture allows one to build applications as suites of services that can be used by other services. This architecture is in contrast to the monolithic architecture, where the services are built as a single unit comprising a client-side user interface, databases and server-side applications in a single frame — all dependent on one another. The failure of one can bring down the whole system.

The microservices architecture mainly consists of the client-side user interface, databases and server-side applications as different services that are related in some way to each other but are not dependent on each other. Each layer is independent of the other, which in turn leads to easy maintenance. The architecture is represented in Figure 2.

This architecture is a form or system that is built by plugging together components, somewhat like in a real world composition where a component is a unit of software that is independently replaceable and upgradeable. These microservices are easily deployable and integrated into one another. This gives rise to the possibility of continuous integration and continuous deployment.

What’s so good about microservices?

With the advances in software architecture, microservices have emerged as a different platform compared to other software architecture. Microservices are easily scalable and are not limited to a language; so you are free to choose any language for the services. The services are loosely coupled, which in turn results in ease of maintenance and flexibility, as well as reduced time in debugging and deployment.

Figure 3: Virtual machines vs containers

Microservices with Docker and Kubernetes

Docker is a software technology that provides containers, which are a computer virtualisation method in which the kernel of an operating system allows the existence of multiple isolated user-space instances, instead of just one. Everything required to make a piece of software run is packaged into isolated containers. With microservices, containers play the same role of providing virtual environments to different processes that are running, being deployed and undergoing testing, independently.

Docker is a bit like a virtual machine, but rather than creating a whole virtual operating system, Docker allows applications to use the same kernel as the system that it’s running on and only requires applications to be shipped with things not already running on the host computer. The main idea behind using Docker is to eliminate the ‘works on my machine’ type of problems that occur when collaborating on code with co-workers. Docker doesn’t have to install and configure complex databases nor worry about switching between incompatible language toolchain versions. When an app is dockerised, that complexity is pushed into containers that are easily built, shared and run. It is a tool that is designed to benefit both developers and systems administrators.

How well does Kubernetes go with Docker?

Before starting the discussion on Kubernetes, we must first understand orchestration, which is to arrange various components so that they achieve a desired result. It also means the process of integrating two or more applications and/or services together to automate a process, or synchronise data in real-time.

The intermediate path connecting two or more services is done by orchestration, which refers to the automated arrangement, coordination and management of software containers. So what does Kubernetes do then? Kubernetes is an open source platform for automating deployments, scaling and operations of application containers across clusters of hosts, providing container-centric infrastructure. Orchestration is an idea whereas Kubernetes implements that idea. It is a tool for orchestration. It deploys containers inside a cluster. It is a helper tool that can be used to manage a cluster of containers and treat all servers as a single unit. These containers are provided by Docker.

The best example of Kubernetes is the Pokémon Go App, which runs on a virtual environment of Google Cloud, in a separate container for each user. Kubernetes uses a different set-up for each OS. So if you want a tool that will overcome Docker’s limitations, you should go with Kubernetes.

To conclude, we may say that microservices is growing very fast, the reason being its features of independence and isolation which give it the power to easily run, test and be deployed. This is just a small summary of microservices, about which there is a lot more to learn.

LEAVE A REPLY

Please enter your comment!
Please enter your name here