Part -1 Introduction On Microservice And SQL Database Design For Microservices [.NET 6 MicorService Series]
In the .NET6 Microservice series, this is the first installment article, where we are going to understand about the Microservices and also we are going to create SQL databases for our sample microservices of this series.
Monolithic Architecture:
Monolithic architecture is traditional or most commonly used for developing the application. In this approach, all the business units or logic are implemented under a single application. A single database can be used for data serving.
Microservice Architecture:
In Microservice architecture each business unit or logic is developed as separate small individual applications. So each separate application is lightweight and they have their own responsibilities to carry on and these individual services are called Microservices.
In Microservices each service has its own code and databases so anyone service down remaining microservice services are unaffected. Each microservice can be hosted anywhere on the web. Each microservice can interact with its own individual databases, these databases can be any kind like SQL, MongoDB, etc.
Here is the blueprint of the Microservice architecture and the same microservices we are going to implement in our demo series.In Microservices each service has its own code and databases so anyone service down remaining microservice services are unaffected. Each microservice can be hosted anywhere on the web. Each microservice can interact with its own individual databases, these databases can be any kind like SQL, MongoDB, etc.
- We can observe 2 microservices each has their own responsibilities like 'Product API', 'Order API'.
- Each microservice has its own database for data flow.
- Established asynchronous communication between the microservices by implementing a Massage Broker channel of RabbitMQ.
- Each microservice have their own domains which will be a hard time for a client application to maintain, this problem can be overcome by using the 'API Gateway'. The API Gateway where we can register all the endpoints of the microservices and API Gateway also had its own domain. So client application invokes the API Gateway endpoint which implicitly communicates with microservices and then serves the response to the clients.
Create Databases For Microservices:
Let's create 2 SQL databases like 'Manufacture', 'SalesBusiness' each database will be used by individual microservices.
In the 'Manufacture' database let's create a new table like 'Products'.
Manufacture(Database)/Products(Table)-SQL Qurey:
CREATE TABLE [dbo].[Products]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](500) NULL, [Cost] [decimal](18, 0) NULL, [Description] [varchar](max) NULL, [CreatedDate] [datetime] NULL, CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]In the 'SalesBusiness' database let's create a new table like 'Orders'.
SalesBusiness(Database)/Orders(Table)-SQL Query:
CREATE TABLE [dbo].[Orders]( [Id] [int] NOT NULL, [UserId] [nvarchar](50) NOT NULL, [ProductId] [int] NOT NULL, [OrderDate] [datetime] NULL, CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]In the next part, we are going to implement the 'Manufacture' microservice application where we will implement the 'Products' endpoint.
Support Me!
Buy Me A Coffee
PayPal Me
Video Session:
Wrapping Up:
Hopefully, I think this article delivered some useful information on the introduction on Microservices. using I love to have your feedback, suggestions, and better techniques in the comment section below.
Refer:
Part-2 Create A Microservice For The Products Endpoint[.NET6 Microservice Series]
Part-3 Create A Microservice For The Orders Endpoint[.NET6 Microservice Series]
Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series]
Part-5 Ocelot API Gateway For Microservices[.NET6 Microservice Series]
Git Source
Part-3 Create A Microservice For The Orders Endpoint[.NET6 Microservice Series]
Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series]
Part-5 Ocelot API Gateway For Microservices[.NET6 Microservice Series]
Git Source
Comments
Post a Comment