Microservices Part I

Forgetforget
62 min readApr 6, 2022

Microservices is the New Age Technological Marvel that is used by today’s Industries to create and deploy applications.

So it’s a great time for you to start learning about this trending technology. Hi all I welcome you to this Microservices full course and what follows is a session that will give you a complete insight to get you started with Microservices.

So without further Ado, let’s take a look at our agenda for today. So we’re going to start with introduction to Microservices where we will discuss what microservices are their benefits and how they differ from other architectures next.

We’ll talk about micro services with other Technologies such as Docker and spring boot later on we’ll compare microservices with other service-oriented architectures and talk about Microsoft versus with API moving on with our session. We understand how different design patterns can be followed to create applications using micro services.

And then we’ll talk about what tools can be used with Microservices. After that. We look into the various ways through which we can secure a micro Services applications. Finally towards the end. We’ll talk about the top interview questions of micro services that will help you Ace your interviews with that.

We come to the end of today’s agenda. Now before we begin kindly take out a second to subscribe to our Edureka YouTube channel and don’t forget to hit the Bell icon to never miss an update on the latest Technologies also, so if you’re looking for an online certification training on microservices do check out the link in the description box below on that note.

Let’s get started why we need Microservices so before microservices, We all know that there is an architectural pattern called more of the architecture that was used. All right, so there are certain disadvantages of that architecture.

But let me first explain you that architecture what exactly monolithic architecture means so basically in this the Ty software is composed in a single piece that is designed to be self-contained. So what I mean by that basically all the components of a monolithic program are interconnected and interdependent or in other words, if I have to put it I will say that it will give you a tightly coupled software where each component along with its Associated components must be present in order to execute or compile the code.

So all of these components are actually dependent on each other. So if you notice a definition that is there in front of your screen, it says that most of the carcass Picture is like a big container right think of it as a big container where in all the software components of an application are assembled together and tightly packaged. Right? So if you notice that there is an example in front of your screen, so there’s a server-side application, right which executes a domain specific logic it will retrieve an update data from the database and at the same time populate. The HTML view is to be sent to the browser.

So it is basically a big container or I can say that it is not divided into small small services or not divided into small small components. So even these components that are there. Are pretty tightly coupled right? So I will give you a better example of what exactly monolithic architecture is.

Let me just move forward. So let us discuss a classic example of an e-commerce website like Amazon and Flipkart. All right, so everyone actually visits these websites quite often. So that’s a perfect example to you know, explain so let’s understand what monolithic architecture exactly means with this example. So as you see that in basic e-commerce application, we have common option of customer service, right products. Service and card service which a customer can access through their browser.

Right? And when you launch the application, it is deployed as a single monolithic application. There’s only one single instance if you can notice so we have customer service product service and cart service and when you deploy all these Services, it will be basically a single monolithic application. Now, what you can do is in order to scale it you can run multiple instances of this application behind a load balancer right now.

Let me discuss few advantages of this application. So first of all it is Very simple to develop right as a goal of the development Tools in IDs is to support the development of Monolithic application. It makes a development really easy and One Direction. All right now is pretty simple to deploy because you have to deploy the executable file at the run time to launch the application that executable file can be a word file is there now this very simple scale as well because you know in order to scale your application. All you have to do is run multiple copies of the application behind a load balancer now since everything comes with its pros and cons monolithic architecture.

Also has few major drawbacks. Let’s discuss about them one by one. The first disadvantage is large and complex applications. Now if you have a large application or you can see with the increase in size the application, it becomes really complex to understand and modify such applications.

Right and as a result development slows down and modularity breaks down over time more ever because it can be difficult to understand how to correctly Implement a change and due to that the quality of code declines over time. Let’s see what is an excess Advantage.

So the next disadvantage is slow. So what I mean by that as the application and the respective teams grow the application becomes difficult to understand and modify right because it’s pretty huge in size and there are multiple teams working on it. So it becomes really difficult to understand and modify also the larger the codebase leads to slower ID, which makes the developers less productive.

So the code base is pretty large because the entire application is one monolithic application, right? There are not different if it’s overseas present not blocks continuous development. So what I mean by that a large monolithic application is An obstacle to frequent deployments. Let me tell you how in order to update one component.

You have to redeploy the entire application which interrupts the background task. So if I have to take the example of the e-commerce website if I have to update the card service, I have to redeploy the entire application the entire application which includes the customer’s always a product service all these Services right? So there is also a chance that components that haven’t been updated will fail to start correctly.

Alright, because of many dependency issues or anything, right and as a result the risk associated. Redeployment increases which discourages frequent updates. I hope you are getting my point. Let’s see what we have next. So the next point is unscalable. I know I’ve told you that it’s pretty easy to scale. But let me tell you what are the disadvantages when it comes to scalability and in terms of Monolithic architecture.

So each copy of application instance will get access to all the data, right which makes caching less effective and increase memory consumption along with input/output traffic also different application components have different resource requirements. One might be cpu-intensive right while other might be Memory intensive and with a monolithic architecture. We cannot scale each component in dependency, right? So if you can see the example that is there in front of your screen.

So here we have customer service product service and guard service is one instance. And this is how we are scaling it. Right if I have to increase only the customer service after scale up the customer service. I have to do that for product and cart Services.

Well, right now it is pretty unreliable as well. Let me tell you how so because of the tightly coupled components if one of them. Goes down the entire system will fail to run what I mean by that. If one of my say production of space that will in turn lead to the downfall of my entire application, right and because of all the modules are running within the same process a bug in any module can potentially bring down the entire process more ever since all the instance of the application are identical the bug will impact the availability of the entire application.

This makes the monolithic architecture highly unstable and unreliable. The last in the final point is inflexible. So how is it inflexible guys with the monastic architecture becomes really difficult to adopt a new Frameworks and languages suppose you have million lines of codes written with XYZ framework. Now, it would be extremely expensive in terms of time as well as cost to rewrite the entire application to use the newer ABC framework, right even if that framework was considerably better and as a result, there is a huge barrier to adopting new technologies.

I hope you’re getting my point. So why is it very expensive because you know, you have written million lines of code in some language now you To use some other language, right? So it becomes really expensive and time-consuming task. And even if the new language of the framework is considerably better but you know, there’s a huge barrier in adopting such new technology.

So I hope you have understood the various disadvantages of Monolithic architecture now is the time to understand what exactly is Microsoft with architecture microservices also known as Microsoft is architecture is an architectural style that structures an applications as a collection of small autonomous services. Modeled around a business domain now if I have to put it in simpler terms.

Basically, it is a self-contained process which avails different and unique business capabilities. Now, if you have large applications built using this architectural pattern, it can be broken down to small multiple Services which together access one large system but behind the scenes, it’s a Microsoft Office. So what I am trying to say here is we have multiple services on all of these Services, they don’t share the data structure, but they will be communicating through apis, right?

A major advantage of breaking down the system is now each microservice can focus on only one single business capability which definitely leads to a better quality and throw and it obviously becomes easy for you to understand when I explain you with a example again, I’m going to take the e-commerce site example. Now if you remember in monolithic architecture all the components were in a single module, but if you see here with Microsoft is architecture all the components are divided into separate modules, which communicate with each other using a well-defined.

Interface usually rest our messaging now the communication between the micro Services is a stateless communication where each pair of request and response is an independent transaction and because of this microservices can communicate effortlessly moreover in Microsoft’s architecture. The data is Federated.

All right. So let me just break it down for you. Each microservice is responsible for its own data model and data because of which interact with each microservices is handled by different instants and like in monolithic architecture where we had only An instant head we have multiple instances for different different microservices. So we have three microservices here customer Microsoft waste product Microsoft which and card Microsoft’s right?

Each of them have their own instances. They have their own data model and they have their own data. So this is what exactly Microsoft’s architecture is. Now, let’s dig a bit deeper into its architecture and understand what it is. Now as you can see in a Microsoft is architecture so which is a small independent and Loosely coupled. So, let me just tell you where it is.

So with these are multiple so which is right these A pretty small in size and they’re independent and Loosely covered now each of these Services has a separate codebase, which can be managed by a small development team and it is deployed independently, right? So this service will have a code bases service will have a codebase.

The service will have a code bit. Similarly. All of them will have a codebase that will be not huge in size. And when you compare it with the monolithic architecture, all of these services are running in one instance.

I hope you are getting my point now basically a team can update an existing service without rebuilding in deploying the entire application. For example, if I have to update this particular service, I Have to do it for the other services as well.

I can just read deploy this service independently now services are responsible for persisting their own data or external State internal implementation details of each services are hidden from other services moreover. They don’t need to share the same technology stack libraries or Frameworks is well, right you getting my points. They might not have the same technology or same libraries of the same framework and they have their own database and things like that. So they are pretty independent from each other besides for the microservices themselves some other components appear in typical Mike. Service architecture. So let me just discuss that so the first part is management. So the management component is responsible for placing services or nodes identifying failures rebalancing Services across nodes and so forth right then let’s talk about service discoveries. Now service Discovery the task of this component is to basically maintain a list of services and which nodes are located on it enables service look up to find the endpoint for a service. Let’s talk about API Gateway now, right so API Gateway is The entry point for clients. So this client won’t call all the services directly write will first go to this API Gateway which will forward the call to the appropriate services on the back end, right if I’m a client I’ll request for this particular service then after call the API Gateway and which will in turn call the service on the back end now the API Gateway might aggregate the responses from several services and return the aggregator response. Now, it might be possible to write a client request for multiple services. So at that time it will aggregate the results from various services and Turn the aggregated response. Right? So I hope I am clear with the architecture. Let us focus on what are the features of Microsoft has architecture. The first feature is small focused. So what it means it means that the aim of microservice Architecture is Simplicity, you know, so that it can be re-written in maintained without any extra efforts by the development team, right? That’s what I mean by small focused. The next point is Loosely coupled. So as I’ve already mentioned multiple times at each microservices independent of Each other and do not need to coordinate as well. This makes a development as well as a deployment it real quick guys, right? So if I have to update a particular service, I’ll only update that so which I won’t, you know, update the other services rights that way deployment becomes really quick. So that’s the big Advantage now, let’s talk about language neutral. So to be a good microservice, it must be language neutral. So what I mean by that for example in an application few Services can be written in Python for fast deployment. Whereas few might be written in Java because its speed and extensive libraries. Right. So depends on the Microsoft Office what kind of programming language we are using so it doesn’t really affect the other services right now bound it context. So it means that each microservice doesn’t need to understand the implementation of other Microsoft’s so these are few features of Microsoft’s architecture. Now, let’s talk about various advantages of microservice architecture the firstly independent development. So each microservices can be developed independently where a single development team can build test and deploy service. I don’t need to explain this much independent development means if I have a product service and I can independently focus on product service where a team of developers are writing code for that particular service testing it and deploying it now independent deployment means that you can update a service without having to redeploy the entire application bug fixes and feature releases are more manageable and less risky as well because you have to focus on one particular service. You have to deploy update one particular service. You don’t have to care about the other service or the entire application as such right? So next is Vault isolation. So it is a very big Advantage guys. It’s basically if a service goes down, it won’t take the entire application down with it. For example, if my card service goes down. My entire application is largely unaffected unlike the monastic architecture where if one of my component goes down the entire application fails to work next is mix technology start because of this feature teams can pick any technology which fits best for their service right and last but not the least granular scaling which means that Services can be scaled independently unlike my monastic architecture where you know after A couple instances. So in order to scale are I can only scale a particular service if I have to you know, increase the card service then I can just scale up the card services instead of scaling up the entire application. Let’s let’s move forward. So there’s a lot of companies which are using Microsoft which is we have Amazon Netflix. SoundCloud Twitter Who board PayPal lot of companies, right and why this happens because the applications become easier to manage when they’re broken down into smaller composable pieces. So without any further delay, let’s begin with our hands on will be using spring boot because it provides a a way to provide Java applications quickly and simply through an embedded server and by default. It is version of Tom cap. It will basically eliminate the need of java ee containers and which springboard we can expose component such as rest Services independently exactly is proportionally Microsoft is architecture that we have just discussed in any maintenance of the components. We no longer make the redeploy of its consumers. I’ll tell you what exactly I mean, what is the consumer for this lab will be use Eclipse oxygen and Maven 3? Now to illustrate the concept of microservice. What we will do will create 3 Maven projects in this Hands-On and each of them will symbolize back and functionality or you can say reusable apis and one of them held a composition fair to put it in simpler way. I will say it will be a consumer of the other two. So one application or one service will be a consumer of the other two Services, right? So we’ll be creating three simple Maven projects that I’ve already done. I’ll just open my clips and show you that so my first Maven project is basically diagnosed with Microsoft. He’s then we have dr. Microservice and we have patient microservice. So this doctor microservice is the consumer right and consumer the other two microservices that is patient and a diagnosis. Alright, so that is how it is done. Now if I have to explain one of these Services, let me explain to the patient microservice first so over here as you can notice that we have a palme D’Or XML file. So basically this bombed or XML file will stablish all the dependencies right before we start coding the first class that we create that we call. Negation will be identical in all three projects and it only works as an initiator to Spring boot that we call a Spring boot application annotation. So that’s how it is. If you notice here, we have application or Java. So it will be common application or Java and application configuration or Java the two packages that we have created will be common for all the other Microsoft uses as well. So if I show you a doctor’s is well now here also, we have application or Java and application config dot Java similarly for diagnosis. As well. If you notice we have both application or Java and the other things as well. Now, we have patient or Java and we have patient rest dot Java, right? So the patient Java here, we have defined all the variables like, you know, the email ID of the patient name and things like that and this patient rest dot Java will be used to provide the input the variables. I hope you are getting my point but a patient rest or job is basically to provide the input. I won’t be explained in the code here in the upcoming tutorials. I’ll be explaining the entire Microsoft which you know, how the code works and I think all the technical details you can find the next tutorial and this I’m just giving you an overview of how things work in Microsoft versus and we have this application config class as well right the package. So let me tell you why we actually use it is basically it is a resource configuration class, which is basically a resource manager responsible for exposing rest services for application consumers, right so basically for messaging right so the rest services for messaging and it is a stateless service for application consumers and we can notice a patient or Java and giant rest or Java are in the same package right now. Let me tell you how I’ve defined a ports here. So all I have to do is right click go to properties click on run debug settings. I mean I go to arguments right so I just have to write — the server dot Port 8:08 one so you can see that my patient Microsoft is will be running at a 14–0. It was when I started let me just start all these Services one by one so I’ll start this first. Let’s click on run a spring boot app similarly click on right click on this and I’ll just run it as spring boot up again, and I’ll run this also as a springboard app. So does that now? Let me just open my browser. All right. So this is for Port 8:08 one writes my poor a zero eight one is for patient to let me just click over there. Let me reload this page again. So here I have my patient Microsoft is similarly. My poor a0 A2 is for diagnosis, right so are high of the diagnosis microservice and finally my port 8 0 8 3 basically is a consumer. All right. It’s a doctor microservice and in the URL if you notice I have written. Patient ID right diagnosis and consultation, right? So basically we’ll get you know, this particular patient has been diagnosed with this disease and this is the consultation right? So, let me just reload this again for you so I can just go ahead and change the diagnosis as well. I can make this as to write sobre child has been diagnosed with a different disease now similarly if I make it as one she has been diagnosed with viral fever here, right? So that is what the difference is. Basically this particular Microsoft which is a consumer of the other two Services, right? So you can even think of it as an e-commerce application. I know it’s not of that level but consider it something like, you know customers production orders. So this patient Microsoft which will become the order Microsoft’s right and the other two will become customer and products. So this order Microsoft will be a consumer of the product and customers a similarly in this example. We have patient and doctors we have patient. My resolve is and we have diagnosis Microsoft OS and we also have Doctor Microsoft Office, which is actually a consumer of the other two service. Today, I’m going to discuss Microsoft versus with spring boot. So let’s move forward and have a look at the agenda for today. So this is what we’ll be discussing today. We’ll Begin by understanding. What are the various challenges with the microservice architecture after that will understand. What is the need for spring Boot and how it overcomes the challenges of a microservice architecture. Then we are going to discuss a use case that we will Implement practically in today’s session and I will also tell you about what are the various tools required in order to execute that use case. So let’s begin guys will first start with what are the various challenges with microservice architecture. The first challenge that we are going to discuss is called perceptibility. Now as we know that in a Microsoft is there are small components to deploy and maintain and there are many of them. So there are many small components that we need to deploy and maintain and at times it becomes very difficult guys to Monitor and identify problems, right if I take the classic example of an e-commerce website so over there we have multiple small small Services running for example the card so which it can be the product service or the customer service. So there are multiple Services running and we need to deploy and maintain those services. So at times it becomes very difficult to Monitor and Aunt if I problems so what we require we require great perceptibility around all of these components. The next challenge is configuration management. Now, there is a great need to maintain the configurations for the components across the various environments because we have small small components, right the idea behind microservices to break down a notch break down an application into small composable pieces that can talk to each other. So we need to configure these components across various environments. That is also a very big challenge guys. Now the next challenge is debugging now, it becomes very Difficult to probe each and every service for an error, right? So you have multiple Services running now to debug error in each of those Services is very difficult. So what we need, we need centralized logging and dashboards to make it easy to debug the problems, right then an excellent that we are going to discuss is basically consistency now think about it guys. You cannot have a wide range of tools solving the same problem, right? And we know that it is important to Foster Innovation, but we also know that it is also important to have some decentralized governance around The languages platforms technology and tools which are used for implementing or deploying or even monitoring the microservices, right? So I hope you are getting my point. So maintaining consistency is also a very big problem. Now, the next point is automating the components. It becomes very difficult guys to automate everything because there are a number of smaller components instead of a moonlit that is built deployment and monitoring. So in order to automate this entire Cycles, it’s very difficult. So these are the challenges with the micro service architecture now, let us see the solution so It’s spring boot now spring boot enables building production-ready applications quickly and provide many non functional features. Let me discuss few of them. So the first feature that I’m going to talk about is embedded servers. So these servers are easy to deploy with the containers. Then the next point is it helps in monitoring multiple components. So you have various various components are various Services running. So in order to monitor those Services we can do that with the help of spring boot then and finally it facilitates in configuring the components externally, so we saw whatever the Changes were right the consistency perceptibility configuration management Automation and all the challenges that we have just discussed were completely removed with the help of spring boot. So let’s move forward and now we are going to focus on how to build a top sports bra. So this is our use case guides will be building a top sports brand. Let us see how we are going to do that. So in this pre-boot microservice example, we’ll be creating top sports brand application, which will have three sources so you can see it in the diagram is well, so we have three services here one is Eureka’s over then we have item catalog server. And then we have a church service. So these are the three services that will be running now. Let me discuss each of these one by one. So the first thing is Eureka service now this service will register every microservice and then the client microservice will look up to the you take us over to get a dependent microservice to get the job done for I mean by that is a user will approach this Eureka service which will have the other two Services registered with it.

