In this session, let us get an introduction to micro services. micro services is an architectural style, which helps to develop software applications as a set of loosely coupled services. Let me explain this with a simple example. Say you want to create an online bookstore, what are the things you will consider you need to consider orders considered inventory then you need to consider the shopping cart the user details then the buyer details seller detail I mean user is the buyer then seller details, all these in our case till now whatever we have done, we have compressed it into a single functionality. That is we had a presentation layer and the business logic which was compressing all the stuff. I mean the inventory order cart history seller bias All the functionalities were compressed into a single business unit which are connecting to the database.
But when you say micro service, I am going to create the much separate service that has all the details will be in order service which is going to express itself after the CPA. You have already learned how to export an application as Sapa so what I will do I inventory I will export this as an Sapa order Sapa so I mean, Carter Sapa user service or Sapa so when I want to create an online book application in this scenario, I'm not going in for a monolithic application with one simple presentation business logic and the database but they are going to be loosely coupled services. Each service is going to take care of its own functionality, and each service is going to run in a separate process. Of course, you know that when we were working with ref JPA, it was running in a separate process. It was running in its own server, right.
So here also, when you say micro service, if you want to develop a software application, you're going to create it as a set of loosely coupled services, multiple services compressed together into a single application. So here, a single application as a suite of small services, each running in its own process, each service taking care of a particular business functionality. These services are exporting their methods are Sapa some micro services may expose the risk our message based API. So when you want to develop a software application, instead of going in for a monolithic application, you can prefer micro service architectural style, which is going to develop the application as a set of multiple services. Now, let's understand the difference between monolithic and micro services. In case of monolithic application, the modules are tightly coupled when I say modules they are nothing but our module user modules set by or more I mean a cart module is a module, then then what else in mentary module are these modules are tightly coupled into a single unit in case of micro services, each module is a service now, they are running in their own process, you can run the process that is you can make the process up or down based on your requirements.
And in case of monolithic the presentation, the business layer the integration layer are combined to one unit that is you are going to generate one WAR file and you will deploy it in case of micro service. Each functionality is a service that's what I told you got service order service Inventory Service. So, one functionality I have done Step and convert it into a service. These services talk to each other. And for one service itself, you will be having a group of front end developers people working on the business part and the back end database part. I hope it is clear.
In case of a monolithic application, you will be adding front end developers, then the people who are working in different modules of the business logic and people are working in the database part. But when you come into micro services, each service has a business functionality. So you will be having few people working in front and back middle back, I mean, the business logic and the database, but let me show you a pictorial representation here. In this case, you can just see, this is the date this is monolithic. And this is micro service. In case of monolithic, you can just think I have one database, of course, multiple put together here.
This is the business logic, and this is the front end. So here the complete application is deployed as a single Was file. In this case, there are different services use a service, cart service, other service and I mean Inventory Service like this. They are, they have their own database, they are deployed as individual instances, and they can talk to each other. Using this template. Already we have learned how to access our SMP API, we need to create an application and we have to access the REST API using rest template.
So same thing only we will be doing if I if I'm creating an online book app, I am having multiple services. If order service wants to connect to the Inventory Service, they are not going to have an object of Inventory Service something like that, using rest template or the service will connect to an inventory service that you will not be using the interfaces are the classes of Inventory Service in order service directly. But in the scenario, there are modules. Basically you create different packages and so on. To call one interface from another interface that is how you work in a monolithic application. In this case, if one service wants to talk, talk to another service, you use this template, identify the URL, call it directly see few examples of micro service.
This is an example for online stores. When you want to create a faster application for an online store, first you identify the services that are available. So here I have identified order management, Product Management, delivery management, inventory management, you can come up with your own services, each service will talk to another service using this template, it is not only with the rest template, there are few other ways which we will be using to connect to other micro services. One more example of a micro service here I have got a book application. I mean, yeah book a book application or an online shopping application only. You can see this as a shopping cart UI.
And these are all the services catalog order uses. Either they can have their own database or they can use Same database, all these services should register themselves to the service registry only then it will be visible for other services is our services has not registered itself to service registry, it will not be visible for these two micro services okay. This is a basic example what they have given what are the real time examples, what are the sites that are really using micro service architectural style. So, these are the websites which are really using micro service architectural style. Initially they were using monolithic architectural style. Now, they have shifted to micro service architectural style, Netflix, Amazon, eBay, Twitter, PayPal guild and much more.
Let us also talk about the benefits of micro services modular in nature. Each service is modular. Of course, one service is going to take care of only one functionality. So, it is only a single responsibility that is why is this modular Independent development and deployment. So now what I will do with for one service, I can create a team. In one team, I can have two front end developers, one person is going to take care of the business logic part and one person will take care of the database.
So, for example, I can have a team of eight people who's going to do one service. And similarly, I can have one other team which is going to do another service that does independent development and deployment. I don't have to bother about order module or inventory module when you're when I'm working on user service. And again, the order service will consider only its own functionality doesn't have to bother about Inventory Service. All the services are loosely coupled. As I told you, we are going to connect to the services only using this template, we are not going to identify the mean the interfaces are implementation classes, nothing will be visible to this particular service.
Independently scalable independently, you can just expand the functionalities of a particular service. Be there by purchasing data services. Next, it is faster because it is a separate service which is going to take care of one functionality for fault isolation. When a fault or when an exception occurs in a particular service, it is not going to affect the other services. And another thing is it is very easy to identify the fall or the exception that occurs in a particular service and also it is very easy to take care of it techmount of your diversity the technology diversity means what because they are a piece you can develop in any way you can develop any any technology and you can export the method plus the CPA. Any front end can access the Search API an Angular application can access a specific or a simple JSP application can access the specific because you are exposing our functionality as a list of application.
So this is an introduction to micro services. In the upcoming sessions. We will be learning How to create micro services using Netflix voices. Thank you