tags:

views:

42

answers:

1

I have 2 different classes that i am testing to send files to the browser. First one is at http://pastebin.org/1187259 uses Range specific headers in order to provide resuming

Second one is at http://pastebin.org/1187454 uses chunk reading to send large files.
Both work fine with one different. First one is wayyy slower than the second one in the sense of download speed. With first one i cannot pass over 80KB/s with second one i can get as fast as possible.

I have done few tests and result was same. Is this an illusion or is there something on the first one that slows download speed?

I also noticed that first one seems to block other requests. For example if i request a file from server with first one server will not respond to my other request to it until download finish. Even if I request different page. It doesn’t do that if i open different sessions from different browsers.

Thanks.

+1  A: 

At last! I managed to fix the issue by adding EnableSessionState="ReadOnly" to the download page.

See http://www.guidanceshare.com/wiki/ASP.NET_2.0_Performance_Guidelines_-_Session_State

"Use the ReadOnly Attribute When You Can

For pages that only need read access to session data, consider setting EnableSessionState to ReadOnly.

Why

Page requests that use session state internally use a ReaderWriterLock object to manage session data. This allows multiple reads to occur at the same time when no lock is held. When the writer acquires the lock to update session state, all read requests are blocked. Normally two calls are made to the database for each request. The first call connects to the database, marks the session as locked, and executes the page. The second call writes any changes and unlocks the session. By setting EnableSessionState to ReadOnly, you avoid blocking, and you send fewer calls to the database thus improving the performance. "

nLL