6

BLサービスとしてWCFサービスがあります。サービスは混合トランスポートモードであり、BasicHttpBindingによってバインドされた10を超える異なるエンドポイントがあり、異なるコントラクトとそれらすべてに同じアドレスがあります。このサービスは、IIS-7のアプリケーションプールで実行されます。

問題は、サービスは正常に機能することですが、最初の呼び出しの後、WSDLを取得しても、w3wp.exeのメモリ使用量は300メガになり、サービスのメモリ使用量は絶えず増加し続け、すべての物理メモリを引き継ぎますサーバーの(98-100%)。メモリ不足の例外は発生しませんでしたが、この状況では他のアプリケーションとサービスの速度が低下するため、数日ごとにアプリケーションプールを手動で更新する必要があります。私はすでにメモリプロファイリングツールを使用しようとしましたが、問題の原因につながるものは見つかりませんでした。

誰かがこの問題に遭遇しましたか?もしそうなら、あなたは何をしましたか?

追加情報:

  • BLサービスはNHibernateに基づくDALフレームワークの上にあり、メモリリークがそこから発生していることはすでに除外されています。
  • 構成ファイル

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <appSettings>
        </appSettings>   
        <system.web>
            <compilation debug="true" targetFramework="4.0" />
            <httpRuntime maxRequestLength="20000" requestLengthDiskThreshold="20000" />
        </system.web>     
        <system.serviceModel>     
            <behaviors>
                <serviceBehaviors>
                    <behavior name="DefaultServiceBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                    </behavior>
                </serviceBehaviors> 
    
                <endpointBehaviors>
                    <behavior name="AnonymousBehavior">
                    </behavior>
                </endpointBehaviors>
          </behaviors>
    
          <bindings>
              <basicHttpBinding>
                  <binding name="SecureBinding" 
                   closeTimeout="00:10:00" 
                   openTimeout="00:10:00" receiveTimeout="00:10:00" 
                   sendTimeout="00:10:00" allowCookies="true" 
                   hostNameComparisonMode="StrongWildcard" maxBufferSize="65536000" 
                   maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000" 
                   transferMode="Buffered">
                      <readerQuotas maxDepth="20000000"
                       maxStringContentLength="8192000"
                       maxArrayLength="16384000"
                       maxBytesPerRead="4096000"
                       maxNameTableCharCount="16384000" />
                          <security mode="None">
                              <transport clientCredentialType="None"/>
                          </security>
                  </binding>
             </basicHttpBinding>         
        </bindings>
    
    <services>
    <service name="BL.Services.MyService"
    behaviorConfiguration="DefaultServiceBehavior">
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Security/Anonymous"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.IAnonymousClaimsService" />
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Domain/App"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.IAppService" />
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Domain/App"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.IAttachmentService" />
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Domain/Site"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.ISecurityService" />
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Domain/Transaction"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.ITransactionService" />
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Domain/ActiveDirectory"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.IActiveDirectoryService" />
    
    <endpoint address=""
    binding="basicHttpBinding"
    bindingConfiguration="SecureBinding"
    bindingNamespace="Domain/Report"
    behaviorConfiguration="WithSecurityContextInspector"
    contract="BL.Services.Contracts.IReportService" />
    
    <host>
    <baseAddresses>
    <add baseAddress="//MyService.svc" />
    </baseAddresses>
    </host>
    </service>
    </services>
    
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <defaultDocument>
    <files>
        <add value="MyService.svc" />
    </files>
    </defaultDocument>
    </system.webServer>
    </configuration>
    
4

3 に答える 3

6

AnkMannenが指摘するように、300MBは珍しいことではありません。頻繁に使用されるサービスは、約700MB以上を簡単に横ばいにする可能性があります。最も利用可能なサーバーメモリを消費しているが、メモリ不足の例外をトリガーしていないサービスの2番目の観察は、デフォルト以外の構成値が原因である可能性があります。

binding:
maxBufferSize="65536000"
maxBufferPoolSize="524288000"
maxReceivedMessageSize="65536000"
transferMode="Buffered"

readerQuotas:
maxDepth="20000000"
maxStringContentLength="8192000"
maxArrayLength="16384000"
maxBytesPerRead="4096000"
maxNameTableCharCount="16384000"

You are actually configuring WCF to consume excessive memory with the values you have chosen. Unless you have encountered a specific condition that required changing the default value for any of those attributes, don't change them. The only value I routinely change is maxReceivedMessageSize from a default of 64K to around 1 to 2 MB, if unavoidable. If you're routinely slinging around messages that are bigger than 3 MB, you should reconsider your data contract design. A lot of the performance issues WCF is accused of are actually misconfigurations not performance problems in WCF itself.

于 2012-11-19T14:29:24.090 に答える
5

長い検索の結果、問題が見つかりました。私たちのサービスは、作業単位パターンで多くの論理装置を使用しました。BaseLogicクラスから継承された各論理ユニット。BaseLogicユニットには、ファクトリを作成したEnterpriseLibraryUnityContainerプロパティがあります。呼び出しごとにこのファクトリの多くのインスタンスが作成され、このプロパティを静的プロパティに変更すると問題が修正されました。

于 2012-12-09T09:10:41.847 に答える
4

300MBへの最初の最初のジャンプは、私がアプリケーションで見たものと一致しています。その数を減らす方法を実際に見つけていませんが、それは時間の経過とともにその数字にとどまります。

メモリの増加部分については、標準のメモリリークまたは少なくともGCの問題のように聞こえます。エンティティフレームワークを使用していて、組み込みのVSプロファイラーではなく、Red Gates Memory Profilerなどのツールを使用してプロファイリングしましたか?

質問の情報に基づいて、これ以上具体的な答えを出すのは難しいです。

それまでの間、アプリケーションプールのIIS自動更新を使用してみてください。選択したしきい値に設定し、更新を自動的に処理できるようにします。

于 2012-11-19T10:04:22.043 に答える