So this is basically called a registry service in this industry service. We have the other two Services already registered so based on what the user. Zur want Eureka server will get a dependent microservice to get the job done. So I hope you have understood that now let’s move forward and we are going to focus on what our item catalog service. So item catalog service will generate the list of sports brands which are popular in the market. So whatever the list of sports band rather popular it will generate that and then the edge service is also pretty much similar to the Standalone item catalog service. However, it will have fallback capabilities which prevent the client from receiving an HTTP error when the service is not available right now. We have understood this architecture. Let me just repeat it once more. So we have a Eureka service which is owned by Netflix. And this is basically a registry service and we have the other microservices registered in this service. The item catalog service will have the sports brands. Then the edge service will basically give us the op sports brand will filter only the top sports brand. This is how the architecture of our a spring boot application is. So we have given the numbers as well in the diagram. So the first thing is it will register the other two applications in Eureka service. So first will register the eye. Item catalog then we will register the edge service then will produce a sports brand names item catalog service and the edge service will filter only the top sports brats. So this is what is going to happen in today’s use case. Now. Let us see what are the tools I’m going to use. So I’m going to use Java 8 Eclipse IDE oxygen and the spring tools. So let me just quickly open my Eclipse IDE, and I’ll explain you the code there. So this is my Eclipse IDE guys and over here. I’ve already written the code in order to execute the use case. I’ll just take give you a walkthrough of what I’ve done here. So I have all the He’s always had that I mentioned in the slide. So we have Eureka service. We have H of s and we have item catalog. So start with Eureka service first. I’ve already written it. So I’ll just quickly show you how you can do that. Click on new over here. Go to other and over here select spring starter project click on next and just a couple of minutes and then just give the name to your service and then go ahead and click on next and the dependency. So we want the Eureka server as a dependency in this finally click on finish. So that’s all you have to do and real fine you Lakers over already created? And over here, the first thing that I wanted to show you is application properties so over here I’ve mentioned the port I’ve modified it a bit. So what modification I’ve done I modify the file to add a port number and I’ve disabled the registration the port number is eight seven six one and this and I’ve disabled the registration right next what I’ll open, I’ll just open your a car service application dot Java, right? So for that so this is the file that I was talking about and over here. I’ve added a couple of notation forces enabled you. Above the spring boot application. So this Eureka server that you are seeing. I’ve added that above the spring boot application. Right? So this annotation will configure a registry that will allow other applications to communicate since I want the other applications obviously communicate with it. So it will basically configure a registry and it will allow the other applications to communicate so that’s all for Eureka service. Let me just go ahead and quickly run it to show you how it looks like in the browser. So I’ll just click on run as a springboard application and you can see that it has started running out. Ready, and I’ll just quickly open my browser and at Port eight seven six one so you can see that Eureka service is running at Port eight seven six one, but currently you can see there are no instances which are registered with Eureka. Right? So we need the other two services to be registered here. So this is it for Eureka server. Now, let me talk about item catalog. So for item catalog, what we need to do is again click on new. Go to other spring starter project. Like we have done it in Eureka Services. Well given name whatever name you want to give them in the dependencies are a lot of dependencies that we need to import. So let me just talk about that. The first thing we need to import is an actuator, right? So we need to click on this and we need to import this. So what is an actuator it is a feature that will help us to Monitor and manage our application after actuator. I need to import Eureka discovery. Yeah, so I need to import this Eureka Discovery for Service registration since I want my service to be registered in the Eureka server. So for this I need to impose this particular dependency. Then I’m going to import jpa which is basically to save or retrieve data after that. I’ll import H2, which is an in-memory database. All right, then I’m going to import the rest repositories. I did these repositories are basically to expose JP repositories as rest endpoints. Then I’m going to import web. Alright, so here we can see that we have web here. So web will basically is nothing but staying Embassy and embedded Tomcat then I’ll import Dev tools they have tools. All right. So this is to Auto reload the application when there’s any change in the file. Now, I’m going to import lombok in order to you know, just to reduce the boilerplate code. So since I’ve already done that I won’t create another project here. Another service are basically so let me just give you a walkthrough of the code that I’ve written here. So first, let me show you the item catalog. application dot Java file So this is how it looks like first of all the couple of annotation. So enable Discovery client is basically to register my application in the Eureka server. Then we have a one more annotation springboard application. Right? And so after that what I have written, so this is my main class. All right, the main class will be executed for some application and this is responsible for item catalog execution the item catalog application execution. All right, then I have purel notations at the rate data all argument Constructor. So in order to explain You that let me just tell you what a Droid data is a convenient shortcut annotation that bundles the features of to string, you know equals and hashcode getter Setter required argument Constructor together. Alright, so people who are familiar with Java know all these annotations then the second generation I’m using is all argument Constructor generator. So basically it will generate a Constructor with 1 parameter for each field in your class. All right, so Fields marked with at the rate not null result in a null checks on these parameters, then we have no argument Constructor will generate a Constructor with The no parameters. Yeah, after that we have at the rate to string. So it will also pretty easy. So either a tostring is basically, you know, it gives you the facility so that you don’t have to start a debugger to see your Fields. You can just let lombok generate a tostring for you and then the entirety is basically is a lightweight persistence domain object typically an entity represents a table in a relational database and each entity instance corresponds to a row in that table. So the primary programming artifact of an entity is the entity class. Although entities can use Helper classes as well. So this is about the annotations. So the next thing that I’m telling you about is a parameterised Constructor of the item class. So let me just write that here as well. So it is a bad a meter erised Constructor of the item class. And here we are defining the class members along ID and the string name. So next we have a repository rest resource. So basically we have an interface item repository that we are extending with JP repository over here what we are doing we are defining an implementation of the command line. Runner interface that we need to override the run method and this method will be executed after the application context is loaded and right before the spring application run method is completed. So this is basically generate the key value pair using the for each Loop and we are basically overriding the run method to print our key value pair. So that’s what we are doing here. So, I believe you have understood this code or people who are familiar with Java for them. It’s not a tough task, right? So it’s a pretty basic code. So let me just say we are creating an item entity a JP a repository for it and we are also creating a command line burner to populate database with the default data. All right, so that’s what we have done here. Now let me go to the application dot properties and I wanted to show you a couple of things that so yeah in this application dot properties what we have done. We have added an application name in the file to display the Eureka service and set the port to 8:08 it now also in the cloud properties file. So let me just show you the cloud properties file as well. So you need to add all of these things in your Cloud properties file is well. So this is the Eureka instance hostname. Then we have the non secure Port mention here the metadata map to the instance ID. Over here we have it. Then you record or instance lease renewal interval in seconds is 5 then Eureka client region, the default reason registry fetch interval seconds is we have given it as 5 so all of these things will be available with you. If you can mention your e-mail ID in the comment section, you can find the entire code there. So mention your email ID in the comment section and will reply with the entire code use in the video since I’ve configured Port 8:08 to let me just go ahead and quickly run this first I’ll clean it using Maven. So I’ll just click on Maven clean. And now I’m going to build it using Maven again. So just click on run as go to. Maven build over here type string — boot: run and just hit enter. So let me just go to the you rake us over. Let me just refresh this link one, right so you can see that item catalog Services already registered my Eureka server now. Let me just go to the port 8:08 to / items So it is displaying basically all the items present in my item catalog servers, right?

