当前位置:网站首页>Getting started with microservices
Getting started with microservices
2022-07-21 05:26:00 【When the human stars shine】
Microservices
.Net Core A complete record of microservice introduction
Introduction to microservice
Today's application development and IT System management is cloud driven . New cloud applications need to be fast 、 agile 、 Scalable and reliable .
Microservice architecture is a way to decompose large applications into a set of smaller Services . Each service runs in its own process , And use HTTP/HTTPS、WebSocket or AMQP Wait for the protocol to communicate with other processes . Each microservice implements a specific end-to-end domain or business function within a specific context boundary , Every microservice must be developed independently , And it can be deployed independently . Last , Each microservice should have its relevant domain data model and domain logic , And it can be based on different data storage technologies (SQL、NoSQL) And different programming languages .
It can be said that , Microservice is an idea , Split the previous large-scale monolithic applications into one that can run independently , Deployed Services , There is no detailed division of the split here , Generally, a service is responsible for implementing a business function according to the business scenario , The services are connected through HTTPS/HTTP Wait for the protocol to communicate ( Most commonly used Restful API). This is the basic idea of microservice .
Of course, in the actual use of microservices , There will be quite a number of extension issues .
Containerization is a method of software development , Through this method, applications or services can be 、 Its dependencies and their configuration ( Abstracted as a deployment manifest file ) Packaged together as a container image . Container applications can be tested as a unit , And deploy them as container image instances to the host operating system (OS). So use containers , It is an effective method to realize the microservice architecture pattern .
The typical microservice architecture is shown in the figure below :
Docker
Docker Is an open source application container engine , be based on Go Language And follow Apache2.0 Open source agreement .Docker Allows developers to package their applications and dependencies into a lightweight package 、 In a portable container , Then post to any popular Linux On the machine , You can also implement virtualization . Containers are completely sandboxed using the sandbox mechanism , There will be no interface between them ( similar iPhone Of app), More importantly, the container performance overhead is minimal .Docker Is a for development , An open platform for delivering and running applications .Docker Enables you to separate your applications from your infrastructure , So you can quickly deliver software . With the help of Docker, You can manage your infrastructure the same way you manage your applications . By using Docker The way to quickly deliver , Test and deploy code , You can significantly reduce the delay between writing code and running it in a production environment .
docker Use
- install docker
- Dockerfile
fsutil file createnew Dockerfile 0
The command creation name is Dockerfile The file of
And add the following :
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY backend.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o /app
This will perform the following steps in order when called :
- Pull mcr.microsoft.com/dotnet/sdk:6.0 Image and name it build
- Set the working directory in the image to /src
- The name that will be found locally is backend.csproj Copy the file to the newly created /src Directory
- Invoke in the project dotnet restore
- Copy everything in the local working directory to the image
- Invoke in the project dotnet publish
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
EXPOSE 80
EXPOSE 443
COPY --from=build /app .
ENTRYPOINT ["dotnet", "backend.dll"]
This will perform the following steps in order when called :
- Pull mcr.microsoft.com/dotnet/aspnet:6.0 image
- Set the working directory in the image to /app
- Open port 80 and 443
- Create the build Mirrored /app Copy all contents in the directory to the application directory of this image
- Set the entry point of this image to dotnet, And will backend.dll Pass as a parameter
- Build the image
docker build -t mymicroservice .
docker build Command to use Dockerfile structure Docker image .
- -t mymicroservice Parameter indicates that it marks the image ( name ) by mymicroservice.
- The last parameter tells it which directory to use to find Dockerfile (. Specify current directory ).
- This command will download and generate all dependencies to create Docker image , This operation may take some time .
- See the build results , And run
docker images
A list of all images available on the computer , Including the image just created
docker run -it --rm -p 3000:80 --name mymicroservicecontainer mymicroservice
Run the image just created
docker ps
View the running container
边栏推荐
猜你喜欢
Flume的学习笔记
The use and difference of extern and static as global variables
Run keyword if usage details
Iptables防火墙实验
Common classes under JUC package
两种常见的Vlan间通信的方式
Detailed explanation of x509 digital certificate
Okaleido or get out of the NFT siege, are you optimistic about it?
【深入浅出玩转FPGA9------经验点滴】
年中总结及个人有感
随机推荐
1.54寸TFT ST7789液晶屏图片如何取模
几个DPDK控制框架
Lua脚本语言入门
含静态代码块及子父类的执行方法
The use and difference of extern and static as global variables
tp5.0 后台admin访问
The solution of MySQL inserting Chinese errors
每日三题 7.15
ASP.NET CORE 自定义中间件
sql server 2022 安装
Introduction to the basic use of openresty
localtime()
Run keyword if usage details
JUC包下的常见类
Create k26 SOM minimum system
阿里云 cdn 域名的配置方法
tp5.1 include 包含文件(引用公共文件)
Introduction to Lua scripting language
Request和Response
go 常用标准库之-time