Multithreading 当请求被激发时,WCF请求时间会增加

Multithreading 当请求被激发时,WCF请求时间会增加,multithreading,wcf,iis,parallel-processing,Multithreading,Wcf,Iis,Parallel Processing,我有一个服务(WCF服务托管为IIS),您可以在这里看到: [ServiceContract] public interface IInquiryService { [OperationContract] [WebGet(UriTemplate = "/Inquiry/{VisitDatetime}/{Plaque}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMe

我有一个服务(WCF服务托管为IIS),您可以在这里看到:

[ServiceContract]

    public interface  IInquiryService
    {

        [OperationContract]
        [WebGet(UriTemplate = "/Inquiry/{VisitDatetime}/{Plaque}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]

        Inquiryview Inquiry(string VisitDatetime, string Plaque);
}
使用此工具:

 public class InquiryService : IInquiryService
    {
        private DataContext _ctx;
        private INajaService _najaService;
        private IUserService _userService;
        public InquiryService(DataContext ctx, INajaService najaService, IUserService userService)
        {
            _ctx = ctx;
            _najaService = najaService;
            _userService = userService;
        }

        public  Inquiryview Inquiry(string VisitDatetime, string Plaque)
        {

            !!.....service
        }
}
这是服务网络配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
  </system.web>
  <system.serviceModel>
    <!--<added for security  />-->
    <bindings>
      <webHttpBinding>
        <binding>
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <!--<added for security  />-->
    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization serviceAuthorizationManagerType="Inquiry.Service.AuthorizationManager, Inquiry.Service" />
         <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Inquiry.Application.ServiceImplement.InquiryService" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="Inquiry.Domain.Service.IInquiryService" behaviorConfiguration="web" />
      </service>
      <service name="Inquiry.Application.ServiceImplement.NajaInquiryService" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="Inquiry.Domain.Service.INajaInquiryService" behaviorConfiguration="web" />
      </service>
    </services>
    <protocolMapping>
      <!--<add binding="basicHttpsBinding" scheme="https" />-->
      <add binding="webHttpBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Methods" value="GET, POST,PUT,DELETE" />
      </customHeaders>
    </httpProtocol>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    *****
  </connectionStrings>
</configuration>
创建请求的函数:

public Result Inquiry(string Plaque)
        {
            string result_ = "";
            ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return true; };
            DateTime start;
            DateTime end;
            using (WebClient ClientRequest = new WebClient())
            {
                ClientRequest.Headers["Content-type"] = "application/json";
                ClientRequest.Encoding = System.Text.Encoding.UTF8;
                NetworkCredential credential1 = new NetworkCredential("1", "1");
                ClientRequest.Credentials = credential1;
                start = DateTime.Now;
                result_ = ClientRequest.DownloadString(ServiceHostName + "/Inquiry/2012-12-28" + "/" + Plaque);
                end = DateTime.Now;

            }
            var javascriptserializer = new JavaScriptSerializer();
            Result temp = javascriptserializer.Deserialize<Result>(result_);
            temp.StartDate = start;
            temp.EndDate = end;

            return temp;
        }
公开结果查询(字符串)
{
字符串结果\=”“;
ServicePointManager.ServerCertificateValidationCallback+=(se、cert、chain、sslerror)=>{return true;};
日期时间开始;
日期时间结束;
使用(WebClient ClientRequest=new WebClient())
{
ClientRequest.Headers[“内容类型”]=“应用程序/json”;
ClientRequest.Encoding=System.Text.Encoding.UTF8;
NetworkCredential credential1=新的网络凭据(“1”、“1”);
ClientRequest.Credentials=credential1;
start=DateTime.Now;
结果=ClientRequest.DownloadString(ServiceHostName+“/Inquiry/2012-12-28”+“/”+plate);
end=DateTime.Now;
}
var javascriptserializer=新的javascriptserializer();
Result temp=javascriptserializer.Deserialize(结果);
温度开始日期=开始;
temp.EndDate=结束;
返回温度;
}
我更改了一些IIS配置,如您所见:

具有多线程的2000请求次数:

763 762 844 919 165 558 527 574 518 209 238 227 252 221 304 198 283 296 291 266 271 197 195 238 241 297 238 315 201 247 305 319 309 322 341 213 304 236 339 228 234 384 429 383 409 345 387 360 287 327 388 413 455 434 442 410 423 368 368 271 290 285 281 284 284 297 320 302 309 311 325 333 156 310 348 326 531 308 304 293 327 310 309 306 307 287 305 302 358 318 399 318 304 426 314 299 323 643 350 631 385 613 313 397 469 276 298 290 264 288 572 353 296 439 317 426 359 519 334 478 331 496 313 513 358 321 433 324 439 405 381 386 361 363 342 363 386 225 307 421 329 501 502 403 410 417 404 458 443 437 624 435 373 635 359 563 670 468 378 371 500 419 539 463 563 457 590 559 575 516 576 545 541 535 480 589 446 636 511 454 631 470 641 640 483 426 642 423 627 416 598 404 602 446 413 631 400 585 401 556 393 553 419 409 421 388 904 379 381 888 365 380 939 951 482 971 628 647 599 689 716 628 646 748 629 647 591 539 497 603 488 441 582 545 439 454 547 558 491 454 571 512 530 560 564 574 583 603 603 467 590 437 733 424 664 378 630 404 502 511 947 544 944 624 619 897 605 911 649 1009 671 683 641 700 625 633 632 616 576 619 504 450 382 681 551 563 462 443 556 459 479 479 491 535 487 603 508 533 631 575 690 577 691 670 575 533 672 616 517 589 471 441 550 551 544 545 544 712 742 625 732 636 736 751 641 641 816 638 574 558 674 539 612 459 572 607 704 663 645 641 649 639 640 655 682 538 733 625 613 905 634 713 629 711 697 783 650 736 696 700 701 733 712 713 724 727 664 664 689 668 664 664 616 648 621 619 630 628 615 626 622 638 605 488 493 705 589 673 575 495 555 806 553 789 555 721 557 723 558 543 719 689 532 528 726 683 543 513 690 526 527 466 782 701 518 704 725 512 621 723 732 660 670 753 699 714 725 749 763 816 755 703 836 608 817 800 582 787 551 524 987 541 559 626 625 631 651 656 1378 653 1594 673 1429 702 711 1352 730 1394 1474 763 773 1506 759 1499 809 897 853 820 935 777 911 775 1004 759 984 759 781 999 957 773 947 778 931 803 818 910 924 837 790 877 818 893 778 874 790 790 879 868 797 830 760 859 765 815 832 836 782 838 756 758 849 841 760 863 759 800 749 929 768 939 723 946 755 961 959 779 744 944 749 960 925 738 934 770 867 871 855 853 871 1225 954 1261 955 1258 990 1247 1276 1025 1287 1075 1290 1277 1081 1125 1079 1076 915 1063 950 992 963 1121 1233 1269 1154 1141 1230 1150 1188 1224 1287 1253 1356 1263 1385 1220 1398 1198 1390 1015 1375 1163 1037 1030 1142 1012 1116 975 1108 978 1090 947 1048 1085 1005 1081 1014 1136 1055 935 1183 940 1124 928 1219 1217 897 1225 943 1250 1035 1217 969 1124 1008 1041 1181 1110 1016 1119 1154 1180 1190 1187 1232 1229 1230 1200 1183 1070 1556 1020 1068 1548 1017 1000 1655 977 1731 1021 1758 1017 1028 1725 1027 1825 1734 1068 1713 1074 1022 1648 1050 1354 1044 1414 1097 1113 1483 1124 1091 1456 1124 1511 1088 1484 1453 1117 1186 1186 1484 1499 1194 1178 1134 1422 1387 1125 1080 1390 1380 1112 1084 1412 1427 1074 1046 1398 1061 1413 1014 1019 1429 1307 1079 1078 1368 1040 1001 1372 1379 1179 1410 1265 1421 1293 1427 1407 1352 1440 1364 1406 1440 1440 1453 1468 1498 1483 1532 1513 1585 1580 1541 1509 1550 1506 1525 1581 1567 1603 1585 1567 1606 1554 1591 1513 1465 1586 1521 1432 1517 1482 1462 1508 1536 1565 1536 1539 1557 1595 1518 1572 1464 1562 1437 1541 1448 1461 1535 1491 1559 1444 1431 1594 1661 1347 1590 1385 1645 1376 1644 1625 1529 1418 1432 1518 1445 1431 1532 1568 1560 1556 1591 1523 1714 1547 1709 1520 1725 1508 1745 1474 1481 1717 1498 1708 1528 1608 1661 1689 1640 1358 1653 1716 1680 1604 1624 2048 1590 1796 1601 1596 1855 1877 1622 1586 1909 1549 1979 1603 1980 1928 1570 1570 1986 1592 2025 1569 1507 1996 1781 1975 1491 1684 1547 1570 1925 1481 1888 1852 1558 1834 1582 1635 1859 1648 1612 1702 1696 1566 1631 1574 1627 1770 1630 1781 1652 1806 1768 1685 1788 1753 1722 1752 1736 1814 1697 1721 1831 1607 1778 1659 1775 1717 1862 1723 1899 1570 2002 1598 1959 1585 1706 2036 2180 1957 2152 2047 1956 2000 1997 1967 1958 2009 1941 1913 1888 1874 1890 1838 1887 1737 1827 1777 1856 1640 1410 1403 1422 1449 1395 1522 1422 1467 1298 1309 1344 1316 1617 1592 1570 1628 1602 1603 1570 1554 1461 1481 1474 1426 1242 1209 1305 1306 751 1016 766 877 908 753 712 874 591 889 587 889 625 836 615 611 510 607 494 453 477 762 453 644 536 558 743 630 577 469 617 563 490 442 566 532 409 371 396 275 384 265 385 294 391 258 423 286 261 355 361 278 354 244 335 234 224 224 198 235 182 163 214 374
175

Windows具有出站http流量的ha限制,请查看该配置,并根据您的需要进行调整


什么操作系统承载您的服务(客户端和服务器)我的服务是hos
public Result Inquiry(string Plaque)
        {
            string result_ = "";
            ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return true; };
            DateTime start;
            DateTime end;
            using (WebClient ClientRequest = new WebClient())
            {
                ClientRequest.Headers["Content-type"] = "application/json";
                ClientRequest.Encoding = System.Text.Encoding.UTF8;
                NetworkCredential credential1 = new NetworkCredential("1", "1");
                ClientRequest.Credentials = credential1;
                start = DateTime.Now;
                result_ = ClientRequest.DownloadString(ServiceHostName + "/Inquiry/2012-12-28" + "/" + Plaque);
                end = DateTime.Now;

            }
            var javascriptserializer = new JavaScriptSerializer();
            Result temp = javascriptserializer.Deserialize<Result>(result_);
            temp.StartDate = start;
            temp.EndDate = end;

            return temp;
        }