So let’s just go through it. It’s pretty easy guys. So we have the name of the sports brand right then we have again a bad boys. And you have Air Jordan Mike added us although sports brands that we were talking about and the size of the page total elements and everything. You can have a look and just play around with it. So I’ll just go back to my Eclipse IDE once more so now we are going to create an edge service now add Services have told you it is pretty similar to the Standalone item. So we That we have created. However, it will have fallback capabilities which will prevent the client from receiving an HTTP error when the service is not available and how we are going to do that similar fashion. Like we have created item catalog. All you have to do is click on file go to new. And go to other select spring starter project here. Click on next give a name to your service. Whatever name you feel like then go to next then over here. We need to add dependencies. So let me just tell you about that. The first dependency we need is Eureka Discovery. So just type here Eureka Discovery select that right. So this is basically for Service registration like we have done in the item catalog Services. Well, so this will be registered in my Eureka solo. Then we are going to add a fiend dependency. Let me just type that first. So yeah. Let’s begin dependencies. Basically a declarative web service client. All right, and now once it is done, we are going to add Azul. So basically zul is provides an intelligent routing system. So just click on Google as well. Once that is done. I am going to import rest repositories. So these rest repositories are have told you earlier as well is Bill expose the JP repositories as rest endpoints then I’m going to again ADD web as well. So I’ve done that in the item catalog as well. So just click on web. It is basically a spring MVC with spring MVC architecture and embedded Tomcat. Right? So like we have MVC and MVP architecture then I’m going to type in here hysterics. So this historic just let me just check it once yeah, so it is a circuit breaker to stop cascading failure and enables resilience, right? So that’s what it is used for then let’s go ahead and add one more dependency. That is lombok. Lombok is basically to reduce the boilerplate code that I’ve done in the past. U.s. Project as well. So I’ll just click on cancel because I have already done that. You can just go ahead and click on finish and you will find the HOV is present here something like this, right? So now let me just take you through the edge Services well. We know that the item catalog Services running on Port 8:08 to so what we need to do. We need to configure this application to run on a different port. Ah, now, this is pretty obvious guys, right? So let me just open this application dot properties and you can see that I’ve configured at Port 8 0 8 9 right and I’ve given the application name for a similar reason basically to add my service in the Eureka. So right now I need to create the cloud properties file that I’ve already done right? You can see it over here the cloud properties file. It is already present. I need to add some code here that I have done it in the item catalog Services. Well, so this code you can again find it once you you know ba mention your email ID in the comment section will reply you ASAP with the code. All right. All right. We just open Edge service application dot Java file so that I can find it here right now in order to you know enable Fein hysterics and registration with the Eureka server add the appropriate and notation. So what are the properties that annotations? We have enabled the inclines. We have enabled circuit breaker we have discovery. Giant Zuul proxy and springboard application obviously, right? So these are the annotations that we are going to use and after that let me explain you the code. Although it’s pretty simple guys people who know Java will find it really easy to understand. So this is again the main class which Java will basically execute the first in my application, right? Then I have a couple of Getters and Setters methods defined here. I have an API adapter that will return the array list of our items and the finally in see the public collection item good item that you can see it in the end. Yeah, this is basically for collecting items and adding it into a list. Finally. This private. Boolean is great item. This will return true and false if the item is not available for a particular brand. All right, so this is pretty easy guys now over here. I’ve created a D2 now. Let me just take you through the core once more. So if you notice here, I’ve already created a dto and item detail which means data transfer object in this same file and at the long box at the rate data will generate to In methods we Getters and Setters the appropriate Constructor. All right, then I’ve created item client interface. So if you scroll down you can see that we have an item client interface so we can see that we have an item client interface that uses Fein to communicate to the item catalog server. So we have talked about item catalog service. So this item client interface will use steam to communicate with the item catalog service. Right? Then we have a rest controller below the item client so over here we have the rest controller that will filter out. Less than top brands and shows a top brands endpoint. So slashed our top brand endpoint. So it will filter out the Brand’s right it will it will add a filter to all the brands that we have in order to get the top brands, right? So that’s what the rest controller will do. Now what I’m going to do, I’m going to start this service for you. So I have configured this service at Port 8 0 8 9. So, let me just quickly go ahead and run this for you. I’m going to first click on run as Maven clean. So I’m going to quickly run this as a springboard. Up and let us see what happens. All right. So let me just quickly open the you take us over. Right and I’ll just refresh this and you’ll see that there are two instances currently registered with Eureka, right? So you can see that there are two instances currently registered with Eureka. Now, let me just quickly go to a particular oat. That is a 0 8 9 so I’ll just type in here localhost:8080 9 / top — brands. And here we go, so we have got the top brands. So we have lining Puma Bad Boys in Air Jordan right now. What I’ll do, I’ll just quickly shut down the item catalog service application for that. Let me go back and I’m going to shut down the item catalog application. So this is what we have done in this particular use case. Now if we shut down the item catalog service application, you’ll get a 500 internal server error, right? So just go ahead and try it yourself and let us see if you get that or not. It’s pretty easy guys pretty basic application that we have. He added but a lot of things to learn from today’s session. I’m going to focus on Microsoft restraining. So without any further Ado, let us move forward and have a look at the agenda for today. So this is what we’ll be discussing today. We’ll Begin by understanding. What is the use case that we are going to implement in today’s session after that. I’m going to tell you about the few Basics which are required in order to execute that use case. Like what exactly is microservice? What is monolithic architecture? What is darker and how Docker can be used in Microsoft? Isis and finally I’m going to tell you how to implement the use case using Docker after that. I’m going to discuss the course content of microservices training provided by a director. So let’s move forward and we’ll discuss the use case that we are going to implement in today’s session. So this is a problem statement of I use case guys. We have a node.js application and mySQL database running in the same instance or you can say in a local laptop. So this is a typical example of a monolithic architecture. So let us just focus on few problems with this architecture and then we’ll see what is the solution to it. So let us now discuss the problems associated with this monolithic architecture. I’ll just give you a small introduction to all of these challenges later on. I’ll discuss it once more when I’m talking about monolithic architecture. So I hope that is fine with you all. So the first thing is large and complex applications. So if the size of our application is pretty large and it becomes really complex to understand and modify such applications when you use a monolithic architecture, you’ll actually understand that when I’m talking about monolithic architecture in detail, you’ll understand why are these problems there with such an architectural pattern? Then it also leads to slow development as the application in the respective teams grow the application becomes difficult to understand and modify and also the larger the codebase it leads to slower ID. Then at the same time. It blocks countenance development as well and it is pretty unscalable. So each copy of the application instance will access all of the data which makes caching less effective and increase memory consumption and input-output traffic also different applications components have different resource requirements. For example, Euro one might be CP. Pensive while another might be memory-intensive. So with the monolithic architecture we cannot scale each component independently, then it is pretty unreliable because of the tightly coupled components that we have here. All right. So if any of the component goes down the whole application will fail to run and then finally it is inflexible as well. So with more literature architecture, it becomes really difficult to adopt new Frameworks and languages. So this is the problem statement of a use case guys. Let us see what are the solution to such a problem. So it is nothing but Microsoft has now what I’m going to do here is I am going to To create two separate Services one called user service. Another is test database running on different Docker container. All right. So with this what we have we have separate services or you can see we have separate microservices compared to a monolithic architecture that we had just seen so what I’ve done here is this monolithic architecture where my node.js and MySQL were running on the same instance. I’ve divided them into two separate microservices one is user service. Another is test database and both of these obviously are running on a different doctor. And then so this is nothing but an example of Microsoft Office. So this is a use case that we are going to implement in today’s session guys. So now we are going to compare before and after Microsoft’s is basically we’re going to find out the differences between the micro services and a monolithic architecture. So let’s begin guys. So let’s take the classic example of an e-commerce website now from the diagram also, we can observe that in the monolithic architecture. We have all the features running at the same instance. For example, we have customer service. We have product service we have card service, right? All of these instances are Lying on a single instance and sharing a common database. All right. So this is a typical example of a monolithic architecture, but then with microservices each feature was allotted a different micro service which handles their own data and performs different functionalities. All right. So this is the basic difference between the monolithic and Microsoft’s architecture. So the idea behind Microsoft, which is that few applications become easier to manage when they’re broken down into smaller composable pieces that talks to each other. So that is what exactly microservice is. Let’s move forward and we are going to focus on I guess always architecture. So we are going to discuss it in much more detail. So let me discuss this architecture with you now over here. We have different clients coming from different devices and they’re trying to use services such as search build configure another management capabilities. Now, all of these services are separated based on their domains and functionalities and a further allotted to individual microservices. So you can see we have microservice a b c and d probably this is for your search service. This is for your build services for configure like that. We have many other services as well. Now these microservices have their own load balancer and execution environment to execute their functionalities and at the same time captures data in their own databases. So microservice a will have its own load balancer and execution environment and we’ll have it its own database as well similarly for other microservices. Also now all the microservices communicate with each other through a stateless server, which is either rest or a message bus now the all the functionalities performed are microservices are communicate to the clients by API gate when a client gives a request it will first go to the API Gateway and all the internal points are connected from this API gate. So anybody who connects to the API Gateway automatically gets connected to the complete system. So I believe guys have given you a good introduction to what exactly are microservices. What is monolithic architecture why we use Microsoft Office is what are the various challenges with monolithic architecture. Let’s move forward and now we are going to discuss what exactly is darker now, what is the occur if I have to give a definition I would say At its heart the docker is a software which lets you create an image image is nothing but a template for a virtual machine and then run instances of that image in a contain. So that’s what Docker is. Alright. I have a question popped on my screen. This is from Quinn. He’s asking can you tell me the differences between virtual machine and Docker and which is better find so bitch is better. I would say talker. Let me just give you a few reasons for that. First of all Docker is pretty lightweight, right. You have all the binaries and libraries there in your Tanner required for your application which can be a Microsoft Office application as well. Plus it’s pretty lightweight plus it doesn’t use as your guest operating system. It uses the host operating system unlike the virtual machines and you don’t have to pre-allocate any Ram in the containers and like your virtual machine. So, I believe you I’ve given you enough differences between the two already is Alpha is the answer now. Let me just take you through the diagram that is there in front of your screen. So here we have a host operating system on top of that we have dr. Engine, right? So we have couple of applications running on Top of Docker engine so we have couple of containers as well. Alright, so basically what we have done we have containerize the two applications into different containers. So we have binaries in libraries along with the application in one container and similarly for the container to as well. We have similar configuration. So all the binaries and libraries required for an application of present inside a Docker container. All right. Now, let me just go ahead and discuss few components of Docker. So I’m going to start with what our Docker images and what are Docker containers. So Docker images as I have told you are reading. A template which are used to create containers now Docker maintains vast repository of images called the docker Hub, which is nothing but a git repository of Docker images now with Docker images, we can create Docker containers. All right, and they contain everything required to run your application. Now, this is all about Docker images in Docker containers. So let me just quickly open my Virtual Machine and I’ll show you a few basic commands of docker. So this is my Center as virtual machine guys over here. I’ve already installed Docker. So let me just go ahead and quickly start Docker. So the command to start Docker is systemctl start talker. So it has started now. Let me just clear my terminal again. And now I’m going to try out few commands and then exit the container. So now what I’m going to do is I’m going to show you how you can pull images from Docker Hub. Right? So I’m going to pull Ubuntu image from Docker Hub. So let me just tell you how you can do that. All you have to do is Click. Occurred pull Ubuntu that’s all you have to do. It will first check the local system if there are any images available if there are no images available, then it will go ahead and check it and Docker Hub and pull then image for us from Doc it up. As you can see that it is pulling from Docker Hub right now because it couldn’t find it locally. So it says that downloaded newer image for Ubuntu latest, which means we have successfully downloaded the Ubuntu image. Now. Let me just hit a command called Docker PS and this will give me all the images all the containers which are there in my system right now. Now if I have to run this container, what I have to do is I have type in head Docker Run — it and at the name of my image or you can even use the image ID. So I am in open to container right now so over here you can you know, try out a few doc it commands. I’ll Exit from here now and yeah, let me just clear my terminal again. So what we have done we have basically pulled an image of Ubuntu from Docker Hub. And then we build a container from that image. That’s what we have done till now. Let me show you how Docker Hub looks like so for that I’ll open my browser. Now this is the official website that is half doctor.com. You need to go to this particular URL and you can just go ahead and create an account for free and get started. You can find all the images plus you can upload your own images as well. If you want just going to type my username and password. I’ll be logged into Docker Hub. So this is how a doctor of looks like guys. We have couple of tabs here repository Stars contributed create a repository create an organization explore repositories. So just go ahead and play around with it and You’ll understand it. I’m just going to tell you how to search an image here. So if I want anyone to image, this is the official Ubuntu image here guys. Similarly, you can go ahead and search whatever images that you want. All right, so let me just close it for now. So we have just discussed what exactly is darker what our images and what our containers I’ve also executed practically. I told you how you can pull in a bun to image and create a container from that. Let’s move forward and we’ll focus on Docker registry. Now, I won’t spend a lot of time on Docker registry because it is nothing but a storage component of Docker images Docker is own cloud. Depository for Docker images similarly, you can have either public or private repositories on Docker Hub as well. So it’s basically a storage component for all the docker images. Now, I’m going to talk about Docker compose because this is what I am going to use in today’s session. Now what exactly Docker compose has when you have multiple containers then Docker compose makes it easier to configure and run applications that are there in those containers what I mean by that consider the example that is there in front of your screen. So imagine I’m Able to Define three containers one running a web app another running a post Grace and a third rate is now all-in-one yamen file and then running those three connected containers with a single command. That’s what Docker compose is. So we have three applications and we write the configurations for all of these three applications. We have defined all of these three applications running on different containers in a Docker compose pile. That is Docker compose or Yaman and then with one single command, I can run all of these three containers. That’s what Docker compose is. All right, so I’m going to show you. Really how it works. Let’s move forward for now. Now this is basically a use case of how Docker can be used in an industry. So I’m going to write a Docker file complex requirements for a Microsoft Office in an easy to write dockerfile. Now from that Docker file, I can create Docker images and intern run as many Docker containers as I want now that Docker image, I can upload that onto the docker hub from which various teams beat staging or production can put that image and prepare as many containers is they want now whatever was there in my Laptop is replicated in my staging as well as in my production environment or it or you can say throughout the sdlc. So this is how you can use Docker. Although there are multiple use cases right available. So you can just this is one way of using Docker guys now doctor for Microsoft Office is so just an example how we can use Docker for microservice. Basically imagine. We have separate services for an online shopping service. We have account service product catalog card service and orders over right all of them have their own database so we can turn all of these services on a different Docker container. I’m going to show you practically how you can do that. So let me just quickly go ahead and discuss few advantages of Docker in Microsoft versus what are the various advantages that we get when we run Docker with micro Services the First Advantage is packaging. So a piece of software usually consists of a number of components. Now these components may be bundled together or distributed separately and I usually themselves composed of various files. This can include executables binaries documentation, etc. Etc. Now, Make software distribution convenient there must be some way of assembling all of these pieces together into one cohesive whole so traditionally this was done using one of a number of mechanisms like zip files or tar balls Debian or RPM packages or language specific packages, for example, npm python Wheels rubygems, etc, etc. So these all have their own trade-offs, but they have one thing in common. They do not solve the entire problem. Zip files need an agreed-upon format for their contents, Debian and RPM packages are os specific. Vic and notoriously difficult to work and the rest are the language specific systems that do a proper job of handling application dependencies outside of the scope of their language now Docker makes it possible to achieve the granularity of portable microservices through its packaging. So I hope you got my point now, let’s talk about distribution. So in order to share software with others or to deploy some way the software package needs to be tracked in a central place and accessible across the organization now Docker solve this problem by providing a standardized a Hi for a registry Service as well as an open source implementation for now. The standard Docker registry is not quite user-friendly right and lack some features available. In other systems such as yam and app. However, this will improve with time and that will happen definitely guys runtime isolation. Now, if you worry about efficient resource utilization, you’re likely tempted to run multiple microservices per host or right now. This is definitely doable but can present some challenges. Let me discuss those challenges. So I just discuss one such challenge, which is called. Dependency management, for example if service one requires the library with version one point XY service to require the same library, but with an incompatible version 2 point x will likely run into a problem. If you are using a package manager that installs packages system-wide such as after yum some ecosystems provide a way to isolate the application environment into a specific directory one example of this is pythons virtual environment node.js npm also does this by default as well? However, the isolation offered by these system is far from perfect any dependency on Freeze or executables outside of the language is sandbox can still result in conflicts another issue that comes up and running multiple Microsoft offices on the same host is protection against Rogue processes that use more than their fair share of memory or CPU prior to container technology or Docker containers. The main way to achieve this would have been to run multiple virtual machines right now Docker solve this dependency isolation Problem by packaging the entire OS image along with all the dependencies. It solves the The isolation Problem by providing and enforcing explicit CPU and memory constraints similarly Dockers runtime isolation allows you to run multiple API microservices side by side on the same host with greater ease and maintainability. So different teams working on different microservices will not affect the runtime of others if I have to give an example think of it, like if a revision of an API is needed the APA microservice running in a Docker container can be redeployed without affecting other apis and finally the installation process lasts. Wantage of Docker in Microsoft Office, is it how simple it is to install you can just go ahead and refer if you installation videos. So these are various advantages of using Docker n microservices. Now, let us discuss the implementation of the use kit already told you what I’m going to do here. I have a monolithic architecture that has node.js and MySQL running on one single instance. I’m going to create two microservices user service and database running on two different containers, and I’m going to run those containers using Docker compose. I’ll just quickly open my Virtual Machine and I’ll show you how I have implemented this use case. So this is my Center is virtual machine again guys. Now for doing local development will need to install MySQL and create a test database for us now for local development. We need to install MySQL and created test database now creating a local database and running scripts on it is an easy start but can get messy lots of uncontrolled stuff going on. It might work. We could even control it with some shell scripts checked into our repo, but what if other I was already have my SQL installed. What if they have a database already with creative name users which we want to create. So because of all of these reasons we are going to create a — database server n Docker. So I’ll just tell you how to do that. So this is a great talker use case guys be might not want to run our production database in Darker, but we can spin up a clean my SQL database in no time as a Docker container for development leaving a development machine clean and keeping everything we do controlled and repeatable. So in order to do that that the command that I’m going to type in here is pretty easy guys. Let me just go ahead and quickly do that. So it is Docker Run — — name now after give the name to my database. So let that be DB then my SQL password. I need to give root password. Which is equal to 1 2 3 whatever password that you want to give just go ahead and do that now Define a port here. So double 3:06 of my host and I will 3:06 of my container as well and the image so I just want the my SQL: latest image. All right, so it’s pretty easy. So here we go. So that started now it is giving us a few warnings. You don’t need to worry about that. So this starts a my SQL instance running allowing access through port double 3:06 using the root password 1 2 3 so we know that Docker and tells that the engine we want to run an image and the name of the image is MySQL: latest. All right, so let me just quickly open one more Tab and over here. What I’m going to show you is that image that we have just downloaded. So this is the name of our image. This is the port plus we have downloaded created about a minute ago, right? We can find all the details here now. I’ll do let’s connect to this image and see what’s there. Alright, so I’m just going to type in here Docker execute — it the name of my image is DB slash bin slash bash. And here we go. Now over here if I type here my SQL — user that is root. And the password is one two three, so you can see that so over here. I will just type my SQL databases. Semicolon so my SQL database I’m sorry. It will be show databases by mistake. I’ve typed MySQL databases. So here it is. You can see all the information here. Right? So what we did we basically executed a talker exe see — it´d be tells Docker we want to execute a command in the container name DB we can also use the ID or just the first few letters of the idea is well and — it ensures that we have an interactive terminal MySQL — you wrote — P 1 2 3 We have given that is a command. We actually run as a process in the container which in this case is just the my SQL time so we can create databases tables users. Whatever we need. Basically now, let me just move out of this. Let’s type in here exit and one more exit. Alright, so we’re done now now running my SQL inside a container has already introduced, you know, if you Docker tricks, so we are running MySQL inside a Docker container. So now what we need to do is we need to create a test database folder with a script to start the database stop the database and set up the test database. So let me just tell you what I’m talking about. So I’ll just go to a particular directory now, we’ll have to create a test database folder with a script to start the Database Top the database and set up the test data now for that what I will do I’ll just quickly go to a directory that is documents over here are enter. So this is my application guys. Let me just clear my terminal now over here. I Directory called test database so let me just show you that me clear my terminal so over here I have three scripts one is to start the database that is start out. Sh. Another is to stop the database. And then the final one is to set up the database is well. Now, let me just show you what I have written in each of these files. So let me just start with the startup script start or sh and you can use whatever editor you want. You can even use a cat command that will display it on your terminal itself. So this is a script to start my S database right? It’s pretty self-explanatory. You can go ahead and Have a look at this. All right. So this is my startup script. Now. Let me show you the setup script that I’m talking about. So I’m just going to do a cat command here set up dots equal. So this has all of my data. So it has my email addresses and various phone numbers and things like that. It is available here. This is my setup script. Now, what I need to do is I need to create a stop Crypt as well. Stop dog. Sh, so here we have stopped the database and remove the container so docker Stop DB and Docker remove DB. So before removing any container, you need to first stop it and that’s what we are doing here as well. And then we are removing it r m stands for removing the database now. Let me clear my terminal so we are done with wrapping up the test database now. We need to create a Microsoft offices in node.js. So this video basically talks about how we can use Microsoft versus with Docker and what exactly are Microsoft versus I won’t go into too much detail of node.js application and I’m talking about so let me just highlight the areas and takeaways so Just go to a particular directory called user service and let me just clear my terminal so over here you can see that we have multiple folders and files present here. So starting from package dot Json. So this is basically used for dependencies and metadata then index dot JS is nothing but a main entry point of the application. So we have API as well. So this API file includes our apis and the API test then we have a config directory as well. This is basically the Enthusiasts configurations of our application then we have the repository directory which provides the abstraction over our database and then we have server directory as well that will contain the server setup code. This is how we have created the node.js application. I mean just clear my terminal again. Now if you want the code for this application again, you can find it through the link that is present in the chat box. And if you’re watching this video on YouTube, you can mention your name and email ID in the comment section will reply you ASAP with the code. So this application that I’ve built here is basically a allows us to get all the users or to even search a user using the email. So in the set of the SQL file, we have seen that we have given all the data the email address in the phone number. So this is what my application is all about. It’s pretty basic but it’s very good example to understand why we should use Docker with Microsoft versus right? So now let me just hit few commands. So now to start that I’ll just use a startup that sh script that I’ve written and here we go. So it is waiting for the database to start up. So it is done. Now. We have started our test database. All right. So in order to stop it, we can just use a stop script that is dot slash stop door. Sh and that’s all we have to do. All right. So let me just open one mode tab here so over here, I’ll just run my node.js application. So let me first go to that particular directory. So all I have to do is here npm install. All right, so this will set up everything for me. So it is up to date in four point eight to six seconds and the next command is to start my application. So all I’m going to type in here is npm start. So service started successfully at Port 8 1 2 3 now, let me just open my browser and I show you how the application looks like. This is my browser guys. I’ll just go to Local Host Port 8 1 2 3 / users. So here we can find all the users with the email ID and phone number. So this is how Our obligation looks like guys. So now I’m going to tell you how to dock your eyes are Microsoft offices. So here we have a micro service which we can run on a development box as long as it has a compatible version of node.js installed. What we would like to do is set up our service so that we can create a Docker image from it. Allowing us to deploy our services anywhere with suppose Docker and one way to do is to create a Docker file. So as I told you earlier is well during the use case that we write complex requirements for a project or a Microsoft ways and an easy to write Docker file. So this Docker file is what I’m talking about right now. So a Docker file is recipe that tells Docker engine how to build your image will create a simple dockerfile in US user service directory and start to explore how we can adapt it to our needs. So I’ve already done that. Let me just quickly show you where it is present, so So just quickly go to that particular directory where I’ve already written that yeah. Let me just hit an LS command and you can find that we have test database and user service here as well apart from that. We have a composed or camel file and integration tests, which I’m going to tell you about data. You don’t have to worry about it right now. Let’s talk about Docker file. So we’ll go to this user service. All right, so let me just go there are my terminal and you can see that we have a dockerfile present here as you can see that we have a Docker file present here. So let me just Quickly show you the contents of this Docker file. So what we have done here, first of all, we are telling the occur to use note for as base image CMD command tells Docker that this image should run the node executable when the executable terminals the container shuts down. Then what we have done we have made use of add command to copy everything. Alright, so you can see that we have an add command here to copy everything and then current directory to a folder in the container called app. We then use run to run a command in this image and the image which installs are modules. And finally, we expose the server Port 8 1 2 3 telling Docker we intend to support inbound connections on 8 1 2 3 then run us over code. So this is how our dockerfile looks like now. Let me just go ahead and close it. Similarly. I have written the dockerfile for my test database as well. So let me just quickly go to that particular directory. So here in the test database we can currently see when we hit analyst command that we have two files one is dockerfile set up dot SQL file, but I have actually told you to create start dot sh. Top Dog sh is well along with Theta dot sequel. There was no talk of 5. So now that we are not familiar with Docker we can improve on this looking onto my SQL image documentation on the docker Hub. There’s a note which tells us the dots equal or dot SSH file added to the images folder will be executed when setting up the DB. So what I have done basically I have replaced my start dot sh and stopped or SS scripts with Docker file. All right, so let me just quickly show you how the dockerfile here. Looks like it’s pretty easy. Although I let me just open it through GL. It so when use my SQL 5 as my base image after that. I have given the password for my database then the name then the surveys and then the MySQL password password is 1 2 3 add setup dots equal to Docker entry point. I need DB dot d so over here. I’ve just written that to use MySQL 5 as my base image then provided the root password database name user service. Then we have provided the bicycle password and then we have used the add command. Let me just quickly save it and Close it. So that was pretty basic guys writing a Docker file. Now. Once we have written these Docker files, what we can do is we can make use of a command called Docker Bill — T Test database so Docker Bell — T Test database. So this command Docker Bill — t-test — database will actually build a new image from the dockerfile that you can see over here. Right? So it will build a new image from that particular dockerfile similarly if I type in here instead of build If I type in here Run — I T Test database. So this will run a container with this image. All right little basically ran container with this image the previous Commander. I’ve showed you will build an image from the dockerfile and this will run a container from that particular image. This is why we use a Docker files. Let me just quickly go ahead and clear my terminal and now I’m going to talk about composing so building and running each container is still somewhat, you know time-consuming we can take things a step further with dog. Compose tool which have discussed during the slides as well. So Doc is composed lets you create a file which defines each container in your system the relationship between them and build or run them all now, what we need to do is create a new file in the root of s project called Docker — compose dot Yaman. So it’s a yam elf. I’ll let me just go back and hit an LS command here and you can see that we have dr. Ivan composed dot HTML file present. So let me just quickly take you through that particular file. I’ll use G edit in order to you know, open that file you can use. Whatever editor or you can even use the cat command to open that on the terminal and means increase the size of it. Yeah, so I have written all the doctor files that I first want to build and create an image and linking the different Docker images or the docker container. So you can see that I have Services here user service and build will basically I need to specify build value for each of us always tells Docker way to go and find that particular dockerfile. So the first one is dot slash user’s — service the name of the container is user underscore. Service and the port that is present here. It should be linked to my database right depends on the database environment is database underscore host is equal to D. Be similarly. My database image can be built using the dockerfile which is President test underscore database. So it is pretty basic. Let me just quickly save it and close it. Let me just clear my terminal again. So I need to sign in as a root user for that. I’m just going to type in here the password. So now what I’m going to do, I’m just going to type in here Docker — compose build. So this will build the docker images for me set is successfully build now. Let me just clear my terminal and now I’m going to run this application. So for that I’m going to type in here doc it — compose up. That’s all I have to do and here we go. It’s always started successfully running on Port 8 1 2 3. So let me open my browser and check whether it’s working or not. Local Host 8 1 2 3 / user. So as you can see that application is working here here. I have all the email IDs and phone numbers which are there in my setup dot SQL file. This session is about the difference between the applications which are implementing SOA which is service oriented architecture and software applications, which are implementing the micro Services architecture. So without wasting any time, let me get started. Now before we go into details about SOA and microservices. Let’s see what is a monolithic application and how that function. First of all you can think of a monolithic application as a container, which is basically I think the number of software components right? There can be a number of software components as part of your software application. And if they are all hosted together and delivered together, then that’s called a monolithic application. Now there are various challenges with any software application which is implementing the monolithic architecture. First of all, they are not flexible. Okay, monolithic applications. They cannot be built using different Technologies. That’s the problem. The Second Challenge is that they are unreliable even if one feature of the system does not work then the entire system. Mm will not work. The third challenge is that these monolithic applications are not scalable. They cannot be easily scaled. And even if the application needs to be updated then the complete system has to be rebuilt. The next problem is that with these monolithic applications. They block continuous development all the features cannot be built and deployed at the same time. They will have to be done separately. The next challenge with monolithic applications is that the development is very slow. They take a lot of time to be built since each and every time It has to be built one after the other and most of all the monolithic applications are not fit for complex architecture because of course you cannot use different Technologies. You are very limited and very constraint, right? So that is the challenge with monolithic applications. So now let’s go on to SOA, which is nothing but service-oriented architecture now with SOA these services or features. They are broken down, right? The entire software application is not built as one but the different features teachers and the different services are broken down into smaller components, right? So that’s why it’s called coarse grained architecture and over here. If we have let’s say one software application inside the which it provides and if it provides like five features or four features, then all those are four features are delivered by four different services. And that is what you can see over here, right? There are four different services. And each of these Services would have multiple tasks inside them and these smaller tasks are together. Tell or ask one particular feature and the whole software application comprises of a number of these features, but with microservices, it’s a little more different. Now these features or services are further broken down into tasks level services. So here it was feature level Services. Whereas the services here. They are task level each and every task in a particular feature that was broken down and that’s why you have multiple tasks and multiple services in a micro service architecture. Chop and that is why this is called fine grained architecture. So that is what the differences are between these three on a high level. Now before I go further and confuse you people let me just go into more details about the differences between SOA and microservices. You can think of the difference between SOA and microservices with the help of these images. So SOA is like an orchestra similar to you having multiple performers, you will have multiple services. But each of these performers will be controlled by one potato director and similarly in Rip even though you have a multiple Services these services will be interacting with one another and then they will be delivered as one particular software application. But whereas in case of a micro service there are multiple or let’s say there are independent performers, but these independent performers are not controlled by any director. So they work separately and they work in silos. So that is a different. So I hope you can understand the difference between the two from these images right even though they work together. Are they are controlled by one particular director and that’s why this is called a centrally governed architecture and whereas microservices you do not have a centrally governed architecture and that’s why it’s called a decentralized governing architecture. So let me go forward and talk about the difference between these two which is nothing but Micro service and SOA with respect to certain parameters. Let’s look at the difference between them with respect to architecture and coordination. So first of all in SOA, there are four different. Types of services versus Business Service the Nexus Enterprise service, then we have application service and then we have infrastructure service. So these four service types together form your SOA and they together delivered your software application. Now, what are these different services? And what do they do? Let’s see that first is business service. Right? So your business service is the one that’s going to be performing your core business operations and it It can be either a represented by XML or by web service definition language. And then we have Enterprise service. The Enterprise service is that service which implements the functionality defined by all business service and the Enterprise service does it with the help of the application service and the infrastructure service now moving on we have application servers. The application service is the actual core application or the core functionality of that feature and these applications? Offices can be either invoked directory or they can be invoked through a user interface. And now we have infrastructure service the infrastructure service refers to those non-business or those not technical operations such as editing scaling or security and all these things. Those are the different Services enough SOA. But in case of micro Services architecture, you do not have these many types of services. You just have a functional service and you have an infrastructure service. The functional service is basically So the combination of a business service and Enterprise service and an application service now a functional service is a fine-grained service. So basically if your Robb business logic or your business operations requires a particular feature to work then the task that is related to exactly that particular feature that is performed by the functional service and besides a functional service. We have an infrastructure service and the infrastructure service over here is very similar to the infrastructure service that is there. An SOA the it does all the non business or the non technical operations. Such as your security auditing and logging. Okay, so that is the difference with respect to architecture and coordination. So now moving on to the next slide, we have a true genius interoperability. Now what this means is any software application and need not be developed on the same programming language. Now when your main software application you might have a smaller applications, right? And each of those smaller applications could be written on Java or it could be written on C dot dot net or it could be written on. On C sharp or python or anything now when it’s written in different programming languages, it’s tough for them to interact with one another and if you want the different services to communicate with one another then you would have to bring a particular platform. Right? So that’s where you have this messaging middle web. So in case of SOA, there is something called as a messaging middleware which acts as a communication point or the interaction point between the different applications which are in a different language. So you can see that this application is on either C sharp for.net and This is on plastic javabeans, right? So now here it’s C plus plus and here is Java so and all of these communications they go through this one quadrature messaging middleware, but in case of micro Services, we do not have any broker here the communication happens directly between application to application. Even if they are in different programming languages, even if they are structurally different and even if they are built on different grounds, so look at this if you have a C sharp or a.net application, which is communicating with a Java application, but then how does it happen? It happens with the help of a rest API. There is a direct communication between these two services and similarly. If you have another Java application which wants to communicate with another Java application. The communication would take place with the help of rest API and similarly Java to C sharp or dotnet would again take place with the help of a rest API. So there is no broker here or middleman, which is a messaging Middle where the communication is directly to the other application. Then comes service granularity. If you can remember I earlier told that in microservices you do not have the software delivered as a whole right? It is broken down into smaller features. And if you’re basically performing an operation which involves multiple applications or multiple Services, then those services are called by one another when it’s needed so as an end user as a consumer, you might be performing one operation. Okay, so that one operation would not be calling all the different Services it would call. One service and this service when it needs to interact with the second service. This would make the call to service to and similarly your service to when needed it would call service number 3 and similarly the ones the service requested made the server’s response is also given to the one that’s invoking the request now the catcher is each and every service requests and service response takes hundred milliseconds. Okay. So let’s assume it takes this much time the API calls and this is in case of micro services. So in the micro service architecture when each call takes a hundred milliseconds Is in total for this service to get successfully returned it would take 600 milliseconds. Now, that’s an awful lot of time for an API call to complete successfully write for an API called be made successfully and to be returned and this is where it is different from an SOA. So when case of an SOA the service consumer would again be calling would we would be performing one particular operation? And what happens here is this operation would be calling the different Services all at the same time. So the and over here would be calling the service number one service number 2 and service number three, it should be encompassed all together. So one particular call be made to the servers and all three would be serviced at the same time and by this you would be saving time because all the three requests and responses would be made simultaneously so you would be saving a good

400 milliseconds over here.

--

--