What are Microservices ? | Monolith vs Microservices | Microservices communication in Node.js

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hey what's going on guys welcome back to  another video so in this video we will   learn about Concepts like what is monolithic  application how they are built and deployed and   what are the pros and cons of using it we will  see how microservices architecture solves the   problem and what are the different solutions  available to communicate between the micro   services with their pros and cons so there's  a lot of things to learn in this video so if   this sounds interesting then stick around  also don't forget to subscribe the channel   and press the Bell icon so that you don't miss  the videos like this one so let's get started all right guys so today's video is sponsored  by Zegocloud. Zego cloud is a global Cloud   Communication service provider which provides  developer friendly and Powerful SDK and API to   build many communication features on the app such  as video call chat video conference live streaming   and many more Zego cloud is trusted by more than  4000 businesses and offers pre-built UI kits and   sdks to developer and businesses recently they  have introduced their pre-built UI kit and UI   components that help in building and shipping  apps to the market in the shortest possible   time instead of building everything from the  ground up these UI kits suited for testing tools   building MVP for funding or in-app plugins to our  existing app it's less time consuming economical   and we just need to focus on the Core Business  use video call kit and build features in no time   with less complex coding it offers various UI  components with easy integration and flexible   and enough to handle most of the requirement the  UI kits covers the need of various industry and   offers features like one-on-one calls group calls  video conferencing live streaming live audio room   in app chat and here are some of the pre-built UI  kits which you can explore and you can see that   how fast you can build feature-rich apps with less  coding you can start building your apps by simply   signing up to the Zego cloud and you can get 10  000 minutes free so you can just click on the   start building and then you can just do a sign up  and once you sign up you will see this console so   you just need to click on create your project you  need to select which feature you want to build in   your application and then you give your project  name and you will forget all the configuration   related to the project you will also find a lot  of tutorials how to build the features like how   to make webrtc video call app how to use iOS call  kit for video call and you can sort it based on   the language so if you need for JavaScript you can  just select JavaScript and you will find all the   tutorials related to the JavaScript so I highly  recommend to use the UI kits and give a try to   build the features in your application alright  guys so in this video we are going to understand   about monolithic architecture and how monastic  applications are built in node.js so in node.js   a monolithic application is usually refers to an  application that is built a single large code base   and typically it uses a single process or a thread  in monolithic application all the components of   the application are very tightly coupled and  they run with a single process and this makes   it difficult to scale and modify individual  components independently let's understand this   with the help of a diagram so we will see that we  have a monolithic architecture based application   and this application is being used by the users  so users connect with this application as this   application offers some services like customer  service product service card service and all these   services are very tightly coupled as a customer  service will always call the order service to get   the orders of of a particular customer or a card  service to check the card of a customer and all   these Services is connected to a single database  so now let's see how this monolithic applications   are deployed so in a monolithic application  the entire code base is typically deployed as   a single unit and this makes very easy to deploy  and manage but as the application grows it becomes   increasingly difficult to maintain and scale and  this is because that all the components of the   application are closely integrated and any changes  or updates can affect the entire application let's   understand this with the help of a diagram this  was our application and now we want to deploy this   application so whenever we want to deploy this  whole application we need to make some artifacts   so let's create a zip file of it now we need to  deploy this ZIP file into the server so we see   that we have the zip files and now we will deploy  it on different multiple servers so this way the   whole application code base is deployed as a  single unit but this monolithic architecture   comes with some pros and cons let's take a look  at the advantages first so the First Advantage   is Simplicity in monolithic applications are  simple to develop test and deploy as they build   as a single unit and this makes it easy to manage  and maintain the application the second benefit is   the cost effective since monolithic applications  are built as a single unit there is a less need of   complicated architecture and it is easier to  deploy and maintain making it cost effective   and the third one is the easier debugging with  monolithic applications it is easy to track down   the bugs since all the components are in one  place and making it easier to debug but with   this advantages there are also few challenges  while using monolithic architecture so let's   take a look on that the first one is the limited  scalability as monolithic applications can be   difficult to scale since all the components are  very tightly coupled and make it challenging to   scale individual components separately the second  is single point of failure since the applications   are deployed as a single unit any failure in one  component can affect the entire application and   making it as a single point of failure there are  some maintenance issues as the application grows   it becomes increasingly challenging to maintain  since all the components are tightly integrated   any changes to any of the component we need to  take down the entire application and this makes   it challenging to maintain and the last one is  the technology lock-in monolithic applications   are typically built using a specific technology  stack making it difficult to switch to other   Technologies as the application grows now with  this advantages and disadvantages there is a   general rule of thumb that in which cases we  can use the monolithic architecture to build   applications so we can make the monolithic  applications are best suited for small and   medium-sized projects with simple requirements  where scalability is not a concern however for   large and more complex projects that require  scalability and flexibility a micro Services   architect texture is preferred so the summary  is the monolithic applications can be simpler   to deploy and manage initially they can become  increasingly difficult to maintain and scale   as the application grows and to address these  issues many developers are now moving towards   the microservices architecture all right guys so  in this video we are going to discuss about what   microservices architecture is and how we build  applications using microservices architecture in   node.js so in node.js a microservices architecture  is an approach to application development   that involves breaking down a large complex  application into smaller independent services   and those Services can be developed deployed and  scaled independently each of the microservice is   responsible for a specific functionality of the  application and they communicate with each other   through well-defined interfaces usually using  rest API or message queues let's understand   this with the help of a diagram so this was our  application which we built using the monolithic   architecture now we will see that how we can  transform this application into a microservices   architecture so we are going to break down this  complete application into smaller projects or into   smaller microservices projects so let's see so we  have now three smaller projects one is the user   service product service and Order service and  all these three are the microservices and they   have their individual database so if we see about  the user service then this has a very specific   functionality or the apis which are related to the  users similarly for the product this microservices   is only responsible for the product services and  then we have the order Services now as these three   are separate projects their endpoints and the  ports will also be differ so the user will not   communicate to these Services directly so for  that we are going to have a proxy or an API   Gateway which is going to have a single endpoint  with the port that can communicate internally with   any of the services based on the user query so the  user will communicate with the API Gateway and in   the background we are going to have different  Services which will interact with each other   so in this way all these three services can be  built with different technology as they have   their individual database and they have their  specific functionality so it's not dependent   on a single technology stack so in microservices  architecture each microservice can be developed   and maintained by a separate team and can be  deployed and scaled independently this provides   more flexibility and scalability compared to the  monolith architecture where all the components   are tightly integrated and any changes or updates  to any of the component we need to bring down the   entire application now let's see how we deploy  this so we have three different micro Services   here in order to deploy them we are going to  deploy them individually so we have different   pipelines for each of the projects so we are  going to create the artifacts or a zip first   all right so now we have three different Zips user  zip product zip and Order zip and all these three   are independent of each other other so if we want  to deploy them we are going to deploy them in the   server with three different pipeline or we can  also have a single pipeline which will have all   the three so it's really depend upon our use case  next let's see that if we have any changes in our   user service then how we can deploy this so you  will see that this are three micro services and   now we have some changes in the user service so  we are going to update some changes and then we   are only going to create a zip for the user  service since product service and the order   service doesn't have any changes we don't need to  deploy them and they will work as independently so   we have created the new user zip and then we are  going to ship that user zip to our servers so this   really helps us with the flexibility you don't  need to bring down the entire application and   it's not a single point of failure but with this  microservices architecture we do have some pros   and cons Let's Take on the advantages first so  the First Advantage is scalability microservices   can be deployed and scaled independently and this  makes it easier to handle High traffic and spikes   in demand second one is the flexibility so each  microservices can be developed and maintained   independently allowing for more flexibility  and Agility in the development process next is   the Fault tolerance since each microservices  is developed independently a failure in one   service does not necessarily affect the entire  application and making it more fault tolerant   and the last one is the technology Independence  each microservice can be developed using different   technology stack allowing for more flexibility  in choosing the best tool for the job now let's   discuss some of the challenges that we face while  building the microservices application so the   first one is the complexity managing multiple  Services can be complex sometime then managing   a single monolith application testing can be more  complex in microservices architecture as multiple   Services need to be tested independently and as  a whole and the last one is the deployment so   deploying multiple Services can be more complex  then deploying a single monolith application so   in a summary microservices architecture in node.js  is a powerful approach to application development   that can provide greater scalability flexibility  and fault tolerance compared to the monolith   architecture however it also introduced some  additional complexity and challenges that needs to   be addressed to ensure a successful implementation  alright guys so now we already know what the   microservices architecture is and how we implement  the microservices now the other question is how   these micro services will communicate with each  other so let's say that if a customer service want   to have a communication with the order servers  in order to know the order of a customer then   how they are going to communicate so in node.js  there are several ways to implement communication   between microservices depending on your specific  requirement and the architecture so here are some   of the most popular that we are going to discuss  and the first one is the HTTP rest API so this is   a synchronous way of of communication where each  service will wait for response from the other   servers and each service exposes its functionality  as a set of restful endpoints that can be accessed   by other microservices using HTTP request let's  understand that with the help of a diagram so here   you will see that we have four different micro  services customer service product service card   service order service now all these services  are exposed with a rest API endpoints so you   will have the customer slash customer customer ID  so customer is the entity for the orders you have   the order as entity products and cards where  you can build your rest in points so now if a   customer service wants to access the orders then  it will send a HTTP call with a rest client so we   will have an HTTP request now the order service is  going to respond in HTTP response to the customer   service and in this way they can communicate with  each other similarly if a product service wants to   communicate with the card service then they can  send the http request response now in node.js   there are a couple of HTTP clients that we can use  the first one is the axios the second one is the   fetch then we can also use the got package we can  use the super agent and we can use the KY so these   are some of the popular HTTP client libraries  that you can use in order to use the https DPI   communication between microservices the second  popular choice is the message queues so message   queues are a good option for asynchronous  communication between microservices each   microservice can publish a message to a queue and  the other microservices can consume those messages   from the same queue so you will see here that we  have four Services the same four services and in   this case we are going to have a message broker in  between them so they are not going to communicate   directly but they are going to communicate via a  message broker and the message broker is going to   have some message queues inside that so in this  case you will see that a customer wants to access   the cards so customer service will communicate  with the card service so the customer service   will be a publisher and the card service will be  a subscriber and the customer service is going   to publish a message to a message queue and then  this message will be consumed by the subscriber   so you will see that the card service is a  subscriber and it's consuming the same message   via messaging queues so there are some popular  message Brokers which we can use and those are   the rabbit mq Kafka AWS sqs third popular way of  communication is the remote procedural call and   it is developed by Google so it says grpc. Grpc is  a high performance RPC framework that uses buffer   protocols for serialization and supports multiple  programming languages including nodejs with grpc   you can Define services and messages using buffer  protocol and generate client and server code for   communication between microservices the best  part of this grpc is that it's using HTTP 2   protocol in order to transfer for the data and  it is five to seven times faster than using the   normal rest API calls with HTTP let's understand  how this grpc call works so you will see that we   have two Services we have the customer service  we have the order service and then we are going   to implement a grpc client and a server so you  will see that we have a grpc client which is a   customer service who wants data from the order  service which is the grpc server now in this   client and the server there is a communication  via HTTP 2 and this happens at a transport layer   in the form of a protocol buffer so the data will  be sent in the form of a binary so that's why it   is more faster than the normal rest API calls  so let's understand that how this communication   happens from a client to server so whenever a  client is implemented generates a client's Tab   and have a grpc runtime and the transport layer  protocol we have so the grpc client is going to   decode encode and have a client Line stop which  is then passed to the grpc runtime then it passes   that information or the messages to the transport  layer and then it forms in the form of a protocol   buffer it then passes with the help of an HTTP  2 protocol to the order service which can comes   to the transport layer then it comes to the grpc  runtime and we get it to the grpc server now the   server in return will response and can generate  the encoding decoding and then give the response   back in the same flow so you will see that we have  the response back from the server to the client so   this is how the communication happens with the  help of grpc between the micro Services now in   summary when choosing a communication method  for your microservices it is very important   to consider factors like performance scalability  reliability and the ease of implementation [Music] foreign [Music]
Info
Channel: Dipesh Malvia
Views: 4,395
Rating: undefined out of 5
Keywords: microservices, microservices architecture, what are microservices, monolithic vs microservices, monolithic architecture, microservices communication, what is api gateway in microservices, nodejs microservice example, microservices with nodejs, introduction to microservices, dipeshmalvia, microservices tutorial, monolith to microservices, why microservices, microservices benefits, how microservices work, communication between microservices, how microservices connect with each other
Id: A0d9JGgFPNQ
Channel Id: undefined
Length: 17min 44sec (1064 seconds)
Published: Thu May 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.