What are microservices? Does your company really need them? How to evaluate their pros and cons? If you are making a business decision related to this recent top trend in the IT industry, you are in the right place. Welcome in the second part of:
Cloud guide for business owners – everything an entrepreneur needs to know
After reading this article, you will be able to decide for yourself whether your company can benefit from microservices!
What are microservices?
The most frequently cited example of microservices is Netflix. As an application, it contains hundreds of smaller elements, such as:
- a service managing payments,
- a service that remembers the list of movies already watched by a user,
- a service that uses algorithms to suggest movies you might like,
- a service allowing you to create your own list of movies you want to watch,
- and many, many more.
First: back-end, then: micro front-end
In the past, when we talked about microservices, we thought about the backend of the application: server infrastructure, database interactions, implementing algorithms. But today, the frontend is also using the microservices infrastructure.
The shift from monolithic frontends to micro-frontends solved many problems. First, it is simply easier to modify smaller codebases. Second, when several teams are working on the same application, they no longer interfere with one another or overwrite parts of code. Third, similarly to microservices in the backend, micro-frontends continue to function even if one element crashes.
Advantages of microservices
Let’s look at microservices from a business perspective. It is worth mentioning that the presented features are based on a comparison with monolithic applications.
Simplicity application development. It is much easier to develop and deploy a small application that does a specific task than a large, complicated monolith that does everything. Microservices contain a smaller number of lines of code and thus are easier to grasp by developers. That does not only accelerate the pace of work, but also reduces the number of errors (bugs) made while programming.
Services built around business processes. Instead of building one large application that can do everything, we focus on smaller applications that have specific tasks to perform. It may, for example, manage customer subscription details and payments, analyze the history of their purchases, or gather and present data about their trends and preferences. As a result, it’s easier for both development teams and business stakeholders to understand the goal and importance of each service.
Improved speed and time-to-market. One of the greatest advantages of microservices is that this solution allows all development teams to work separately on their services. It is then possible to upgrade and improve certain elements of the application without waiting for other teams to finish their work first. As a result, services can be constantly worked on, improved, and tested – and it doesn’t affect the operation of the application as a whole.
Scalability. Microservices are small applications that work separately from one another. That means if one service demands more powerful hardware, it can be scaled independently. In the case of a monolith, you have to scale the entire application – which is not always a reasonable solution from a financial point of view.
Failure resistance. Because services do not depend on one another, if one of them fails, it can be easily isolated from the rest. One failure does not stop the whole application, as it is the case with monolithic software.
Cloud synergy. Although microservices can be used with on-premise solutions, they are most efficient when deployed in the cloud. Automation is the reason – with clouds, we can configure the services to scale automatically when the need arises.
Disadvantages of microservices
Usually when we are dealing with a new and popular trend, much more is said about its pros than its cons. It is important to remember that flawless solutions do not exist, and that microservices have a few important drawbacks to consider.
Complexity. The maintenance of distributed services is more complex and demands much more technical knowledge and monitoring than in the case of monolithic software. The same can be said about testing. Using microservices demands a cultural change in the company: it is the safest option to choose microservices in companies which already adopted the DevOps culture.
Data consistency might pose a problem. In order to make microservices work as separate applications, each one of them must have access to their own resources – which means, for example, having their own database. Achieving data consistency between these applications is demanding for developers. They might, for example, need to create a lot of failure scenarios for even a simple task.
Consistency or availability. One of the biggest advantages of the described solution is that even if one microservice fails, the application continues to work. The problem is to decide how the application is supposed to behave in case of such a failure.
For example – there is a query, but (due to an error) the system cannot show the most recent data to the user. Should it show the last available value, even if it is not up to date? Or should it return an error and ask the user to repeat the query? The answer depends on the needs – if the value is crucial (example: application for hospital management, query: “did a patient in the hospital receive a medicine?”), it is better to return an error, therefore ensuring data consistency. If the value is not as important (example: application presenting facts and news, query: “how many people live in Los Angeles?”), it is alright to ensure availability and present the last known value.
When (not) to switch to microservices?
The most important piece of knowledge an entrepreneur can acquire is this: first comes the need, latter the technology. Just because big companies use microservices doesn’t mean that this solution will elevate your business. As always, technology is a means to an end, not a goal in itself.
➔ If you don’t have the necessary team of experts, you haven’t adopted the DevOps culture yet, and, most importantly, if your monolithic software meets all your requirements – then it is better to rethink your approach.
➔ Choosing microservices is the best solution if the processes run by your company are maintained by many teams – and when those teams interfere with each other’s work. If continuous development is the means to survive in your industry, then the speed of microservices is also worth considering. If some of your business processes have greater requirements resulting from high traffic or upgrades, it will be reasonable to use microservices architecture with them.
Now you know both sides of the coin – and can plan the implementation of a microservices infrastructure! If you wish to use this solution to update your system, see Legacy Update. If at the same time you want to take advantage of cloud computing, see Cloud.
Author: Łukasz Antosiewicz, Lead Fullstack Software Engineer at Hicron