Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InProc vs. AppFabric session state with single web server

I have an ASP.Net MVC application which makes significant use of session to save state (including large data collections). At present, it is hosted on a single web server. The session is set to the default of InProc.

An issue arises whereby the application freezes for some users when many users are on line. I guess that this is because InProc session does not scale too well, and that there is only so much memory available to the process. (What happens if memory demand exceeds the available memory - does it swap out to disk?)

I have a couple of solutions in mind that would help with scalability. (a) Sql server session state; (b) Configure session state to use AppFabric caching. The first option looks like a good solution, except that it will affect performance and require stored items to be serializable.

What about configuring session state to use AppFabric caching (aka Velocity) in an environment where the single web server is also used as the cache host? How does this differ from InProc in this single-server environment? Will this provide more scalability and available memory than InProc, or will it essentially amount to the same constraints?

like image 394
Andy Thomas Avatar asked Jul 26 '12 21:07

Andy Thomas


1 Answers

You would be better off implementing AppFabric Cache for your scenario. As your system grows, you can increase the number of cache servers with each new web node - something you cannot easily do with SQL Server without additional cost. SQL Server licensing also costs much more than AppFabric - which is bundled with a Windows Server license.

The only benefit SQL Server will provide is recoverability, but for what you need, it's probably overkill.

See related SO post discussing AppFabric Cache vs. SQL Server for session.


As for AppFabric Cache vs. InProc...

You could put your AppFabric Cache on another server if you are running into memory limitations. You can't do this with InProc.

Here are some other miscellaneous benefits of the AppFabric Cache:

  1. Supports Local Cache to speedup retrieval costs involved in serializing/deserializing.
  2. Provides finer grained controls with respect to cache eviction and expiration policies.
  3. Supports compression of session contents to reduce network bandwidth.
  4. Blob mode versus single item retrieval to improve data retrieval for large objects.
  5. Same session state store can be used across multiple applications (via sharedId).
like image 99
SliverNinja - MSFT Avatar answered Dec 30 '22 11:12

SliverNinja - MSFT