This could be a bit complicated to explain and understand so I'll try my best to explain the set up.
Our media files (videos) are Flash video (.flv) files. These files are not directly accessible as a url that end with a .flv. As a result the bit rate throttling module does not intercept requests for these files automatically.
We had been using an IHttpHandler to serve these files because we authenticate the request coming from our site and from our video player before we issue the bytes. We read 8k chunks and write them directly to the OutputStream. This was working just fine, even for large files.
We then modified the handlers to incorporate the Bitrate throttling logic. The implementation works as expect, in terms of the burst and then throttling. However there is one thing I don't like about the we the bitrate throttling has been implemented and then there is an issue we're having to do with "Out Of Memory".
The one thing I don't like is that the http headers now include the bit rate information. These headers are visible across the internet and at the client. I don't believe there is any reason for this to be the case. I mean what's happening on the server end should remain at the server end (What happens in Vegas, stays in Vegas).
The bigger issue is that now the server is running out of memory each time we serve large files. This was not the case when there was no bitrate throttling in place. So it looks like IIS is buffering the bytes the handler issues (in a tight loop wirting 8K chuncks) because it is throttling the serving of these bytes. So if we're issuing a large file 800MB, the process is accumulating the bytes and eventually the process is out of memory.
The server has 8GB of memory and and at any time about 4GB is used (it kind of stays at this level) but we still see out of memory issues now.
My question is if IIS were to handling issuing the files itself, would this problem dissapear? Second, given the situation I mention at the start, is there a way we can still get IIS to issue the media files directly, *after* we authenticate the request? Also users should not be able to request these files directly using a url that ends with a .flv, we'd still like to intercept these requests and authenticate before allowing the files to be served.
I'm going to be trying an IHTTPModule that will intercept these requests and authenticate if the request is for our media files and allow or disallow. Does that sound ok?
The main issue (out of memory), is that "as designed"?