2011-12-08 1 views
1

私はIISホストWCFサービスを1台のサーバーで実行し、Windowsサービスを別のサーバーで実行しています。 Windowsサービスはスレーブとして機能し、MS Sync Frameworkを使用してIISホストのWCFサービスに接続することにより、各サーバーのデータベースを同期させます。MS Sync FrameworkとIISホストWCFサービスとの2mbエントリの同期テーブルには10分かかります

私は同期されているテーブルの1つにファイルの内容を保存していますが、エントリは少し大きくなる可能性があります(1エントリあたり10MB)。私の問題は、これらのエントリを同期しようとすると、同期に時間がかかることです。

同期中のテーブル:

[Id] [int] IDENTITY(1,1) NOT NULL, 
[Client] [uniqueidentifier] NOT NULL, 
[Date] [datetime] NOT NULL, 
[Content] [nvarchar](max) NOT NULL, 

私は次のようにさまざまなコンテンツサイズの1つのエントリとの同期を計時しました。

  • 500キロバイト - 1分20秒
  • 1メガバイト -
  • 1,5mb 3分 - 6分30秒
  • 2メガバイト - 9分50秒

(Visual Studioでデバッグするときにタイミングがほぼ同じでした

なぜこのように長い時間がかかるのですか?

WCFサービスの設定:

<configuration> 
    <system.web> 
    <httpRuntime maxRequestLength="2147483647" /> 
    <compilation debug="true" targetFramework="4.0"/> 
    </system.web> 

    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

Windowsサービスの設定:

<configuration> 

    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_ISyncServiceContract" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
      <message clientCredentialType="UserName" algorithmSuite="Default"/> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <client> 
     <endpoint address="http://localhost:60000/SyncService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISyncServiceContract" contract="SyncServiceReference.ISyncServiceContract" name="BasicHttpBinding_ISyncServiceContract"/> 
    </client> 
    </system.serviceModel> 

    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 

</configuration> 

答えて

1

あまりにも多くのデータが含まれていると、nvarchar(max)フィールドに問題があるようです。私はフィールドをvarbinary(max)に変更しました。今では、同じデータの同期が、以前使用された時間のほんの一部で終了しています。

0

あなたは、クライアント/サーバーライブラリを使用している場合は、通信は基本的に(XMLにシリアライズされたデータセットされて終わりますそれは技術的には「シリアライズ」されていませんが、ほぼ同様です)。だから、肥大化しているという評判を持つデータセットから始めましょう。さらに、変更された各行のデータの前後にデータセットが格納され、データ量が倍になります。 XMLにシリアライゼーションを追加すると、オーバーヘッドが増えます。そのペイロードはWebサービスコールにラップされます。これによりオーバーヘッドが少し増加します。皆さんは、非常に大量のデータをワイヤを介して転送することを検討しています。あなたが見ている時間の経過は、すべてのデータを転送するのにかかる時間です。

これは、あなたの質問を超えて、これを解決するためにいくつかの推奨事項は以下のとおりです。それは、ワイヤを介して転送されるデータを圧縮する時

  • ルック。そこにいくつかのwcf + gzipプロジェクトがあります。
  • データベースからファイルをファイルシステムに移動し、別のWCFサービスを使用してファイルを転送することを検討することをお勧めします。
+0

私はあなたの意見を見ますが、信じがたいと感じます。時間の経過がデータの転送にかかる時間に起因する場合、サービスとデータベースの両方を同じマシン上でローカルにデバッグする場合、同じ時間がかかりません。たとえ2 MBが200 MBまで膨らんだとしても、同じマシンとの間で転送するのに10分かかることはありません。 – Avilan

+0

@Aviian、同じディスクから読み書きしている場合は、 –