当前位置:网站首页>Getting started with microservices
Getting started with microservices
2022-07-04 13:46:00 【Hua Weiyun】
Microservices
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 buildWORKDIR /srcCOPY backend.csproj .RUN dotnet restoreCOPY . .RUN dotnet publish -c release -o /appThis 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.0WORKDIR /appEXPOSE 80EXPOSE 443COPY --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 imagesA list of all images available on the computer , Including the image just created
docker run -it --rm -p 3000:80 --name mymicroservicecontainer mymicroserviceRun the image just created
docker psView the running container
边栏推荐
- 7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多
- Don't turn down, three sentences to clarify the origin of cross domain resource request errors
- Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
- Alibaba cloud award winning experience: build a highly available system with polardb-x
- 聊聊支付流程的设计与实现逻辑
- Iptables foundation and Samba configuration examples
- 舔狗舔到最后一无所有(状态机)
- 三星量产3纳米产品引台媒关注:能否短期提高投入产出率是与台积电竞争关键
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
- When MDK uses precompiler in header file, ifdef is invalid
猜你喜欢

从0到1建设智能灰度数据体系:以vivo游戏中心为例

JVM系列——栈与堆、方法区day1-2
高效!用虚拟用户搭建FTP工作环境

字节面试算法题

OpenHarmony应用开发之如何创建DAYU200预览器

Xue Jing, director of insight technology solutions: Federal learning helps secure the flow of data elements

Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example

实战:fabric 用户证书吊销操作流程

Comparative study of the gods in the twilight Era

ViewBinding和DataBinding的理解和区别
随机推荐
安装trinity、解决报错
After the game starts, you will be prompted to install HMS core. Click Cancel, and you will not be prompted to install HMS core again (initialization failure returns 907135003)
Use fail2ban to prevent password attempts
FS4056 800mA充电ic 国产快充电源ic
Three schemes to improve the efficiency of MySQL deep paging query
数据库公共字段自动填充
读《认知觉醒》
AI painting minimalist tutorial
Simple understanding of binary search
Golang sets the small details of goproxy proxy proxy, which is applicable to go module download timeout and Alibaba cloud image go module download timeout
2022KDD预讲 | 11位一作学者带你提前解锁优秀论文
高效!用虚拟用户搭建FTP工作环境
MySQL three-level distribution agent relationship storage
使用宝塔部署halo博客
室外LED屏幕防水吗?
CTF competition problem solution STM32 reverse introduction
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
C language staff management system
XILINX/system-controller-c/BoardUI/无法连接开发板,任意操作后卡死的解决办法
Xue Jing, director of insight technology solutions: Federal learning helps secure the flow of data elements