mvc 到微服务_从学生的角度来看MVC到微服务

本文从一名学生的眼光出发,探讨了从传统的MVC(Model-View-Controller)架构到现代微服务架构的转变。文章翻译自Medium上的文章,深入浅出地解释了这种转变的原因和过程,涉及技术包括Java和数据库等领域。
摘要由CSDN通过智能技术生成

mvc 到微服务

What is the Microservice Architecture?

什么是微服务架构?

We have probably all heard of microservices before, but what does that really mean? Microservice architecture is a type of distributed system. This means we have our components decoupled or detached from each other, instead of having them all in the same place like with the Model-View-Controller (MVC) architecture pattern.

我们以前可能都听说过微服务,但这真的意味着什么? 微服务架构是一种分布式系统。 这意味着我们使组件彼此分离或分离,而不是像Model-View-Controller(MVC)架构模式那样将它们全部放在同一位置。

This allows us to break up our application, similar to how on a low-level we break up our classes and interfaces into different files. The general idea with this, is that most of our services are backend, which means they are simply dealing with business logic. Most of these services will take in data, do some operation, then return data back. These backend services send the data back to other services, including the frontend (FE) or user interface (UI). They talk to one another using various protocols such as HTTP and some kind of data-interchange format, which is just a fancy way of saying a way to easily send and receive data, a popular example of this being JSON.

这使我们可以分解应用程序,类似于在低层将类和接口分解为不同文件的方式。 这样的总体思路是,我们的大多数服务都是后端的,这意味着它们只是在处理业务逻辑。 这些服务大多数将接收数据,执行一些操作,然后将数据返回。 这些后端服务将数据发送回其他服务,包括前端(FE)或用户界面(UI)。 他们使用各种协议(例如HTTP和某种数据交换格式)相互交谈,这只是一种表达方式,可以轻松地发送和接收数据,这是JSON的一个流行示例。

The FE of our application is a service as well. It is the entry point into the rest of our code for the user. The FE, which might be a Javascript framework like Vue or React, will generally have a UI backend ‘attached’. This UI backend will act as a dummy or glue API between what the user interacts with on the website or app, and all the backend services. This means that the backend attached to the website or app has a single job, which is to format outgoing and incoming requests so that the actual UI doesn’t need to manipulate any data.

我们的应用程序的FE也是一项服务。 这是用户其余代码的入口点。 FE,可能是像Vue或React这样的Javascript框架,通常会将UI后端“附加”。 此UI后端将充当用户在网站或应用上与之交互的内容与所有后端服务之间的虚拟API或粘合API。 这意味着附加到网站或应用程序的后端只有一项工作,即格式化传出和传入的请求,以便实际的UI不需要处理任何数据。

Every service is entirely self-contained. This means that they each have their own database if needed, and they only talk to other services through API calls. There are various reasons for using microservice architecture — which will be discussed later in the article — but there are limitations and downsides to consider as well.

每个服务都是完全独立的。 这意味着,如果需要,它们各自都有自己的数据库,并且它们仅通过API调用与其他服务通信。 使用微服务架构的原因多种多样(将在本文的后面进行讨论),但也有一些局限性和不足之处。

Image for post
Figure 1. MVC architecture diagram
图1. MVC架构图
Image for post
Figure 2. Microservice architecture diagram
图2.微服务架构图

Mapping an MVC system to a microservice system

将MVC系统映射到微服务系统

The key to understanding microservices is understanding how they came to exist in the first place. Like most things, they evolved out of necessity. Other architectures were not scaling effectively, so a new type of system had to be designed. More importantly, the design of microservice architecture is just an iteration on past architectures, not a complete redesign, so we can see how pieces of other architectur

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值