Microservices: Modernizing the Monolithic Legacy

Reading time: 6 minutes

IT teams always want to build new applications enabling specific functions to ease processes or customers. To balance projects, they sometimes allow distributed teams to work on focused targets using reusable assets, templates, and best practices. While decentralizing and democratizing application development helps, managing security can be a task for strategizing different Lines of Business (LoBs) and functional business partners.

Enter microservices. They are supposed to be the next great leverage of modern and lucrative businesses. What are they exactly and how can you use them to work to your advantage?

 

What Are Microservices and Where Do They Originate?

It was a natural course of evolution in the software industry that pushed microservices to the top of the list. Whereas there are scenarios where the more orthodox monolith and service-oriented architecture (SOA) are applicable and more beneficial, for most of the dynamic and fast-reacting business microservices remain the preferred choice.

So, what is wrong with monolith and SOA? The problem behind the traditional multilayered monoliths is that their components are tightly coupled, they depend on each other. Changes are usually expensive, and hard to implement, and deploying them to the end-users takes lots of time.

Compared with a monolith, service-oriented architecture is a milestone step towards flexibility and dynamic. Besides offering better scalability and decoupling, modifications, testing, and deployment are less costly in time and money; however, the components are led by a central, governing module. This can be an advantage or disadvantage, depending on the project.

Microservices are decentralized, the components cooperate and exchange data, but are independent in their tasks. This way, the system is resilient. In case of a failure of one component, in most cases, the others can continue delivering services. There is no need for messaging middleware between the components since they use mutually comprehensible APIs, not a specific programming language. Because of that, adapting new or mixing multiple technologies into the project is relatively easy. All of those characteristics make microservices that powerful in their flexibility.

The goal of microservices is to create a harmonious ecosystem of small components, each with well-defined responsibility and light-weight communication.


Microservice Architecture

Individual microservices are a great fit to follow unique – or specific – business use cases. Each microservice can be implemented in any language or framework. Indeed, the only thing that matters is the service’s API.

As a result, the most important thing to decide about your microservices architecture is not how each service will be implemented. Instead, focus on how those services will communicate (synchronous, asynchronous) and what protocol they’ll use to do so (REST, message queues, etc.).

Within each service, there is an API gateway, the service’s business logic, and the service’s datastore. Also, most architectures include some load balancing solution that knows when and how to spin up a new instance of the service in cases of high request volume. The microservice is a self-contained mini-application that handles only one business case.


Making Microservices Work in the Real World

Microservice implementation will be different for every company, but the challenge of making the switch is worth the reward. Most often, the best way to implement microservices is to gradually separate parts of your application into new services. As a result, developers can work on separate business concerns in parallel, making your application more resilient and less reliant on proprietary solutions since components can easily be swapped out.

Before starting your first microservice, consider whether the architecture can contribute to the business. So, where do you begin…

 

Pros

  • Scalability – Arguably the biggest benefit. Acquiring or limiting your number of resources to critical components like computer power, memory, servers and generally adjusting to the business’ growth is driven by analytics which will quickly identify priority candidates for scaling up.
  • High availability – The servers remain responsive and users are bound to receive answers promptly.
  • Reliability – Microservices are less prone to failure in comparison to other architectures.
  • Flexibility – Modifications are fairly easy and cost-effective to implement and can easily merge into the existing product. The impact of changes on the other components is often minimal.
  • Direct communication between components is achieved via language-agnostic API — The most popular means are RESTful APIs and HTTP protocol, which are fast and efficient. Exchanging data is achieved via lightweight formats like JSON.
  • Fast Continuous deployment — Instantiating the new version of a microservice and retiring the old version is fast since there are few dependencies between components.
  • Fast development — Understanding and maintaining a set of smaller projects, each with well-defined responsibilities, is less demanding, making the plunge into the project for the new team members smoother. Granularity can also boost productivity, although productivity hits a wall when a certain number of services are reached.
  • Team autonomy — Well-separated components are divided between independent teams.
  • Effective human communication — Naturally, a microservice team will be relatively small, making communication easy. Often a team is fully responsible for end-to-end development, creating an environment where most developers thrive.

 

Cons

  • Following messaging flow – Dealing with complexity is unavoidable. When a greater number of components reach a certain threshold, it is hard to follow the flow of calls between them. When data is exchanged and modified through many services layers, finding bugs can become cumbersome.
  • Possible latency – If messaging between the components creates a long chain (eg. data has to go through four services before reaching the client), the calls may accumulate and take more than expected to reach their final destination.
  • Consistency — The latest updates may not be available immediately. Accessing data storage is a complicated beast and microservices architecture usually requires various techniques such as sharding (dividing data into many databases with possible duplicates). Duplicates may not at all times contain the latest changes leading to a conundrum: Compromise consistency of data over availability?
  • Transaction safety is hard or impossible to achieve — Delegating data between many receivers can often create undue headaches in tracking down changes made to data.

 


Microservices Pay Off

Used effectively, microservice architectures allow you to scale your application as the number of developers working on your application increases. The key is to build applications without creating a complex, unwieldy beast at the macro level. That means keep tracking each time a new service is added to your system or a new connection between microservices is made.  It also means examining the complexity increase and making sure it is warranted and well understood. Regularly examining the entire application system is critical to keep an interconnected set of microservices working effectively and reliably.

You should consider microservices if:

  • You need to deploy often, even daily.
  • You need frequent releases/updates of services.
  • You have a solid knowledge of your domain and market.
  • Your business is expected to grow rapidly and on a huge scale.
  • The business functionalities are well-separated, they are not interwoven.

Microservices will do more harm than good if:

  • Your business is small or it is a startup.
  • The business functionalities are tightly interwoven.
  • The predicaments about business growth are uncertain.
  • Consistency of data is a requirement (the requests have to always retrieve the latest data).



Wrapping Up

The road to microservices is paved with good intentions. But more than a few teams are jumping on the bandwagon without analyzing their needs first. Microservices are powerful. They should be in your toolbox! Just make sure you consider the tradeoffs. There’s no substitute for understanding the business drivers of your applications; this is essential to determining the proper architectural approach.

 

Build and host a low-code API 

Sign up to our Newsletter