您的位置:首页 > 大数据

大数据传输下的WCF配置

2014-06-11 23:19 309 查看
主要还是要将传输模式改为流模式。

特别要注意的是: maxBufferPoolSize 不应该设置为 2147483647 (int/max) , 这个反而降低了传输速度, 甚至导致容易异常。

打个比方, 你要一个人搬两千吨水泥到邻居家, 一次应该搬多少呢? 如果你觉得一次应该搬两千吨, 那就恭喜你了……

maxBufferPoolSize="13000000"

这是本人试验出来的比较合适的值, 速度比较快……

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="NoneSecurity"
          maxBufferPoolSize="13000000" maxReceivedMessageSize="2147483647" messageEncoding="Text" transferMode="Streamed" sendTimeout="00:20:00" >
          <security mode="None"  />
        </binding>
      </basicHttpBinding>
    </bindings>
		<services>
			<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
				<!-- Service Endpoints -->
				<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NoneSecurity" contract="CommonLib.ITest">
					<!-- 
              部署时,应删除或替换下列标识元素,以反映
              在其下运行部署服务的标识。删除之后,WCF 将
              自动推导相应标识。
          -->
					<identity>
						<dns value="localhost"/>
					</identity>
				</endpoint>
				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
			</service>
		</services>
		<behaviors>
			<serviceBehaviors>
				<behavior name="WcfService1.Service1Behavior">
					<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
					<serviceMetadata httpGetEnabled="true"/>
					<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
					<serviceDebug includeExceptionDetailInFaults="false"/>
				</behavior>
			</serviceBehaviors>
		</behaviors>
	</system.serviceModel>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: