Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does windows azure websites handle session?

Tags:

session

azure

I was investigating one of the new offerings in windows azure. Specifically "Websites" and i'm not able to find anything about how it handles session data. Does anybody know? I moved the slider up to 2 instances and it all seems to "just work", but I would feel better about using it if I knew for sure it was sharing session data (or not?)

like image 873
iamkrillin Avatar asked Dec 01 '12 05:12

iamkrillin


People also ask

What is session in Azure?

A persistent browser session allows users to remain signed in after closing and reopening their browser window. The Azure AD default for browser session persistence allows users on personal devices to choose whether to persist the session by showing a “Stay signed in?” prompt after successful authentication.

What are the options to manage session state in Windows Azure *?

Options for storing session state information in the Azure environment: In Microsoft Azure SQL Database – easy to set up, suitable for small projects or projects with read access to web pages. In Microsoft Azure Redis Cache – a dedicated cache service appropriate for more demanding projects.


2 Answers

If you'd like to learn more about the architecture of Windows Azure Web Sites, I would suggest watching this session from TechEd 2012 Windows Azure Web Sites: Under the Hood

like image 175
cory-fowler Avatar answered Sep 22 '22 07:09

cory-fowler


You have some options to solve this problem

  1. sql solution

  2. table storage solution

  3. memcache solution

Sql is the classic solution. Sql handles all sessions with classic sql requests.

Table storage works wonders (in my experience). It's really easy to scale and really simple to implement (just a few lines of code on your webconfig).

Memcache solution is the best solution. Azure provides a cluster of "cache servers" to store session (or other serializable objects). It's really easy to scale and works really really fast. I am using this solution on my production environments with 0 problems and a really good performance results.

In order to implement Memcache, you just need to add those lines on your web.config:

<configuration>
    <configSections>        
        <section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere"/>
        <!-- more config sections here -->
    </configSections>
    <dataCacheClients>
    <dataCacheClient name="default">
        <hosts>
        <host name="YOUR_NAME_HERE.cache.windows.net" cachePort="YOUR_PORT_HERE"/>
        </hosts>
    <securityProperties mode="Message">
            <messageSecurity authorizationInfo="YOUR_KEY_HERE">
                            </messageSecurity>
            </securityProperties>
    </dataCacheClient>
</dataCacheClients>
<!-- more configurations here -->

Summary

If you don't care about the costs and you wish to archieve best performance possible, go for memcache solution. If you need to keep your costs really low, go for table storage.

like image 43
Jordi Avatar answered Sep 22 '22 07:09

Jordi