Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux集群 > Architecture > » 正文

Three-tier与MVC的不同

来源: fishhg 分享至:

先说Three-tier。简单点说,

                  客户机---应用服务器-----数据服务器

典型的情况下有多个db服务器和多个客户端。应用服务器也可以有多个。应用服务器指 对客户端的请求进行分析,平衡,再将其分配给db服务器。对db服务器返回的结果集分析,平衡,发送至不同的客户端。

一个最简单的例子:
  client1,client2发出两个相同的select语句到应用服务器。应用服务器发现两个请求相同,向数据库服务器select一次,得到结果集,发给两个客户端。
  在没有应用服务器的情况下,数据库须被执行两次select。

 

对网络应用而言,可以说成下面的结构:

   database 服务器----
                  |
                   -----Web服务器——--
                                     |
                                      -------客户端浏览器
好处:
1、减轻database 服务负担;
2、瘦客户;
   ......

 

再说MVC。

MVC是遵循了关注点分离的原则,C和V对M是松耦合的。

Today, MVC and similar MVP are Separation of Concerns design patterns that apply exclusively to the presentation layer of a larger system. In simple scenarios MVC may represent the primary design of a system, reaching directly into the database; however, in most scenarios the C (Controller) and M (Model) in MVC have a loose dependency on either a Service or Data layer/tier.

 

最后说说两者的不同。

Three-tier的各方是线性连接的。

A fundamental rule in a three tier architecture is the client tier never communicates directly with the data tier; in a three-tier model all communication must pass through the middle tier. Conceptually the three-tier architecture is linear.

但是MVC的各方的连接方式是三角型的。

However, the MVC architecture is triangular: the view sends updates to the controller, the controller updates the model, and the view gets updated directly from the model.

 

两者如何联系起来呢?

MVC中的V和C很可能就是Three-Tier的client端;这样一来,对一个大的系统而言,它是three-tier的三层架构,而它的client端的框架可以是MVC的.


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史