WCF 和 n 层架构和序列化性能 [英] WCF and n-tier architecture and serialization performance

查看:34
本文介绍了WCF 和 n 层架构和序列化性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 5 层架构(前端 => 接口层 => 业务层 => 数据库层 => 数据库)使用 WCF 服务作为接口层时,让客户端应用程序调用它的方法,我也应该使用业务层和数据库层的 WCF 服务?我问,因为这 3 个服务之间将进行的所有序列化/反序列化可能会为服务器消耗大量 CPU,并对整个应用程序产生性能影响,还是我错了?
在一台机器上运行所有3个组件层的情况下,是否将业务层和数据库层构建为简单的类库,只留下接口层作为WCF?
tks

When working with 5-tier architecture (front-end => interface tier => business tier => database tier => database) using WCF service as the interface tier, having the client applications calling it's methods, should I use also WCF service for the business and database tiers? I ask because of all the serialization / deserialization that will be going on between the 3 services is probably going to consume a lot of CPU for the server, and have a performance impact on the application as a whole, or am I wrong?
In the case of running all 3 component layers on a single machine, is it better to build the business and database tiers as simple class libraries, and leave only the interface layer as WCF?
Tks

推荐答案

WCF 对于物理机之间的通信很有用.虽然您可以使用 WCF 在进程内进行通信,但有更简单、更有效的方法来完成相同的事情.如果您想在某个时候将不同的层放在不同的机器上,您只会使用 WCF 进程内.至于将 WCF 用于数据库层,您不会:您将使用 System.Data.xxx 命名空间中的类(即 System.Data.SqlClient,如果您使用的是 SQL 服务器数据库;或者可能是实体框架).

WCF is useful for communication between physical machines. Although you can use WCF to communicate intra-process there are simpler and more efficient ways to accomplish the same thing. You would only use WCF intra-process if you were thinking about putting the different layers on different machines at some point. As far as using WCF for the database tier, you wouldn't: you would use the classes in the System.Data.xxx namespaces (ie System.Data.SqlClient if you are using a SQL server database; or possibly the Entity Framework).

当人们谈论三层架构时,他们将两个概念混为一谈:物理层:客户端机器、中间件机器和数据库机器;软件架构中的逻辑层:客户端 UI 代码、业务逻辑代码和数据访问代码.当来自位于同一物理机器上的两个不同逻辑层的代码需要通信时,最简单的模型是一个类调用另一个类,解耦量取决于您的要求.您想使用满足您要求的最简单的模型.Rockford Lhotka 在他的书 专家 C# 2008 业务对象

When people talk about 3-tier architecture they are mixing two concepts into one: physical tiers: a client machine, a middleware machine and a Database machine; and logical layers in the software architecture: client UI code, Business logic code, and data access code. When code from two different logical layers that reside on the same physical machine need to communicate the simplest model is one class calling into another, the amount of decoupling depends on your requirements. You want to use the simplest model that satisfies your requirements. Rockford Lhotka has an excellent description of this in the first chapter of his book Expert C# 2008 Business Objects

这篇关于WCF 和 n 层架构和序列化性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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