当前位置:网站首页>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 /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.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 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
边栏推荐
- CANN算子:利用迭代器高效实现Tensor数据切割分块处理
- ASP.NET Core入门一
- 源码编译安装MySQL
- remount of the / superblock failed: Permission denied
- 读《认知觉醒》
- Xue Jing, director of insight technology solutions: Federal learning helps secure the flow of data elements
- unity不识别rider的其中一种解决方法
- Web knowledge supplement
- Scripy framework learning
- Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
猜你喜欢
安装trinity、解决报错
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
室外LED屏幕防水吗?
7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多
SQL statement syntax error in test SQL statement deletion in eclipse linked database
How real-time cloud interaction helps the development of education industry
Comparative study of the gods in the twilight Era
Flet教程之 03 FilledButton基础入门(教程含源码)(教程含源码)
Three schemes to improve the efficiency of MySQL deep paging query
三星量产3纳米产品引台媒关注:能否短期提高投入产出率是与台积电竞争关键
随机推荐
Configure WebDAV server on Apache
HAProxy高可用解决方案
爬虫练习题(一)
XILINX/system-controller-c/BoardUI/无法连接开发板,任意操作后卡死的解决办法
How real-time cloud interaction helps the development of education industry
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)
CVPR 2022 | transfusion: Lidar camera fusion for 3D target detection with transformer
用fail2ban阻止密码尝试攻
【AI系统前沿动态第40期】Hinton:我的深度学习生涯与研究心法;Google辟谣放弃TensorFlow;封神框架正式开源
C language dormitory management query software
Scrapy 框架学习
请问大佬们有遇到这个情况吗,cdc 1.4 连接MySQL 5.7 无法使用 timestamp
上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
CVPR 2022 | TransFusion:用Transformer进行3D目标检测的激光雷达-相机融合
光环效应——谁说头上有光的就算英雄
Samsung's mass production of 3nm products has attracted the attention of Taiwan media: whether it can improve the input-output rate in the short term is the key to compete with TSMC
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
Rsyslog configuration and use tutorial
Rsyslog配置及使用教程