Service mesh for microservices. Part I
If you have followed trends in distributed and cloud architectures in recent years, you've probably heard about microservices more than once. They appeared several years ago, and since then their role in corporate cloud deployments has only grown. More and more companies are switching to microservices and declare this in their publications and press releases.
Their choice is justified, but only a few tell what is behind such a transition. With proper implementation, microservices solve many problems of monolithic architecture: they are easy to iterate and distribute into groups, and the code is easily divided into managed components. However, in most publications there is not a word about the subsequent work with microservices and tools necessary for their effective use.
Today we look behind the scenes and see what a service mesh is, how this technology helps solve microservice architecture problems and simplifies the work of developers. I hope you get a detailed idea of its role in microservice deployments.
What is a service mesh?
Service mesh (the terms “microservice network”, “mesh-network of microservices” are also used) – this is an abstract layer of infrastructure that defines the interaction between microservices of an application. The technology uses network connections between containers to control the interaction of various application components. It sounds pretty abstract, but actually it’s a very practical concept. Containers interact through the network, so changing the topology of the network allows you to change the order in which containers interact.
Effective collaboration plays a key role in microservices. Managing this interaction with the service mesh provides many benefits. So, when deploying new versions of components, you can instantly switch network devices from old to new ones without additional configuration. If you have difficulty scaling, you can use service mesh to redirect traffic to various load balancers and increase the number of containers for application components.
A popular tip for those who start working with microservices is: treat the various components of the application as an API of completely different providers. Technology service mesh allows you to implement this principle at the network level and accurately determine which services will be available in certain network locations. In case of moving or modifying a service, instead of deploying a new configuration, it is enough to change the network interaction.
What does it give?
Microservices are popular for their extensive scalability and are suitable for working with large applications that can be broken down into easily manageable components. Monolithic architectures, by contrast, are convenient in areas where centralization is important. In monolithic applications, it is easier to record events, as they run in the same location. Version control is also straightforward, as a single instance is overwritten. It is not surprising that many developers are lost in the transition from monolithic to microservice architectures, where there is no single location for journaling and it is more difficult to select the necessary versions of components.
Technology advantage service mesh lies in the fact that it plays the role of a central source of some data, in particular data on network interactions. Consider the above example of deploying a new version of an application component. Instead of destroying all containers containing the old version, launching new containers with the new version and repeating this process for other related components, you can control which containers will be visible to other containers on the network.
This means that to deploy the new version, it is enough to simply specify the new containers as target using DNS, to target the new load balancer or to change the containers that the existing balancer is targeting.
By focusing on the interactions between the components of the application (on the mesh network in which they work), you can maintain a certain level of centralization, which simplifies administration in a monolithic environment. Need more information about traffic passing through the app? Add monitoring capabilities to the network between components. Want to increase security? Implement strong encryption and HTTPS. All this is possible thanks to service mesh.
Want to know more?
In the next couple of weeks we will study in more detail the operation of the mesh network and its practical application in some deployment scenarios of microservices. We will focus on the real benefits of this technology: effective control, manageability and the ability to monitor the processes of large applications.