2012-03-01 31 views
1

我有一个IIS托管WCF服务与获取文件,并将其存储WCF,上传字节[]多头需要时间

我做了一些试验用6.5MB的文件服务器上的一个功能,它带我去上传它4.6分钟allthough它应该需要约2分钟,

任何人都知道如何加快过程?我真的需要上传到快

ServiceManager.UploadFile(fileName, FilesHelper.FileToByteArray(filePath)); 


public static ServiceCallResult UploadFile(string fileName, byte[] data) 
     { 
      Stopwatch sw = Logger.StopwatchInit(); 
      VsServiceClient vs = new VsServiceClient(); 
      EndPointSelector(vs); 
      vs.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0); 
      try 
      { 
       bool result = vs.UploadMediaFile(fileName, data);; 
       sw.StopAndLog(fileName); 
       return new ServiceCallResult() { IsSuccessful = result }; 
      } 
      catch (Exception ex) 
      { 
       sw.StopAndLog(fileName,ex); 
       return new ServiceCallResult() { IsSuccessful = false , Message = ex.Message }; 
      } 
      finally 
      { 

       vs.Close(); 
      } 
     } 




<webHttpBinding> 
    <binding name="NewBinding0" maxBufferSize="160000000" maxBufferPoolSize="160000000" 
    maxReceivedMessageSize="160000000"> 
    <readerQuotas maxDepth="160000000" maxStringContentLength="160000000" 
     maxArrayLength="160000000" maxBytesPerRead="160000000" maxNameTableCharCount="160000000" /> 
    </binding> 
    </webHttpBinding> 
    </bindings> 
    <behaviors> 
      <endpointBehaviors> 
       <behavior name="vsAjaxBehavior"> 
        <enableWebScript/> 
       </behavior> 
      </endpointBehaviors> 
      <serviceBehaviors> 
       <behavior name="vsServiceBehavior"> 
        <serviceMetadata httpGetEnabled="true"/> 
        <serviceDebug includeExceptionDetailInFaults="true"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
     <services> 
    <service behaviorConfiguration="vsServiceBehavior" name="VsService"> 
    <endpoint address="" behaviorConfiguration="vsAjaxBehavior" binding="webHttpBinding" 
    bindingConfiguration="NewBinding0" contract="VsService" /> 
    </service> 

Web服务与IIS7 EC2小实例的服务器上运行,服务功能中的代码需要不到1秒,因此,所有的浪费的时间是客户端服务器上转让。

另一件事,是不是在使用的服务器所以大部分只有一个单一的用户使用它的时候......

任何想法?

感谢

回答

1

尝试使用streaming。无论如何,直接上传和WCF上传之间总是有显着的时间差异,因为WCF有很多额外的处理和抽象,但是您报告的时间确实很长。