3层架构诉3 - 服务器架构 [英] 3-tier architecture v. 3-server architecture

查看:140
本文介绍了3层架构诉3 - 服务器架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个传统的.NET MVC的网站,所以我有一种天然的三层软件架构设置($ P $的车型psentation的意见的形式,在控制器业务层和数据层和数据访问层)。

I'm building a traditional .NET MVC site, so I've got a natural 3-tier software architecture setup (presentation in the form of Views, business layer in the controller, and data layer in the models and data access layer).

当我部署这样的网站,它通常会任一台服务器(其中的网站和数据库实时),或两台服务器(Web服务器和一个单独的数据库服务器)上。

When I've deployed such sites, it usually goes either on one server (where the web site and db live), or two servers (a web server and a separate db server).

如何去约3 - 服务器架构(WEB,APP和DB)?将Web服务器只是有presentation(例如物理视图/ aspx页面),应用程序服务器将举行的配置文件和bin文件夹,并且数据库服务器将保持原样?

How does one go about a 3-server architecture (WEB, APP, and DB)? Would the web server just have the presentation (e.g. the physical View/aspx pages), the app server would hold the config file and bin folder, and the db server would remain as is?

我的问题基本上是,你能简单地移动/ bin和所有的应用程序逻辑上从presentation意见单独的服务器?如果是这样,你如何配置服务器知道去哪里找?如果有一个很好的底漆的地方或有人可以给我的内幕,我会感激不尽。

My question is essentially, can you simply move the /bin and all app logic onto a separate server from the presentation views? If so, how do you configure the servers to know where to look? If there's a good primer somewhere or someone can give me the lowdown, I'd be forever indebted.

推荐答案

MVC是的没有的3层建筑。并不是每一个解决方案的需要的是3层或n层,但它仍然是重要的,了解的区别。 MVC恰好有3个主要元素,但这些元素不以分层方式工作,它们是互

MVC is not a 3-tier architecture. Not every solution needs to be 3-tier or n-tier, but it is still important to understand the distinction. MVC happens to have 3 main elements, but those elements do not work in a "tiered" fashion, they are interdependent:

Model <----- Controller
         \       |
          \      v
           ---- View

视图取决于模型。该控制器依赖于视图的的模型。这些多路径的依赖,因此不作为层。

The View depends on the Model. The Controller depends on the View and Model. These multiple dependency paths therefore do not function as tiers.

通常情况下3层的解决方案是这样的:

Typically a 3-tier solution looks like:

Data Access <--- [Mapper] ---> Domain Model <--- [Presenter/Controller] ---> UI

presenter /控制器是有些可选 - 在Windows窗体开发,比如你平时看不到它,而不是你有一个智能客户端的用户界面,这是也没关系。

Presenter/Controller is somewhat optional - in Windows Forms development, for example, you usually don't see it, instead you have a "smart client" UI, which is OK too.

这是一个3层架构,因为每个的3个主要层(数据,域,UI)只有一个依赖。经典的UI依赖于域模型(或商务模式)和域模型依赖于DAL。在更现代化的实现中,领域模型做的没有的依赖于DAL;取而代之的是,关系被反转,一个抽象映射层上使用IoC容器后注入。在这两种情况下,每一个的的仅取决于previous的层。

This is a 3-tier architecture because each of the 3 main tiers (Data, Domain, UI) has only one dependency. Classically, the UI depends on the Domain Model (or "Business" model) and the Domain Model depends on the DAL. In more modern implementations, the Domain Model does not depend the DAL; instead, the relationship is inverted and an abstract Mapping layer is injected later on using an IoC container. In either case, each tier only depends on the previous tier.

在MVC架构,C是控制器,V是用户界面(视图),M是该领域模型。因此,MVC是一presentation架构,而不是系统的架构。它不封装数据的访问。它可能不一定完全封装领域模型,其可以被视为一个外部依赖性。它不是分层

In an MVC architecture, C is the Controller, V is the UI (Views), and M is the Domain Model. Therefore, MVC is a presentation architecture, not a system architecture. It does not encapsulate the data access. It may not necessarily fully encapsulate the Domain Model, which can be treated as an external dependency. It is not tiered.

如果你想的物理的分隔层则通常是由暴露域模型作为Web服务(如WCF)完成。这给了你提高了可扩展性和关注清洁分离 - 域模型的字面上的可重复使用的任何地方,并且可以跨多台机器进行部署 - 但自带的显著的前期开发成本以及正在进行的维护成本。

If you wanted to physically separate the tiers then it is usually done by exposing the Domain Model as a Web Service (i.e. WCF). This gives you improved scalability and a cleaner separation of concerns - the Domain Model is literally reusable anywhere and can be deployed across many machines - but comes with a significant up-front development cost as well as an ongoing maintenance cost.

服务器架构反映了上面的3层图:

The server architecture mirrors the 3-tier diagram above:

Database Server <----- Web Services <----- Application

应用程序是你的MVC应用程序,这股域模型与Web服务(通过SOAP或REST)。 Web服务的专用服务器(或服务器)上运行,并且该数据库,显然,托管其自己的服务器上。这是一个3层,3 - 服务器体系结构。

The "Application" is your MVC application, which shares a Domain Model with the Web Services (through SOAP or REST). Web Services run on a dedicated server (or servers), and the database is, obviously, hosted on its own server. This is a 3-tier, 3-server architecture.

这篇关于3层架构诉3 - 服务器架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