download - ASP.NET MVC serving files using return File and default Content -


i amazed speed differences between when place file in content folder , let user download it, , when send file.

this result in 100kb/s in dedicated server 2 open section

public filepathresult getfile() { return file("c:\\a.pdf", "application/octet-stream"); } 

when play same file in "webroot\content\a.pdf" , download it, capable open 10 sections , speed 1000kb/s. 10 times faster.

can indicate how send file user max speed?

i tried various methods, like:

  1. the 1 above (return file)
  2. using response.write using loop , buffer , detecting http header request partial content
  3. the fdm (free download manager) software default opens around 3 sections. download manager acts strange when file served via "content/" folder capable open 10 sections no configuration changes.

i found answer, , related processmodel of asp.net

allow me show how maximize potential of server microsoft limited default. don't need pay more upgrade managed dedicated server or hire microsoft professional configure web server high speed, because telling secret in post.

optimize server sending file speed

  1. optimize worker threads, application web.config
   <system.web>    <processmodel maxworkerthreads="1000" maxiothreads="1000" minworkerthreads="10" miniothreads="10"/>    </system.web> 
  1. set c:\windows\microsoft.net\framework , c:\windows\microsoft.net\framework64 file aspnet.config
<configuration>     <system.web>     <applicationpool          maxconcurrentrequestspercpu="5000"         maxconcurrentthreadspercpu="0"          requestqueuelimit="5000" />     </system.web>   </configuration> 
  1. configure in iis, max worker processes : 20 (in application pool)

  2. configure machine.config in c:\windows\microsoft.net\framework\v4.0.30319\config , c:\windows\microsoft.net\framework64\v4.0.30319\config

    search processmodel, , change machineonly machinetoapplication

<section name="processmodel" type="system.web.configuration.processmodelsection, system.web, 

version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" allowdefinition="machineonly" allowlocation="false" />

to 
<section name="processmodel" type="system.web.configuration.processmodelsection, system.web, 

version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" allowdefinition="machinetoapplication" allowlocation="false" />

  1. you must restart application pool take effect

once iis has full power, send file user downloading in high speed, user highest speed can isp package. default microsoft limit potential of server because assume server intel atom.

thank you


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo