Velocity CTP3 Set up for ASP.NET Session State

Historically I have always viewed ASP.NET session state as “pure evil.” In-proc session state is about as unreliable as you can get given that you can have timeouts, ASP.NET might recycle itself, IIS might get bounced, no scalability, and cannot work in a web farm.  SQL Session state is very resilient and works in web farm scenarios but the performance is not good and at that point you might as well be better off writing your own strongly-typed data access layer rather than blobbing everything in and out of the database.  ASP.NET state server is the “middle man” of the various options but it’s not very fault tolerant. As part of Microsoft’s Velocity distributed cache they are providing an session state provider that is actually a *very* compelling option in my opinion for managing session state – more compelling than any of the traditional three choices.  It’s an in-memory distributed cache and it provides *both* high performance as well as robust fault tolerance potentially giving the best of both worlds.

I recently set up Velocity CTP3 in my development environment and there were a couple of minor gotchas.  Many of the samples on the web were either incomplete or outdated (i.e., based on previous versions prior to CTP 3).  The links I found most helpful (in addition to the Velocity help file) to get everything set up were:  Build Better Data-Driven Apps With Distributed Caching, How to: Configure a Session State Provider, and Andrea Col’s Blog.  Putting all these links together, I was able to get it working.  This post will walk through all of the set up steps in a single place.

Step 1 – Download and run installer

Download Velocity CTP 3 from this location.

Step 2 – Accept firewall defaults

Step 3 – Cache Host Configuration

Create a new database called “Velocity” in SQL Server Management Studio. On the Cache Host Configuration screen, specify these values:

  • Storage Location type: SQL Server database
  • Connection string: data source=<YourDBServer>;Initial Catalog=Velocity;Integrated Security=SSPI
  • Cluster Name: “DevCluster” (this could really be anything)
  • Cluster Size:  Small (1-4)

Leave all other defaults.


Step 4 – Configure with PowerShell

Start PowerShell Administration Tool found in the “Microsoft Distributed Cache” fold in Program Files off the Start menu.  The first time you run it can you choose “A” for always run software from this untrusted publisher.

Execute:  Start-CacheCluster

Execute:  New-Cache -CacheName ASPNETSessionCache -TTL 60

For verification you can look at the statistics for the cache you just created:

Execute:  Get-CacheStatistics -CacheName ASPNETSessionCache


Step 5 – Configure web.config

The best reference I found for the web.config for CTP3 is here.  You can copy/paste that and either leave as is or tweak if desired.  For example, you might want to change config values in the sessionState section for cookieless, etc. depending on your scenario.


Hope this helps ease the set up process.

posted on Friday, August 14, 2009 3:46 AM Print
# re: Velocity CTP3 Set up for ASP.NET Session State
4/5/2011 7:50 AM
its true that the performance and scalability results of a distributed cache can be different from a classic cache. it happens because of the fact that the cache in is stand alone and in process in nature, so it be good for smaller web farms only. but if you are running is a multi-server environmental and data is distributed over these servers then you need to have an in memory cache which should be distributed over these servers. in other words cache is only good for smaller web farms only but it will be not a good option to use it in a larger web garden. in such situations, the use of a distributed cache can be a better option. here is a good read about comparison between a cache and a distributed cache.
# re: Velocity CTP3 Set up for ASP.NET Session State
Zeeshan Umar
6/22/2011 1:26 AM
Really a nice little article. Velocity is really useful when we are working in different application pools or in a clustered environment.

Post Comment

Title *
Name *
Comment *  

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers

Google My Blog

Tag Cloud