先说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.
两者如何联系起来呢?