Professional Documents
Culture Documents
Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 1/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
https://medium.com/system-design-concepts/monolithic-
architecture-51272d0b3393
https://medium.com/system-design-concepts/microservice-
architecture-47e9581f8be9
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 2/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
protocol(as they are Single purpose, do one thing only e.g REST/HTTP,
RPC). These services are also deployed separately and not dependent on
any other service/s.
Monolith is the way of developing an application where all the modules are
built into one big application and are deployed together. The advantage of
this architecture is that they are simple to develop, deploy, and scale. It gets
complex when the customer base increases. Drawbacks are technology
dependency, engineering focus, scaling data layer not easy, overloaded
VM/container, understanding of code base, and many more.
FUNCTIONAL DECOMPOSITION:
A technique where we break down the application into smaller modular
pieces. How do we do this? We decompose the application based on the
functional areas like search, payment, product, shipping, authentication,
and other functional areas into their own microservices. These are now
granular service deployed independently and all of these has their
individual codebase. They can be scaled horizontally based on traffic/load.
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 4/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
Monolith vs Microservices
In the above picture, the left side of the dotted line depicts monolith
architecture where all the modules i.e search+product, shipping, and
notification are bundled together, have one common code base, and are
deployed together on one server. When the shipping module wants to
interact with the notification module, it can make a simple function call.
Also, these modules share one common DB, which can be RDBMS or
NoSQL.
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 5/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
The Right Side of the dotted line depicts microservice architecture where all
the services have their own codebase (can be written in different languages
say search+product in java, shipping in python, and notification in
golang) and each one of these microservice has its own DB. The Advantage
of this is that it gives us the freedom to have our choice of DB as per our use
i.e for search we can use elastic, for shipping we can have any NoSQL say
mongo DB, and for notification, we can have RDBMS(oracle). If the
shipping service wants to interact with the notification service it makes a
rest call/RPC call to the notification service.
As we can see in the second scenario, scaling is easy i.e if more and more
user is performing only the search operation in our application we can scale
“search+product” without touching/affecting other services, deployment
is easy, no dependency on technological stack among services, loosely
coupled i.e changing one part of code won't affect other, and easy to
understand(one can focus on the service he/she is deveoping).
Disadvantages include interprocess communication ( Call using REST
API), distributed transaction(Will discuss this later in more detail), more
resources, and debugging issues.
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 6/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
In the previous blog, we have already gone through the scaling cube concept. I
am attaching the link herewith. Happy learning!!!
Microservice Architecture
Melvyn Conway, 1967i.
medium.com
API GATEWAY:
In a typical e-commerce application, we can see product details, reviews,
ratings, price, frequently together bought item, merchant details, shipping
information.
Direct calls where front end/client calls all these services one by one or
parallelly i.e 7 different calls to get this info. It’s not the best way of doing
this. It would have an impact on load and time.
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 8/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
Diret call
API GATEWAY: Another way is using API gateway i.e between client and
these microservices there’s one more service “API GATEWAY” in the same
network as these services (hence reducing the calling time). This service
internally can call these other 7 services in any order. It is much faster than
the above approach.
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 9/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
Api gateway
Advantage:
Disadvantage:
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 11/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
BFF
Here we have three different API gateway for three different purposes. If
the requet is coming from the web application then all calls will get
redirected to API gateway for web and in the case of mobile application and
third-party users, all the calls will get redirected to the respective API
gateway as shown in the above image. This way we can compose different
responses for different types of clients using the same microservice. Also,
we can track and rate limit the 3rd party API usage. one API gateway can be
for android and one for IOS as well.
SERVICE REGISTRY:
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 12/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 13/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
These are the problem which we will solve using “service discovery”.
The question here arises that how service registry will get to know the latest
network address of any microservice?
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 14/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
This answers “There can be the situation where the “shipping” service
wants to interact with the “merchant” service. How will shipping service
get to know about the IP address of the merchant service?”
The client can now request service registry and gets the list of network
address lets say ip1:<port1>, ip2:<port2> and ip3:<port3> in case of
merchant also load balances the requests among these machines. client
can’t keep on talking with service registry every time if it needs to interact
with microservices, there will be a designated TTL. What will happen if the
service registry updated itself but at the client end information still is not
updating. This is one disadvantage of talking with services directly and is
not advisable. Also, traffic on the service registry will be high as clients keep
asking for the latest data continuously. This is what the client discovery is.
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 15/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
Service Registry
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 16/17
12/12/21, 12:26 PM Microservice - Deep dive. Prerequisite: we have learned in… | by Jolly srivastava | System Design Concepts | Medium
Stay tuned!!!
https://medium.com/system-design-concepts/microservice-deep-dive-c100f641db73 17/17