我对WCF很新。我创建了一个WCF RestFul服务,它在内部调用谷歌地理编码api服务和数据库调用。随着并发用户数量的增加,平均响应时间急剧增加。我正在使用SoapUI进行性能测试。下面是平均响应时间变化的表格。有人可以建议可能出现的问题以及我需要考虑的所有事情以获得响应时间<最多100个线程,5秒。提前谢谢。
(No. of Threads/Sec) (Response Time in msec Run 1) (Response Time in msec Run 2) (Response Time in msec Run 3)
1 user 1490 517 585
2 users 2264.5 785.5 853.5
3 users 1341.33 1124 1093.33
4 users 2479.75 1400.25 1317
5 users 2348.6 1432.4 1673.4
8 users 4818.25 2130.25 4726.3
10 users 7510.8 8518.2 7655.4
15 users 11869.26 12933.93 10592.2
20 users 13510.4 6319.75 14553.1
25 users 17695.6 17695.6 17695.6
35 users 20905.17 19823.2 21936.5
50 users 26235.25 26146.32 31645.87
100 users 38424.488 37417.6 39465
Web.Config中
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="user" value="Mahesh" />
<add key="GeoCodingErrorDesc" value="GeoCodingErrorDesc." />
<add key="GeoCodingErrorCode" value="1111" />
<add key="CacheEmptyErrorDesc" value="CacheEmptyErrorDesc." />
<add key="CacheEmptyErrorCode" value="2222" />
<add key="DATAValidationErrorDesc" value="Schema valiation failed for the input recieved." />
<add key="DATAValidationErrorCode" value="5555" />
<add key="GenericErrorDesc" value="GenericErrorDesc." />
<add key="GenericErrorCode" value="3333" />
<add key="GeoCodingAPIKey" value="*****" />
<add key="Geocountry" value="|country:IN" />
<add key="GeoCodingAPIUrl" value="http://maps.googleapis.com/maps/api/geocode/xml?address=" />
<add key="Connectionstring" value="Data Source = MachineName; Integrated Security=True;" />
<add key="Query" value="SELECT * FROM Table where Code IN " />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITwoWayAsyncVoid" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/ESB.ExceptionHandlingServices.WCF/ExceptionHandling.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITwoWayAsyncVoid"
contract="ExceptionHandlingService.ExceptionHandling" name="WSHttpBinding_ITwoWayAsyncVoid">
</endpoint>
</client>
<services>
<service name="SearchRequest">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" contract="ISearchRequest">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Search/SearchRequest.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我的界面如下所示,
[ServiceContract]
public interface ISearchRequest
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "")]
Stream GetList(Stream value);
}