问题
I am using a HTTP handler to raise a file download.Basically code in the 'ProcessRequest' retrieves data from the database,creates a temporary copy of the existing template spreadsheet with a GUID as its name and writes data retrieved from the DB into it cell by cell using COM,raises a file download and deletes the temporary spreadsheet created.This whole process usually takes around 4-5 mins.But when we tried to concurrently test this process it took around 15 mins.
I am wondering if setting 'IsReusable' boolean to true could help improving the performance.But I am not sure,if it is safe.
Could someone please help me with it?
**Update:**Because I am using a different filename for each of the temporary files created I am assuming that there wont be safety issues.But still not sure.
回答1:
The IsReusable
property will do just what you think it does. Instead of constructing a brand new Handler to be used each time a request is made, it will reuse the existing one. If you have instance variables that are created in the constructor it could boost performance, but only if they are expensive to create.
Also, if you are maintaining any kind of state in the handler, then whatever state you leave it in will be there for the next request. This could have unintended side effects.
If the bulk of your process happens in the ProcessRequest
method, then your bottle-neck is there, and you should use profiling to see where you can speed up performance.
回答2:
The IsReusable property is only set to true if this instance of the HttpHandler is expected to handle multiple requests. There may a different Web.Config setting that addresses your issue, perhaps the executionTimeout attribute of the httpRuntime property:
<httpRuntime appRequestQueueLimit="100" executionTimeout="600" />
More info:
http://articles.sitepoint.com/article/web-config-file-demystified
来源:https://stackoverflow.com/questions/3720046/setting-httphandler-isreusable-property