Before diving into Docker in depth, let's first define monolithic and micro-service architectures. We will also know why micro-service architectures are most preferred in current times.
Monolithic Architecture 🏢
You can consider this a single code repository where all of your code resides. It is a traditional model of software program that is built as a unified unit that is self-contained.
Consider the Amazon website as an example. Before 2008, Amazon had a monolithic architecture where their data and applications were on private servers. During the holiday or festival season, their site faces a higher amount of web traffic. Due to this, the site also had to face downtime.
To solve this problem, they have to purchase new server machines, and you already know that this is a very costly solution and that it also wastes your resources. Except during the holiday or festival season, your extra servers are idle because traffic is low, so they are squandered.
- Good for small teams.
- All components are part of a single unit.
- More rapid than others.
- Deployment is complicated.
- Each server is given far too much responsibility.
- Hard to scale
- Release and Testing processes are bit lengthy
In micro-service architecture we divide monolithic model into small services like payment service, cart service, login service, etc.
As you can see in the above diagram, different parts of a single monolithic model are converted into microservices. These services are connected to an API Gateway which routes your requests to different services.
To understand it better, let's again take the example of the Amazon site. After facing lots of scaling issues with monolithic architecture, Amazon decided to switch to a micro-services model. There are many ways and technologies to convert your monolithic architecture to a microservices model.
- Docker + Kubernetes
- REST API
As a result, Amazon's problem during the holiday and festival seasons is now solved by using microservices. Let's say they divided their every service into containers( We will see what is container in next blog, for now consider it as small box containing service code and configurations).
We have three main containers: payment, cart, and login. In the holiday and festival season, people like to buy new things, so they go to the Amazon site and purchase gifts and accessories. So the majority of the traffic will be on cart and payment services.
But you have converted services into containers, so if any service faces a higher load, you can double the number of containers of the same service and divide the traffic among them.
This is something you can do using Kubernetes. You can either scale it vertically or horizontally. When there is no load, you can delete extra containers. How simple is that?
- Easy scalability
- Independent Deploy process
- Highly maintainable and testable
- Flexible choices of technologies
- High complexity
- Sometimes higher upfront costs
- Advantages of microservice architecture
- All about microservice architecture
- Monolithic vs Microservices
Okay, that was all about monolithic and microservice architectures. Docker commands will be covered in our next blog post, so till than stay tuned.
Did you find this article valuable?
Support Shivlal Sharma by becoming a sponsor. Any amount is appreciated!