Tuesday 1 December 2009

Invalid ViewState... ScriptResource.axd and Performance issues of late

I've been looking recently into performance issues we were experiencing on one of our websites. This meant delving back into IIS application pools, running red-gate memory profiler and generally having a blast ;)

The code base is part legacy code, which has not been extended correctly. The memory profiling highlighted one key factor which I think is vital, and is stressed in multiple performance articles scattered across the web.

Be careful with session state, if it's too big your system is going to suffer

The code base has allot of complex objects which in turn have complex children, these are placed into session state and hang around eating up the w3wp.exe memory. All the session objects are run in-proc which is necessary because the objects have components that cannot be serialized, so extracting the session state to an out of proce provider was not an option.

We ended up increasing the memory on the server, to buy us sometime to reduce the complexity of the session objects and find alternative methods of clearing the session state periodically.

Another issue on the same server was we were seeing allot of Invalid ViewState error messages in the application event log. I read this article which pointed my focus in the right direction.

Basically the DOCTYPE's on my website pages were set to use strict XHTML, and the ScriptResource.axd which contains all client side AJAX javascript was being incorrectly parsed by the browser. Therefore when sent back to the server the viewstate was invalid, and so we got the error.

The solution was to change the browser to use the HTML DOCTYPE. This however messed up the display of the website, which I'm currently looking into now.

No comments: