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個對象的數組。
服務端方法為
CodeOrder[]?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
?
(單核)?
(四核)單核處理器下傳輸1,10,100個對象數組WCF吞吐量比ASMX高27%,31%,48%
四核處理器下傳輸1,10,100個對象數組WCF吞吐量比ASMX高19%,21%,36%
3.1.2 IIS Hosted Interoperable Basic Profile 1.0 Web Service using Transport Security
(單核)
(四核)
?
單核處理器下傳輸1,10,100個對象數組WCF吞吐量比ASMX高16%,18%,26%
四核處理器下傳輸1,10,100個對象數組WCF吞吐量比ASMX高5%,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 )。
Codestring?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服務器。?
總結
以上是生活随笔為你收集整理的WCF与现行分布式通讯技术性能对比的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微软与联合国环境规划署联手解决环境问题
- 下一篇: 配置 Cisco ASA Static