Rebuild those old monolithic apps using microservices architecture

Application development, for the longest time, meant monolithic architecture. It made sense to develop and deploy an application at one place and it worked just fine - until it didn’t. Digital transformations and the speeding pace of the market has made monolithic applications somewhat obsolete. Monolithic applications are based on a unified architecture. Code is usually written in one particular language and all the capabilities are very tightly coupled. Each function in a monolithic application depends heavily on the other which renders the applications extremely vulnerable to failure in case of error occurrence. Any error has the potential to bring down the complete application and tracking it and fixing it means the application stays unavailable until the error is fixed. This takes time because monolithic applications lack fault isolation.

Monolithic applications take longer to develop and deploy as all the teams have to work on the same code and working in parallel in this architecture is hard, to say the least. In the age of continuous integration and continuous deployment (CI/CD), the time it takes to develop monolithic applications makes the architecture look like an ancient artifact. Customers want faster development and rollouts of new updates and in order to do that, developers need to consider the microservices platform.

Microservices: Big promises

Recent years have seen snowballing popularity of microservices architecture. This new way to develop and manage applications has become the next big thing. Developers are fascinated by microservices because it is the solution to every problem monolithic applications brought to the table. Microservices-based applications are made of various loosely-coupled components called services. These services are separate blocks of functionality, having individual environments, that are completely walled off from one another. Each service has a particular job and is developed by a dedicated team. Services can be built using different technology stacks and communicate with each other using APIs. This means that a number of teams can work on different services in parallel making for faster delivery.

Since the applications are loosely coupled, an error in one service doesn’t affect others and ultimately doesn’t cause the entire application to crash. Also, the fault can easily be traced back to its service which the team responsible for that particular service can immediately fix making for higher application availability. There’s also the benefit of code sharing and re-usability, which means a particular service can be used in a different project which calls for the same functionality.

The big move to microservices

Microservices architecture is appealing for enterprises looking to boost their delivery speed exponentially. However, it’s not an easy job to migrate from monolithic to microservices. Doing this requires time. There’s a huge risk of failure. And, most organizations won’t find that appealing.

So, how do you make the transition without a rewrite?

The answer is refactoring the app. What you want is to take your traditional apps, split them into separate components (services), and then link them together. The front end of the application will stay, or at least feel, the same, but there will be an entire overhaul of the backend.

Road to high availability

Application modernization isn’t a quick process. Delivery teams should aim to decompose the application one feature at a time while migrating that feature into a service that makes for a seamless transition and a lower risk of failure. Let’s look at seven steps to migrate your monolith to microservices while avoiding failures.

1. Start small

Delivery teams should start with smaller functionalities of the application. These functionalities can be the ones that are relatively loosely coupled with the rest of the application. Developers can use these functionalities as a testing ground to create a continuous integration pipeline. Ops teams can do the same by creating the underlying infrastructure for these and future services. This approach reduces risk and the impact of failures.

2. Remove dependencies

The aim is to move away from the monolith towards microservices. This calls for the elimination of any dependencies of the services to the monolith. The services should be built in a way that makes them independent. Monoliths are slow and expensive whereas microservices offer the benefit of faster delivery. This is because different independent services can be developed and released quickly. However, if these services are not completely independent, it can bring the whole process back to square one since these services have to wait for the monolith.

Although, having independent services may not always be possible. Sometimes, due to the absence of clear domain concepts, services might end up depending on the monolith to some extent. In this case, developers should make sure that these services contain an anti-corruption layer so that the concepts of the monolith don’t end up leaking into said services.

3. Get your hands dirty

After decoupling initial and easier functionalities, developers will be faced with more challenging functionalities which are spread across the application. Developers can’t simply migrate those. Instead, they will have to deconstruct these functionalities and redefine them properly and gradually.

In such a case, developers shouldn’t randomly migrate these functionalities as they might lead to something that is worse than what they began with. Developers should evaluate these functions and refactor them in a way that they don’t depend on the monolith, but the other way around.

4. Consider your data

Developers will end up looking for easy pickings. Functionalities like UI could take precedence in the migration process, but the most important capability to be separated or decoupled from the monolith is the data. Centrally stored data is a hurdle in the migration and acts as a liability preventing a monolith from truly migrating because the distribution of data is a key tenet of microservices. Hence, data migration should be prioritized. Strategies should be implemented that help in data migration without interrupting crucial systems.

5. Decouple fast changing functionalities first

Developers should evaluate different functionalities and give precedence to the ones that change the most. This is because these functionaries are the ones that slow down the monolith the most. If they are decoupled, the changes can be made easily without hampering the application’s performance. With the help of business managers, developers should pick the functionalities that are most prone to changes in the future and they should work on migrating them to derive the most benefit.

6. Consider rewriting functionalities

All functionalities should be reevaluated. Developers should make sure they don’t try to migrate legacy code over to the new system. Legacy code can be years old which means it is built on outdated standards making it unfit for reuse. Also, this code may have tons of boilerplate code blocks. This code may not have clear domain concepts and boundaries. Rewriting various parts of an application from scratch will help developers follow up-to-date best practices that apply to microservices. Developers will now have the ability to choose a programming language or technology stack that best suits a particular service.

7. Don’t aim for small services from the start

It is not easy to set and maintain boundaries within a monolithic application since everything is so tightly coupled. This makes it difficult to decide how granular each new microservice should be. Developers might make the mistake of distributing their microservices into very small services. This can lead to an overly complex network of services that has high friction and will ultimately pile on a heavy management tax. Developers might find it hard to trace errors in this complex maze of services. For these reasons, it makes sense to start with services that aren't too granular, and are easy to manage. Once migrated, the services can then be further broken down into smaller services. This will help avoid unnecessary complexity and clutter.

Migrating to microservices: Take a gradual approach

The process of migrating monoliths to microservices is not easy. Delivery teams should be prepared to take on the task of gradually migrating the applications so that the transition is seamless. This iterative approach will ensure that every new increment brings organizations a step closer to their goal - agile, distributed apps built according to the microservices architecture.

Featured image: Pixabay

Twain Taylor

My interests lie in DevOps, IoT, and cloud applications. I began my career in tech B2B marketing at Google India, after which I headed marketing for multiple startups. Today, I consult with companies in The Valley on their content marketing initiatives, and write for tech journals.

Share
Published by
Twain Taylor

Recent Posts

Hardening your technology infrastructure in preparation for a DDoS attack

By establishing these 11 appropriate controls beforehand, your organization will be better positioned to withstand and survive a DDoS attack.

3 hours ago

Microsoft App-V as an application virtualization solution: Pros & cons

If your shop is considering using App-V as an application virtualization solution, read this article first and weigh the pros…

6 hours ago

Ransomware threats: Cybercriminals take their wares to the next level

As companies and individuals harden their defenses against ransomware, hackers are creating new and more virulent ransomware threats.

23 hours ago

AWS vs. Google Cloud: After a big 2019, what does 2020 hold?

AWS is the public cloud market leader. But Google Cloud is catching up. One thing is sure: In the AWS-Google…

1 day ago

7 web design principles that are crucial to know for 2020

What is going to be significant in the world of web design over the course of 2020? Let’s take a…

1 day ago

Mobile device management with Microsoft Intune: An introduction

Microsoft Intune is a great and powerful tool. Here’s how to use it for mobile device management to keep track…

2 days ago