当前位置:网站首页>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
边栏推荐
- .NET 使用 redis
- Practice: fabric user certificate revocation operation process
- Redis —— How To Install Redis And Configuration(如何快速在 Ubuntu18.04 与 CentOS7.6 Linux 系统上安装 Redis)
- 字节面试算法题
- C#基础深入学习一
- 高质量软件架构的唯一核心指标
- 上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
- Commvault 和 Oracle 合作,在 Oracle 云上提供 Metallic数据管理即服务
- Using nsproxy to forward messages
- CANN算子:利用迭代器高效实现Tensor数据切割分块处理
猜你喜欢
Reinforcement learning - learning notes 1 | basic concepts
AI painting minimalist tutorial
How real-time cloud interaction helps the development of education industry
Flet教程之 03 FilledButton基础入门(教程含源码)(教程含源码)
Oracle was named the champion of Digital Innovation Award by Ventana research
洞见科技解决方案总监薛婧:联邦学习助力数据要素安全流通
When MDK uses precompiler in header file, ifdef is invalid
【云原生 | Kubernetes篇】深入了解Ingress(十二)
eclipse链接数据库中测试SQL语句删除出现SQL语句语法错误
《预训练周刊》第52期:屏蔽视觉预训练、目标导向对话
随机推荐
Introduction to XML II
Web知识补充
Apache server access log access Log settings
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue
Use fail2ban to prevent password attempts
eclipse链接数据库中测试SQL语句删除出现SQL语句语法错误
A data person understands and deepens the domain model
源码编译安装MySQL
舔狗舔到最后一无所有(状态机)
使用宝塔部署halo博客
Alibaba cloud award winning experience: build a highly available system with polardb-x
JVM series - stack and heap, method area day1-2
诸神黄昏时代的对比学习
Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
基于链表管理的单片机轮询程序框架
Redis —— How To Install Redis And Configuration(如何快速在 Ubuntu18.04 与 CentOS7.6 Linux 系统上安装 Redis)
Using scrcpy projection
Reinforcement learning - learning notes 1 | basic concepts
DGraph: 大规模动态图数据集