Day-39 Monolithic vs Micro-services Architecture

Which one is better monolithic or micro-services?

ยท

3 min read

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.

Untitled-2022-11-14-2122.png

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.

Advantages

  • Good for small teams.
  • All components are part of a single unit.
  • More rapid than others.

Disadvantages

  • Deployment is complicated.
  • Each server is given far too much responsibility.
  • Hard to scale
  • Release and Testing processes are bit lengthy

Micro-services โš™๏ธ

In micro-service architecture we divide monolithic model into small services like payment service, cart service, login service, etc.

Untitled-2022-11-14-2122 (4).png

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
  • Prometheus
  • Redis

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.

Untitled-2022-11-14-2122 (6).png

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?

Advantages:

  • Easy scalability
  • Independent Deploy process
  • Highly maintainable and testable
  • Flexible choices of technologies

Disadvantages:

  • High complexity
  • Maintainability
  • Sometimes higher upfront costs

Resources ๐Ÿ“–

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!

ย