Is Microservices Architecture Only About the Benefits?
Microservices architecture is not a new thing in software development. However, today this approach to building applications is actively gaining traction.
In 2018, Camunda conducted research and surveyed 354 companies to determine the value of microservices adoption for fulfilling digital transformation initiatives.
Around 63% of respondents mentioned that the transition to microservices helped them improve user experience, employee efficiency, and save on development and infrastructure tools.
The respondents also identified top reasons why they had switched to microservices:
Additional reasons for switching to the microservices
Today, developing a monolithic program comes with various challenges. For example, the more complicated the composition of the monolith is, the more difficult it is for developers to properly maintain it.
Let’s take a look at a scenario where there are many teams working on the same monolithic program. If team B fails to deliver high-quality code, it blocks the other teams from pushing their error-free code to the environment. So, all teams wait till team B fixes the code and tries to deploy it again. All teams are dependant on each other, which results in constant delays in delivering features.
Additionally, adopting new technologies while having a monolith application can be a very slow process. For example, if you want to apply a new framework, you must rewrite all the code, which can also become a huge challenge and lead to crashes.
To minimize these risks, software companies have started actively using microservices application structure. However, this “monolith → microservices” transition may come with its own challenges.
So, in this blog post, we are going to cover the following topics:
- The peculiarities of microservices architecture and some examples
- Benefits of microservices and drawbacks that can occur along with these benefits
- Successful cases of switching to microservices structure
What Are Microservices?
Microservices architecture is an approach to developing complex multipurpose applications. The core idea is to divide the functionality of the application into logical parts called services and maintain them independently.
However, these services can interconnect and process requests from each other via APIs.
Microservices are not necessarily small. They can be any size. An important thing is that each service carries its own dataset and data model and is focused on performing accurate tasks that differ from the tasks assigned to other application services.
Examples of Microservices: Java, Docker, Cloud
The implementation of microservices architecture can be performed with the help of various technologies. To understand which one best suits your case, let’s look at some of the more popular examples.
Microservices in Java
Java is the most popular programming language used to build microservice-based systems. Let’s see an example of microservices built with the Spring framework. Applying Spring Boot allows for setting up autonomous applications with minor configs through the following process:
- First, you need to register the services for all of them to be visible to each other and be able to interconnect upon request. For this, the Eureka registration server is used (which is built into Spring Cloud).
- Second, use Spring Boot to make up a service (Account Service) responsible for managing all microservices.
- Third, build a web service responsible for accessing all microservices by applying Spring’s RestTemplate class.
Microservices in Docker
While containerization is growing in popularity these days, Docker is another trendy platform for building microservices.
The key idea of Docker is the possibility to divide each microservice into separate processes and launch every process in separate containers. To deploy the broad-scale app containers on a set of machines instead of a single machine, you can use orchestration platforms such as Kubernetes and Docker Swarm. In case your application is small, orchestration is not necessary.
Microservices in the Cloud
Running microservices in the cloud in another popular method that allows for creating and deploying lightweight programs and scaling them more easily. By using cloud platforms, you get access to managed services, on-demand resources, integrated tools such as Kubernetes or Docker, huge choice of database technologies, etc.
By deploying microservices in containers, they are all isolated and can be launched anywhere. You can also avoid using containerization. For example, the WeatherBug application runs its services directly on Amazon EC2 to ensure against complicatedness and overhead.
Key Benefits of Microservices Architecture and Drawbacks
Microservices architecture provides a set of benefits for the entire software development process as compared to monolithic architecture. However, each benefit comes with a side effect that can also impact the process. Let’s discuss all of them in detail.
Microservices Are Easy to Scale
The very first advantage of using microservices architecture is horizontal application scaling, which helps to efficiently handle the extra load.
Today, it is important for software companies to build applications that can adapt to changes and continue to work properly when demand becomes greater compared to original expectations.
For example, you have a program with two major functionalities; let’s call them service A and service B. The frequency of running service A is significantly higher than service B. You can scale service A to run on more powerful computers with many servers. At the same time, service B will run on less powerful computers. So, the advantage here is that you can add capacity to the service that needs it the most without affecting the rest of the application.
Drawback That Comes Along
To ensure adequate application performance, all microservices must communicate and exchange data when requested. As a result of focusing on separate services, network latency occurs, which means that the communication between all services becomes weak and carries lots of delays. Thus, its overall performance suffers.
Microservices Possess Improved Fault Tolerance
Microservices are, to some extent, dependant on each other while they have to interconnect to enable proper performance. When one of the services in the communication chain crashes, all of the dependant ones also go down.
When dealing with a microservices architecture, there is a possibility to implement a fallback called fault tolerance.
Fault tolerance can be implemented through Hystrix, the open-source framework provided by Netflix. Here is an example of the code.
Drawback That Comes Along
The implementation of fault tolerance does not guarantee the complete security of your application. It becomes more difficult to maintain the safety of transactions, and distributed services communication is more likely to go wrong.
Microservices Can Be Polyglot
When building an application based on the microservices approach, software engineers can apply various technologies. Each service can be built with the help of a different programming language or another version of the same language.
Applying various technologies to separate app components improves UX. Moreover, you can apply any of the emerging technologies to preserve the innovativeness of your product.
Drawback That Comes Along
Applying too many technologies within software development teams may cause problems. Poor coordination between teams responsible for maintaining different services is the biggest one.
For example, the team responsible for service A, which was built with the help of Java, can’t substitute the team responsible for service B, which was built with Python, because they are experts only in their Java field.
Microservices’ Loose Coupling
Coupling is the possibility of microservices to depend on each other. Frequently, engineers try to eliminate any coupling to make all services autonomous, which allows for independent deployment of each separate service.
As a result, the time to market is accelerated.
Drawback That Comes Along
If the communication between the services is required to fulfill an accurate request, engineers create dependencies between them.
For example, to fulfill some Order function (microservice 1), it is necessary to send a request to the Shipping function (microservice 2). Without the connection between these two microservices, the request can’t be performed. For this, a high degree of coupling is needed.
Microservices’ Continuous Delivery
To create the monolithic system, separate teams are responsible for the development of separate functions, such as server-side logic, user interface, database, and others.
To create a microservices-based application, cross-functional teams are built for handling all steps of the application life cycle by following a continuous delivery (CD) model. When developers, QA engineers, and operation specialists work together on the same part of an application, its testing and debugging become instant and easy.
Drawback That Comes Along
Unfortunately, the CD approach can’t work properly in the companies that do not stick to automation practices or DevOps culture.
Successful Cases of Switching to Microservices Architecture
Globally recognized organizations such as Amazon, eBay, Netflix, Uber, Spotify, and many others have turned their products into microservices for good reason. Let’s outline some of the examples.
eBay introduced microservices in 2011. At that point, the company had to serve 97 million users and had to handle enormous data traffic. To overcome this difficulty, eBay decided to break its platform into services. This increased employee productivity and improved product stability.
Originally, Uber was a monolith solution that offered a single service in a single location. Then, the company started to actively expand its services. Uber noticed that the usage of a monolithic structure caused many problems such as poor scalability and lack of continuous integration. This was the time when they decided to transit to microservices.
When the company approached 75 million users, Spotify understood it needed a solution that would enable better product scaling and effective support of multiple platforms to remain competitive in the market. For this, the company restructured its product and built over 800 flexible services that allowed for solving the complicated tasks.
To sum up, it is important to mention that the implementation of microservices combines both advantages and disadvantages:
Innovecs has experience in building microservices applications. For one adtech company, Innovecs developed a smart engine for automating the creation of video ads. By logically harnessing big data, the engine not only edits video clips but analyzes the effectiveness of ads impressions as well. So, take into consideration all of the points mentioned above before deciding on your future application architecture.
If you are interested in microservices application development, feel free to contact us with your requirements.