WCF与现行分布式通讯技术性能对比

1:前言

WCF是FrameWork3.0下的分布式框架。

本文讨论WCF与现行分布式通讯框架的性能对比。要求阅读者有一定的WCF基础(可以参照Windows Communication Foundation Architecture Overview)。

2:目标

本文的目的是WCF与现存的分布式通讯技术进行对比。这些现存的分布式通讯结构如下:

ASP.NET Web Services (ASMX) Web Services Enhancements (WSE) .NET Enterprise Services (ES) .NET Remoting

本文中提供的场景和技术对于理解不同技术的性能来说非常有用,但是不能作为选择某项架构的决定因素。因为优秀的SOA架构依赖于服务本身而不在于通讯技术。

3:对比

所收集的数据来自于相同的硬件环境。如图14所示。提供足够多的客户端使服务端满负荷运行。测试过程中的数据为平均数值。本为旨在比较“吞吐量”图表中的线段越高性能越优越。

3.1 ASP .NET Web Services (ASMX)

本次比较WebService和WCF,比较的内容是客户端和服务端交互的性能。客户端请求整型的数据服务端获取请求分别返回1,10以及100个对象的数组。

服务端方法为

ContractedBlock.gif ExpandedBlockStart.gif Code
Order[] GetOrders(int NumOrders);
{
            Order[] orders 
= new Order[numOrders];
            
for (int i = 0; i < numOrders; i++)
            {
                Order order 
= new Order();
                OrderLine[] lines 
= new OrderLine[2];
                lines[
0= new OrderLine();
                lines[
0].ItemID = 1;
                lines[
0].Quantity = 10;
                lines[
1= new OrderLine();
                lines[
1].ItemID = 2;
                lines[
1].Quantity = 5;
                order.orderItems 
= lines;
                order.CustomerID 
= 100;
                order.ShippingAddress1 
= "012345678901234567890123456789";
                order.ShippingAddress2 
= "012345678901234567890123456789";
                order.ShippingCity 
= "0123456789";
                order.ShippingState 
= "0123456789012345";
                order.ShippingZip 
= "12345-1234";
                order.ShippingCountry 
= "United States";
                order.ShipType 
= "Courier";
                order.CreditCardType 
= "XYZ";
                order.CreditCardNumber 
= "0123456789012345";
                order.CreditCardExpiration 
= DateTime.UtcNow;
                order.CreditCardName 
= "01234567890123456789";
                orders[i] 
= order;
            }
            
return orders;
}

3.1.1 IIS Hosted Interoperable Basic Profile 1.0 Web Service

 

(单核)

 

(四核)

单核处理器下传输110100个对象数组WCF吞吐量比ASMX27%31%48%

四核处理器下传输110100个对象数组WCF吞吐量比ASMX19%21%36%

3.1.2 IIS Hosted Interoperable Basic Profile 1.0 Web Service using Transport Security

(单核)

(四核)

 

单核处理器下传输110100个对象数组WCF吞吐量比ASMX16%18%26%

四核处理器下传输110100个对象数组WCF吞吐量比ASMX5%12%13%

3.2 Web Services Enhancements (WSE)

本部分对比WCF和增强WebService之间的吞吐量。本部分是WSE2.0,顺便说一下WSE2.0和WSE3.0的吞吐量差不多。

3.2.1 IIS Hosted Interoperable Web Service using WS-Security

本部分消息采用 X. 509 证书,WCF用WSHttpBinding绑定。该绑定WS-Security 1.1类似。采用HTTP通讯。

(单核)

(四核)

无论单双核在吞吐量上WCF是WSE(增强)的4倍。

3.3 .NET Enterprise Services (ES)

本部分对比ES和WCF的吞吐量,主要通过两种数据类型。一种是常见的数据类型(primitive )一种是类(order )。

ContractedBlock.gif ExpandedBlockStart.gif Code
string TransferFunds(int source, int destination, Decimal amount);

Here the service just returns a 
string "successful" or "failure"

For the order message the following code service 
is used:

static public ProductInfo CreateProductInfo(int count)
{
            ProductInfo productInfo 
= new ProductInfo();

            productInfo.TotalResults 
= count.ToString();
            productInfo.TotalPages 
= "1";
            productInfo.ListName 
= "Books";
            productInfo.Details 
= new Details[count];
            
for (int x = 0; x < count; x++)
            {
                productInfo.Details[x] 
= GetDetail();
            }
            
return productInfo;
}

static Details GetDetail()
{
      Details details 
= new Details();
      details.Url 
= 
"http://www.abcd.com/exec/obidos/ASIN/043935806X/qid=1093918995/sr=k
a-1/ref=pd_ka_1/103-9470301-1623821";
      details.Asin = "043935806X";
      details.ProductName 
= "Any Book Available";
      details.Catalog 
= "Books";
      details.ReleaseDate 
= "07/01/2003";
      details.Manufacturer 
= "Scholastic";
      details.Distributor 
= "Scholastic";
      details.ImageUrlSmall 
= 
"http://images.abcd.com/images/P/043935806X.01._PE60_PI_SZZZZZZZ_.jpg";
      details.ImageUrlMedium 
= 
"http://images.abcd.com/images/P/043935806X.01._PE60_PI_MZZZZZZZ_.jpg";
      details.ImageUrlLarge 
= 
"http://images.abcd.com/images/P/043935806X.01._PE60_PI_LMZZZZZZZ_.jpg";
      details.ListPrice 
= "29.99";
      details.OurPrice 
= "12.00";
      details.UsedPrice 
= "3.95";
      details.Isbn 
= "043935806X";
      details.MpaaRating 
= "";
      details.EsrbRating 
= "";
      details.Availability 
= "Usually ships within 24 hours";
      
return details;
}

本场景中WCFself hosted,NetTcpBinding

3.3.1 Self-Hosted Request/Reply TCP Application

(单核)

(四核)

单核模式下ES传递常用数据类型的效率是WCF高21%而传递引用类型的时候WCF比ES高149%

四核模式下WCF传递常用数据类型的效率是ES高7%而传递引用类型的时候WCF比ES高104%

3.3.2 Self-Hosted Secure Request/Reply TCP Application

(单核)

(四核)

单核模式下ES传递常用数据类型的效率是WCF高24%而传递引用类型的时候WCF比ES高69%

四核模式下ESF传递常用数据类型的效率是WCF高16%而传递引用类型的时候WCF比ES高37%

3.3.3 Secure Transacted Request/Reply TCP Application

该情况下两种技术相差无极

3.4 .NET Remoting

(单核)

(四核)

单核模式下WCF优于Remoting29%,30%在传输128 bytes and 4k bytes。当查传输256bytes时相差无几。

四核模式下WCF优于Remoting38%,18%,28%在有效负载是128bytes,4bytes,256bytes。

4:结论

When migrating distributed applications written with ASP.NET Web Services, WSE, .NET Enterprise Services and .NET Remoting to WCF, the performance is at least comparable to the other existing Microsoft distributed communication technologies. In most cases, the performance is significantly better for WCF over the other existing technologies. Another important characteristic of WCF is that the throughput performance is inherently scalable from a uni processor to quad processor.

To summarize the results, WCF is 25%—50% faster than ASP.NET Web Services, and approximately 25% faster than .NET Remoting. Comparison with .NET Enterprise Service is load dependant, as in one case WCF is nearly 100% faster but in another scenario it is nearly 25% slower. For WSE 2.0/3.0 implementations, migrating them to WCF will obviously provide the most significant performance gains of almost 4x.

5性能测试设备

 

图14

图14显示了机器配置是一台服务器和4个客户机连接的两个1 Gbps以太网网络接口。 该服务器是AMD64 2.2 GHz的四核处理器,Windows Server 2003 SP1操作系统。每个客户机为双处理器的AMD 64 2.2GHz处理器。该系统的CPU利用率保持在近100%。主机使用的是Internet信息服务( IIS ) 6.0服务器。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值