Web Application Development: Principles of Development Based on Microservices. Part 2.

Written by axlle | Published 2022/07/19
Tech Story Tags: microservices | architecture | microservice-architecture | monolithic | docker | kubernetes | containers | containerization

TLDRTo use a microservice architecture, the developer needs to study special technologies that are applicable for web app development. Microservice architecture is based on the principle of *application containerization* For this, it is used the *Docker platform,* which helps to package applications into containers. Kubernetes is used for centralized container management. It helps to accelerate the launch of new products to the market, and one builds an effective process of developing and testing a web application. The REST API uses HTTP requests to perform database functions (creating, updating and deleting records)via the TL;DR App

To use a microservice architecture, the developer needs to study special technologies that are applicable for such web app development. Below we will describe the basic technologies for web app developers — Docker and Kubernetes, REST API, serverless solutions, as well as cloud computing and DevOps.

Containerizing (Docker and Kubernetes)

Microservices are small components. But the size of microservices is not limited. Microservice architecture is based on the principle of application containerization. For this, it is used the Docker platform, which helps to package applications into containers.

Containerization is the packaging of software code with just the operating system (OS) libraries and dependencies required to run the code to create a single lightweight executable. Containers are standardized executable components.

The Docker platform gives to developers the necessary tools for creating, deploying, executing, updating, and stopping containers. Docker uses simple commands and automation tools based on a single API.

Any single container is much smaller and simpler than a virtual machine. Containers meet all the requirements of microservice architecture.

The application can be packaged in the container and transferred to the server in the same form as it worked on the developer's test server. The container serves as a kind of "packaging" that "protects" the application. As a rule, microservices are also packed into containers. When transferring microservices from the test environment to the working environment, they work without problems and errors.

However, there is the following problem: managing large groups of containers is not easy enough. To solve this problem, there is a tool for container orchestration — Kubernetes.

Kubernetes provides convenient container management functions, with just a click of a button, you can perform the following actions:

  • update part of the application;
  • "roll back" updates;
  • add resources where there is a deficit of them;

reduce excess resources.

Below we will consider the advantages of Kubernetes for R&D companies in the development and implementation of web applications.

  1. Microservices and Kubernetes integrate well into the company's existing IT infrastructure. IT specialists do not need to change their working process in the company to integrate Kubernetes and start quickly creating new IT products.
  2. Accelerating the launch of new products to the market. Kubernetes is used for centralized container management. It helps to accelerate and simplify the launch of new applications to the market, and one builds an effective process of developing and testing a web application.
  3. Kubernetes makes it possible to automatically distribute resources to meet the growth of traffic and users without problems when the application is in high demand on the market. In the traditional IT infrastructure, expensive equipment is bought for these purposes. However, when the load on the server decreases, it can then stand idle and not pay off. When using cloud technologies, additional resources are simply allocated for the right time. The faster and easier these resources can be obtained, the sooner the system will be rebuilt to a new load, which means that the risk of errors and failures is reduced. Thus, Kubernetes helps to scale the IT system much easier, faster, and more efficient.
  4. Kubernetes facilitates the implementation and use of advanced technologies such as cloud services, machine learning, big data, and artificial intelligence (AI). For example, Kubernetes allows you to easily and simply transfer a web application to the cloud, and then you can manage it both on-premises and in a cloud. This advantage is in demand by companies using hybrid infrastructure (test environments are in the cloud, and the main development is carried out on their servers).
  5. Kubernetes supports a special function called cluster federation (where one cluster is a group of servers within Kubernetes). This makes it possible to synchronize the work of clusters located in different clouds and manage them. For example, machine learning requires large computing resources. Kubernetes gives developers great opportunities for efficient use of resources and allows them to perform calculations within a cluster. The purpose of Kubernetes is to work with high loads, so it is ideal for Data Science, working with Big Data, and integrates well with cloud Big Data solutions.

REST API

The REST API (Representational State Transfer) in microservice architectures allows of component communication and application integration.

API (application programming interface) provides access of one application to the resource of another application (service). The client is an application that requests access, the server is an application that has a resource.

The REST API uses HTTP requests to perform standard database functions (creating, reading, updating, and deleting records). The resource view is called the state of the resource at any given time ("timestamp"). This information is provided to the client in any format, for example, JavaScript Object Notation (JSON) or it can be HTML, Python, PHP, or text format. The JSON format is independent of the programming language, it is readable for both humans and computers.

Serverless

Microservice architecture is sometimes confused with serverless solutions since the principle of operation of Serverless is similar to microservices. The microservice architecture and Serverless use stand-alone modules that run to perform tasks in containers, they are hidden from the end-user. The fundamental difference is that microservices work according to the "request-response" scheme. In serverless solutions, functions are unidirectional (request only or response only) and they are queued.

In the Serverless, the FaaS (function as a service) approach is used, where the unit of execution is not even a service, but a function consisting of several lines of code.

Cloud computing and DevOps

As a rule, microservices are used together with cloud computing. Ones do this not because it is modern technology.

The main principle of microservices is based on increasing efficiency by reducing deployment costs. The web application is created from components that are independent of each other, each component can be scaled separately. These advantages can also be achieved by using your own local IT infrastructure. However, from the point of view of economic benefits, it is better to use a cloud infrastructure with payment upon use.

With the increasing complexity of the microservice architecture, it is necessary to implement DevOps — a methodology for active interaction of development specialists with technical support specialists. It is necessary to ensure a higher quality of the IT product.

Conclusions

At the end of our article, we will give brief recommendations for software developers. Firstly, at the stage of planning the future application and writing technical requirements, it is necessary to choose the architecture. Choose a microservice architecture not because it is modern and cool, but based on your own goals and objectives.

Let's list the cases when you need to use microservices:

  • A significant number of modules interact with each other (typical for applications for LMS, project management, e-commerce applications, etc.).
  • There is a lot of code, the code can number millions of lines, in this case, a monolithic architecture is not suitable for the application.
  • For some corporate applications, the mechanism of continuous delivery is critical, as well as the timeliness of the release of updates and new releases.
  • When planning the development of a highly loaded application and predicting a high level of traffic. In these cases, microservices and cloud solutions are the most suitable option.
  • There may be completely different resource requirements within a web application. For example, different modules will have different requirements for CPU power, memory, and so on.
  • An application in a monolithic architecture takes a long time to run, and when switching to microservices, forced downtime will decrease.
  • Some applications require a large development team. When using a microservice architecture, it is much more efficient to manage a team when splitting it into small groups. It is also much easier to hire new specialists, they dive into work faster, without a long study of the functionality of the entire application.

I hope that these recommendations will help developers when choosing the architecture when developing web applications.


Written by axlle | Software engineer/ PHP Developer / Yii2 / Laravel
Published by HackerNoon on 2022/07/19