2012-03-19 3 views
2

REST 서비스와 SOAP 서비스를 사용하는 클라이언트를 비교할 때 설명 할 수없는 성능 결과가 나타납니다.REST 서비스 프록시와 WCF SOAP 프록시의 성능 비교

REST :

WebHttpBinding webBinding = new WebHttpBinding(); 
webBinding.AllowCookies = true; 
webBinding.MaxReceivedMessageSize = int.MaxValue; 

CustomBinding custom = new CustomBinding(webBinding); 

WebMessageEncodingBindingElement webMEBE = custom.Elements.Find<WebMessageEncodingBindingElement>(); 

webMEBE.ContentTypeMapper = new MyMapper(); 
webMEBE.ReaderQuotas.MaxArrayLength = int.MaxValue; 

var factory = new WebChannelFactory<ITest>(custom, new Uri("http://localhost/Test")); 
var proxy = factory.CreateChannel(); 

SOAP :

endPointAddr = "net.tcp://" + textBox2.Text + 
":8909/MyService"; 
tcpBinding = new NetTcpBinding(); 
tcpBinding.MaxReceivedMessageSize = int.MaxValue; 
tcpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue; 
tcpBinding.TransactionFlow = false; 
tcpBinding.Security.Transport.ProtectionLevel = 
    System.Net.Security.ProtectionLevel.EncryptAndSign; 
tcpBinding.Security.Transport.ClientCredentialType = 
    TcpClientCredentialType.Windows; 
tcpBinding.Security.Mode = SecurityMode.None; 

endpointAddress = 
    new EndpointAddress(endPointAddr); 

IService1 proxy = 
    ChannelFactory<IService1>.CreateChannel(tcpBinding, endpointAddress); 

모두 IService1ITest가 반환 내가 사용하는 하나의 방법, GetRequest()을 가지고 ~ 내가 한 일은 다음과 같이 서비스 프록시를 만드는 것입니다 300Kb 개체. IService1.GetRequest()는 OperationContract이고 ITest.GetRequest()는 WebGet입니다.

두 경우 모두 채널을 열면 tightly loop of proxy.GetRequest()를 실행하여 각각 얼마나 많은 Requests를 처리 할 수 ​​있는지 파악합니다. 테스트 결과 로컬 시스템에서 SOAP가 5 : 1의 REST보다 성능이 우수했고 네트워크를 통해 SOAP가 여전히 REST보다 약 50 % 뛰어난 성능을 보였습니다.

나는 왜 큰 차이가 있는지 이해하지 못합니다.

+1

SOAP은 SOAP가 아닙니다. –

+0

Embarassing : S. 금요일에 두 기술 중 하나를 처음 사용했고 WCF SOAP를 검색 할 때 자습서에서 시작했습니다. – user472875

답변

4

차이점은 사용중인 바인딩 때문입니다. SOAP 서비스의 프로토콜로 net.tcp을 사용하고 있습니다. SOAP 서비스는 독점적 인 이진 형식을 사용하여 메시지를 전송합니다. 이는 비 WCF 기술이 귀하의 서비스에 연결할 수 없음을 의미합니다. WebHttp은 다른 (비.NET) 기술과 훨씬 호환 될 예정인 REST 서비스에 사용되고 있지만 동일한 성능을 가지지는 않습니다.

SOAP과 REST 성능을 더 나은 "사과와 사과"비교하려면 SOAP 서비스에 WsHttpBinding 또는 BasicHttpBinding을 사용하십시오.

+0

그게 많이 설명됩니다. 문제는 WCF가 필요하지 않기 때문에 REST로 바꾸고 싶기 때문에이 테스트를 수행하고 있다는 것입니다. 우리가 그런 종류의 성능을 발휘할 수 있을지 확신 할 수 없습니다. 저에게 WCF로 얻는 것과 유사한 속도를 줄 수있는 플랫폼에 상관없는 기술이 있습니까? – user472875

+0

내 답변보다 나은 답변 - 저는 사과 - 사과 계급을 좋아합니다. –

+0

@user 아니요, 성능과 상호 운용성이 절충됩니다. 또한 트랜잭션 스코프 정의,보다 보안 지향적 인 기능 등 모든 'WS- *'기능을 잃을 것입니다. –