DEV Community

Cover image for Microservices vs Monolithic Architecture: A Practical Approach
Lovepreet Singh
Lovepreet Singh

Posted on


Microservices vs Monolithic Architecture: A Practical Approach

πŸ“ Monolithic and Its issues

πŸ™‚ When we start learning backend development and implementation, many of us implement all our functionalities in one codebase. Forex. If we want to build the backend of an e-commerce store then we can go with the project with a single index.js file including the functionality of:-

  • Shopping Orders
  • Items or Products
  • Payment
  • Store
  • Wallet
  • Cart

πŸ™‹ But is it right to do so? We do have the advantages of the monolithic architecture like easy testing, and easily deployable. But we do have some issues like scalability, load balancing, and error handling.

Microservices meme

🎯 With Microservices we can address these issues and we also can use some of the advanced technologies like Docker, Kubernetes effectively.

πŸ“ Microservices

Microservices example

🎯 Microservices architecture includes working of separate services that are loosely coupled and work on different ports and with their own database generally.

😌 Let's take an example of an eCommerce app with payment, product, and shipping service. It may look like this:-


--> Used:- JAVA, MYSQL
--> Working on:- PORT 3001
--> Used:- NODE, MongoDB
--> Working on:- PORT 4000
--> Used:- Python, SQLite
--> Working on:- PORT 3002

πŸ™‚ Now these services can communicate with each other using APIs and all. We have the advantages of load balancing, error handling (If payment service fails it will not affect the product service), and modular code with this architecture (Microservices).

πŸ“ Microservices Patterns

πŸ”₯ While we implement microservices, there are some patterns like using BFF (Backend for frontend), Service Discovery

BFF (Backend for frontend)

API Gateway

πŸ‘‰ Here, we have API Gateway that handles all the stuff like Authentication, load balancing ,etc and act as a reverse proxy to accept the incoming requests and gives the appropriate results.

Service Discovery Registry

Load balancing in Microservices

πŸ‘‰ It is used when we have multiple instances of a service and we get the address of the particular instance from the service discovery.

πŸ™‚ Note:- We will see the implementation too, Don't get panic if you are not able to understand fully.

Inter-Microservice Communication

Inter Microservices communication

πŸ‘‰ This is one of the method where we can make calls between the services. You can make Sync calls or Async calls depending on the functionality. Here, we have used the Queue where the messages will be passed from service 1.

Circuit Breaking

Circuit breaking pattern

πŸ‘‰ This situation arises when one or more calls fails in between and other keeps waiting. forex. Service2-->Service3 call fails and Service 1 will keep waiting. In that case, we can do following:-

  • Use the last recent call stored inside the cache from service 2 and 3 and give the response
  • Fallback call:- It is the case when Service 3 calls another third party API and waiting for a long time. Then Service 2 can directly call to that 3rd party API

Log Aggregation Pattern

Log storing

πŸ‘‰ It is the Pattern where we store all the logs of our active microservices so that we can track and monitor them



πŸ‘‰ It is a cloud computing application where we can use Functions that triggers while we call. These functions do have a cold start time though but might be very effective in most of the applications.

πŸ”₯ Follow for more. We will see the implementation in our next Blog. Share this series and drop your views

Top comments (17)

ajimenezsa profile image

Thanks for sharing.
I would add a mention about the difficult introduced by microservices in the transaction management.
Think about an aborted paiment and the product stock control.
Surely this problem needs a complete blog entry to talk about it.

t0nyba11 profile image
Tony B

If you hit that problem in your design, it is usually a sign the design is wrong. There are a lot of good talks/videos on that topic. Best to avoid distributed transactions altogether.

ajimenezsa profile image

I'm not talking about a problem in my design. It is a problem in Microservices architectures.
It is covered for example in "Microservices Patterns" book, "Managing transactions with SAGAS". This is because I mentioned it, to add more information to your entry. 😜

Thread Thread
t0nyba11 profile image
Tony B • Edited

No, you are missing the point. What I mean is a great number of experts suggest avoiding that problem entirely, and altering your design to make distributed transactions not needed in the first place. They are not worth the cost/benefit.


"Distributed Transactions in a Microservices World" by Sam Newman
"Avoiding Distributed Transactions in a Microservices Architecture" by Matthew Skelton

and many more

Thread Thread
ajimenezsa profile image

I'll review it. Thanks for the clarification. πŸ‘πŸΌ

izio38 profile image

There are errors in this blog post, at a point that this is not serious.

Docker is not magically 'effective' because a team swaped to microservices.

This article promote microservices as if it was a magical response to the every day issues.

Note to readers: If your team is less than 20 tech people, and you are setting up a micro service architecture, then stop, micro services has many pros, so do monolithic.

tamusjroyce profile image

I can’t wait until everyone stops using these terms. And instead learns hexagonal architecture vs n-tier vs workflow architecture vs plethora of architectures out there.

Only the Linux kernel 1.2 was large enough and not modular to be called a monolith. If you modularize, by definition not a monolith!

Rest endpoints + gateway is not an API! Unless your modules can use more than http. When that happens, even grpc or dynamic linking, no. No longer do have a microservice. You have an API.

There are some great points made. But please apply them beyond the two naive

omars profile image
Omar Shaban • Edited

Microservices is a hype by big-tech to drive people towards managed/serverless services, or dive deep into a rather unneeded complexity on your own, in most cases you need SOA, clean design in general pays off big time, but this increases in complexity exponentially. Hopefully the world would understand one day what is a hype

sweetestshuga profile image
Eze Sugar πŸ‘©β€πŸ’»

If we have databases for each service and one service handles users register and authentication, how does we duplicate this user information in all the database to give the permission across all services

light_seekern profile image
Taha Syed

Good 😊

fruntend profile image

Π‘ongratulations πŸ₯³! Your article hit the top posts for the week -
Keep it up πŸ‘

jwp profile image
John Peters

Microservices are the end to traditional back-end architecture. Today it should be cloud-endpoints only.

410nidhi profile image
Nidhi Upasani

Very Helpful. Thanks :)

vaibhav68849256 profile image
Vaibhav Khandare


nikki_eke profile image
Nikki Eke

Wow. Thanks for sharing.

rubenruvalcabac profile image
Ruben Ruvalcaba

Excellent concepts and overall explanation, can't wait to next articles on the serie

Can you consider scenarios for distributed transactions across services?


An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<