How do windows azure sites handle the session?

I studied one of the new offers in azure windows. In particular, "Websites", and I can not find anything about how it processes session data. Somebody knows? I moved the slider to 2 instances, and it all seems to β€œjust work”, but I would feel better about using it if I knew that it was sharing session data (or not?)

+5
source share
5 answers

If you want to know more about the Windows Azure website architecture, I would suggest looking at this session with TechEd 2012 Windows Azure Websites: under the hood

+5
source

You have several options for solving this problem.

  • sql solution

  • table storage solution

  • memcache solution

Sql is a classic solution. Sql handles all sessions using classic sql queries.

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

Memcache is the best solution. Azure provides a cluster of "cache servers" to store the session (or other serializable objects). It really scales easily and works really fast. I use this solution in my production environments with 0 problems and very good results.

To implement Memcache, you just need to add these lines to 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 costs and want to maintain the best performance, go to memcache solution. If you want your expenses to be really low, go to table storage.

+5
source

Since the linked video above is out of date, I thought I would share what I could find regarding the sessions on Azure.

Azure uses Application Request Routing .

ARR skillfully monitors users' connections by providing them with a special cookie (known as cookie affinity) that allows them, after subsequent requests, to know which server instance they were talking to. Thus, we can be sure that as soon as the client establishes a session with a specific server instance, he will continue to talk with the same server while his session is active.

Link: https://azure.microsoft.com/en-us/blog/disabling-arrs-instance-affinity-in-windows-azure-web-sites/ .

+2
source

Are you customizing ASP.NET 4.5?

If you do not explicitly configure any providers with 4.5, it will by default use the ASP.NET generic providers, which are now included in Machine.config. Thus, the default SQL Session State provider will be used. I would expect it to use the local DB, so I'm not sure how this will split the state.

You can test it by opening several sessions, and then return the number of instances by one and see if some sessions have lost state or not.

The load balancer may use session similarity, in which case you may not notice if it shares the session state.

+1
source

How many web roles do you have? If you save it to 1, you should be fine, but you can read here about how multiple web roles are going to create the same session state of the problems you encountered if you are using a web farm. When starting a web farm, the option saves the session state in your db. So, as you can imagine, if you need to run several web roles, you can rely on Azure sql (although Table Storage is really cool and probably great for something like session state)

But for a more direct answer to your question, you can use several web roles to distribute the processing load, and the web role is just the front-end of the web application and content hosted within IIS. "So, if you use only one web role, your application is probably working fine, but just keep in mind that if you ever need to scale your web roles, it will lead to a continuation of the session.

-1
source

All Articles