Recently, Amazon Web Services (AWS) surprised many by announcing a move from a microservice architecture to a monolith architecture for their own retail platform Amazon Prime Video. This decision has sparked a debate on the pros and cons of both architectures. You can read the announcement here.
I remember this was a key discussion with student as their Technical Mentor in one of the session in the Udacity Cloud Developer Nanodegree. In this article, we’ll take a look at some key points to consider when deciding whether to modularize your application or stick with a monolith approach.
what is monolith architecture
The monolith is a type of architecture where you build and deploy your software program as a single unit. In monolith, all your application features are tightly coupled as a self-contained application. It usually result into a large computing network with one code base that couples all of the business concerns of the software application together. From the cloud perspective it means your frontend, backend, payment and other features of the application aredeployed from one source code. They probably will be in a server fleet with load balancer and an Auto Scaling group to route traffic between them.
Some of the advantages of a monolith includes:
Before we dig into my take on the AWS Microservice move, let’s take a look at some good that you can enjoy with Monolith.
Easy mode of deployment: With Monolith architecture, you can easily deploy your application as a single entity. You will not need to go through complexities of configuring different applications.
Less Overhead: Monolith can save you some overhead cost including fewer infrastructure use for a mid range application.
Simplicity Of Debugging: With Monolith, you can easily trace debug any issue that can arise from the application. This is so because all the components are in single unit.
Easy To Onboard New Team Member: Since all the components are a single unit, it is much easier for a new team member to study and familiarized with the code base. Also, you as the Cloud Engineer too will find it easier to understand the infrastructure deployment.
Testing is Easier: Since the whole application is a single unit, end-to-end testing is very much easier.
Disadvantages of monolith
Despite the advantages, some draw backs that comes with Monolith architecture includes:
Slow Development Speed: Monolith architecture often results in slower application development especially for the CI-CD. The bulkiness of the application results into longer time from compiling, building, and testing the applications. No matter how minor the change, all of the application will have to go through the devops cycle each time.
High Code Coupling: As the application grows, there is a high chances of having a very complex code that would not be easy for even the developers to understand.
Higher Security Risks as Application Grow: As the application grows, a compromise in one part of the application infrastructure will result in a total down time of the whole application. In worse case, total loss of the whole product to the compromise.
Higher Probability Of Downtime: Just like the above points, when a bug makes it into the production application unnoticed, it could result into a total downtime of the product. If the server experienced an outdate package, it could easily affect the whole application too.
what is microservice architecture
A microservice architecture is one where you decouple all the software application and infrastructure. This means each infrastructure is independent of each other, yet communicate with each other via a secure network computing. This means updating, testing, deployment, and scaling occur within each service. You can assign each service can be the appropriate amount of resources that it needs. That is why it is best model of architecture for large corporation with application that have many moving parts. And that was what AWS needed when they moved Amzon Prime to Microservice architecture. AWS address their microservice architecture as serverless architecture.
Some advantages of microservices architecture
Now let’s take a look at some of what AWS enjoyed when they deployed the Microservice architecute. Some of the serverless services they used includes Lambda, API Gateway and Dynamo DB
Flexible Scaling: With Microservice architecture, you can easily scale the resources of any of the application component. If the API is experiencing more resource consumption, you can easily increase the resources for the API infrastructure without tampering with the Admin application.
More Secure: Since microservice decouple your application, when one of the application infrastructure comes under any compromise, it does not affect the other infrastructure.
Experimenting is Easier: You can easily test new features in a Microservice architecture. This is because you have different code base for each component. Also, you deploy each component on different servers with each’s own need infrastructure resources.
Promotes DevOps and SRE Practice: The complexity of the Microservice architecture is the base for DevOps Engineers and Site Reliability Engineer to deploy continuous as a service and monitoring solution for the infrastructure. This helps to have more visibility of the infrastructure resources consumption.
Faster Time To Market: With Microservice architecture, development teams working on different microservices don’t have to wait for each other to finish before pushing their changes to production.
disadvantages of microservices
However, AWS find some of the below cons when they used the microservice architecture.
Add More Complexity To You Infrastructure: Microservice can easily spiral into a very complex architecture which can become very overwhelming when it comes to managing it.
Can Be Costly: Microservices can cost you more to implement due to the many moving parts of the infrastructure. And when you consider the security and redundancy that each component will use, it can be intimidating even for large corporations. This singular reason is why AWS moved from Microservice to Monolith architecuture. AWS says it saved up to 90% in revenue when it moved from Microservice back to Monolith.
points to consider before you make your decision
- Can you modularize your application?
One of the benefits of microservices is the ability to easily modularize an application. This allows for better scalability, resiliency, and flexibility. However, not all applications can be modularized easily. If your application is tightly coupled or has many interdependencies, it may not be a good fit for microservices.
- Consider Technical Debts
Microservices can help to reduce technical debt by making it easier to maintain and update individual components of an application. However, if you’re not careful, microservices can also lead to new types of technical debt, such as increased complexity and duplication of efforts. It’s important to weigh the benefits and costs of both approaches and decide what’s best for your specific use case.
- Who are your customers?
The needs and expectations of your customers should also be considered when deciding on an architecture. If your customers value speed and agility, microservices may be the better choice. However, if your customers prioritize reliability and consistency, a monolith architecture may be more suitable.
- How large is your application going to be?
The size of your application can also impact your decision. If your application is small and simple, a monolith architecture may be sufficient. However, if you expect your application to grow and become more complex, microservices may be more appropriate.
- What is the budget of your business to deploy the application?
Cost is another important factor to consider. It is the highlight of why AWS moved from Microservice. Microservices can be more expensive to deploy and maintain than a monolith architecture. If your budget has a limit, a monolith architecture may be the better choice.
- How Vulnerable is your application?
Security is a major concern for any application, and different architectures have different security implications. Monoliths may be more vulnerable to security breaches due to the fact that a single vulnerability can compromise the entire system. On the other hand, microservices may be more difficult to secure due to the larger attack surface and increased complexity.
Deciding between a microservice and monolith architecture can be a difficult decision. Amazon Prime Video can find it easy to migrate from Microservice to Monolith because they have the resources and human power too. And it worked for them as they said “The move from a distributed microservices architecture to a monolith application helped achieve higher scale, resilience, and reduce costs.” However, it is important to carefully evaluate your specific needs and weigh the pros and cons of each approach. By considering factors such as modularity, technical debt, customer needs, application size, budget, and security, you can make an informed decision that’s best for your business.