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);
모두 IService1
및 ITest
가 반환 내가 사용하는 하나의 방법, GetRequest()
을 가지고 ~ 내가 한 일은 다음과 같이 서비스 프록시를 만드는 것입니다 300Kb 개체. IService1.GetRequest()는 OperationContract이고 ITest.GetRequest()는 WebGet입니다.
두 경우 모두 채널을 열면 tightly loop of proxy.GetRequest()를 실행하여 각각 얼마나 많은 Requests를 처리 할 수 있는지 파악합니다. 테스트 결과 로컬 시스템에서 SOAP가 5 : 1의 REST보다 성능이 우수했고 네트워크를 통해 SOAP가 여전히 REST보다 약 50 % 뛰어난 성능을 보였습니다.
나는 왜 큰 차이가 있는지 이해하지 못합니다.
SOAP은 SOAP가 아닙니다. –
Embarassing : S. 금요일에 두 기술 중 하나를 처음 사용했고 WCF SOAP를 검색 할 때 자습서에서 시작했습니다. – user472875