I'm working on a distributed application that runs on Windows Azure, but I'm new of this kind of environment. I have a question about server-side state management.
Where should I store global almost static data?
Because it is a distributed environment if a user makes a request to the application, there is no guarantee that subsequent requests will be routed to the same server and so I think that I should use Sql Azure or Table Storage Session Provider (but I've read that can be performance issues) to store the data.
I can also use Windows Azure AppFabric Caching that enables session maintenance.
What is the better solution to store global information that don't need to be secured? Is there something similar to "Application" (like Application["key"] = value)?
Thanks
Please see my responses on the following thread:
Microsoft Azure .NET 4.5 WebForms App : Session TimeOut / InProc / Single Instance
Specifics are below:
If you want to maintain session state you have to use one of the
following options
SQL Session State Provider using Azure SQL
Azure Table Session State
Session State with Azure Redis Cache
You can find details on how to do this at the following links:
Session State Management in Windows Azure Web Roles
Session state with Azure Redis cache in Azure App Service
The easiest way in my opinion is using Azure Redis Cache as noted in
the link above.
Let me know if this helps!
Definitely at that time perhaps, but now Azure Storage Tables :)
Related
I need my Web API to have caching to store some data. I have been researching caching on Azure and I can see that Microsoft recommends to use Redis cache.
Can I use the normal server's in-memory cache to store simple data which will only be accessed by the Web API or is Redis my only option.
Are there any limitations of server memory on Azure?
Of course, you can. Azure Redis cache is not the only option. You can consider to use Microsoft.Extensions.Caching.Memory like MemoryCache to store your simple data, and make sure the size of your data is less than the available tails memory size on Azure App Service which be restricted by the memory limit of Azure App Services for different tiers, as the figure below from App Service limits.
Meanwhile, even you can consider to implement your Web API by using Azure Functions with HTTP trigger which support more memory, please refer to Functions limits.
Hope it helps.
I have a MVC application deployed to Azure Web app.The web app required to scale out in multiple instances.
I want to use Session object (ASP.NET) to store some user data etc.(lightweight), so that can be retrieved quickly.I believe, session will be In-Proc with ARR ON setting.
I've the following questions
Is it ok to use session object in Azure web apps ,will it give
guarantee to use same In-Proc session if ARR is on.
If ARR turned off ,Should I use session object?
Because using Session itself makes application slow,what are the
other alternatives to store small data within Azure webapp/MVC(once authenticated user profile
related data) for quick access in application?
Using IN-PROC sessions in the cloud is a strict no. The reason to host to cloud is to have high availability which is done by having a distributed environment.
To answer your question, the ARR-Affinity cookie will affinitize the client requests to a specific instance. However, if the Process restarts or App-Domain recycles, then all the sessions will be lost. This is one of the primary reasons why Out-Proc session state management is suggested.
I would recommend against using In-Proc session state in any cloud scenario. I understand speed is a concern for you. For this consider using Redis Cache. Refer the documentation here: https://learn.microsoft.com/en-us/azure/redis-cache/cache-aspnet-session-state-provider
HTH
I want to know how windows azure websites manage it's session states across multiple instances. There's a lot of content on Internet about how to share session states on multiple instances using cloud services, but for websites I couldn't find a final answer.
The question How does windows azure websites handle session? has not an objective answer yet. The accepted best answer has a good suggestion, but you have to watch a video that has more than 1 hour.
Do you know how to do it? Can I just use InProc session state and windows azure will manage it across all instances automatically?
Thank you.
Looks like the options are:
Windows Azure Cache Service[1]. This is the new caching service that Microsoft is offering. Pricing starts from $12.50/month for 128MB of cache (this is preview pricing with 50% discount). According to [2] the latency for accessing the cache is around 1ms.
SQL Azure Accordign to Angshuman Nayak [3] relatively cheap, especially if you are already using SQL Azure for something else. As drawback he mentions potential performance issues, as you are normally using shared database. You also need to take care of cleaning up experired sessions.
Table Storage Angshuman [3] also provides some instructions on how to use the table storage to store sessions. He also mentions that the performance is not as good as with other solutions, but does not provide any numbers on this. The good thing in table storage is the pricing. Since it is pay-as-you-go there's not fixed monthly fee.
Based on this is seems to be that the Azure Cache Service is the way to go, unless the price is an issue.
[1] http://www.windowsazure.com/en-us/pricing/details/cache/
[2] http://weblogs.asp.net/scottgu/archive/2013/09/03/windows-azure-new-distributed-dedicated-high-performance-cache-service-more-cool-improvements.aspx
[3] http://blogs.msdn.com/b/cie/archive/2013/05/17/session-state-management-in-windows-azure-web-roles.aspx
InProc SessionState is not supported on Azure websites. You will have to use an external session state provider. This article shows external options and this article shows how to use SQL Azure as a session state provider.
In azure you can make use of Redis cache to handle session.
-->install nuget package RedisSessionStateProvider
-->set your SessionState mode to Custom in web.config and customProvider to RedisSessionProvider.
You can find more information from here
I have read the following from Azure in Action book:
"In Windows Azure, the state server, or out-of-process session state provider,
isn’t supported"
Can anyone tell me why this is not supported. They do not explain in the book. I would have thought I could run the state server and all web roles would be able to use this to read session data.
Thanks for replies
Windows Azure has the AppFabric Cache, which is well-suited for session storage. This went live about 2 weeks ago. You can see details in my StackOverflow answers here and here.
I can't give you an absolute answer on the lack of state server, other than the fact that until recently, Web Roles ran under Hosted Web Core instead of Full IIS and that might have had an impact on offering state server. Additionally, since all of your web role instances are equivalent, how would you specify which is the state server? And what happens if Windows Azure recycles that instance? I think this would be a big headache.
With the AppFabric Cache solution, this is cache-as-a-service, completely independent of your role instances, and managed for you. You simply get an endpoint, attach to the cache, and execute puts and gets on name/value pairs. Through the Azure portal, there's a Client Configuration button you click, and a magic chunk of xml gets generated for you - you place that in web.config, and you now have a custom session state provider that stores/retrieves session data to/from cache.
EDIT: On using SQL Azure for session state: SQL Azure doesn't have a SQL Agent, so you wouldn't have a background job periodically clearing the cache. There's an MSDN blog post showing how to get SQL Azure working as a session state provider (and using a worker role background process to perform session cleanup). However, I'd still recommend the AppFabric Cache solution.
According to MSDN, an azure service can conatins any number of worker roles. According to my knowledge a worker role can be recycled at any time by Windows Azure Fabric. If it is the true, then:
Worker role should be state less OR
Worker role should persist its state to Windows Azure storage services.
But i want to make a service which conatains client data and do not want to use Azure storage service. How I can accomplish this?
The velocity (whatever it is called) component of AppFabric is a distributed cache and can be used in these situations.
Azure's web and compute roles are stateless means all its local data is volatile and if you want to maintain the state you need to use some external resource to maintain that state and logic in your app to handle that. For simplicity you can use Azure drive but again internally its a blob storage.
You can write to local storage on the worker role by using the standard file IO APIs - but this will be erased upon instance shutdown.
You could also use SQL Azure, or post your data off to another storage service by HTTP (e.g. Amazon S3, or your own server).
However, this is likely to have performance implications. Depending on how much data you'll be storing, how frequently, and how big it is, you might be better off with Azure Storage!
Why don't you want to use Azure Storage?
If the data could be stored in Azure you have a good number of choices: Azure distributed cache, SQL Azure, blob, table, queue, or Azure Drive. It sounds like you need persistence, but can't use any of these Azure storage mechanisms. If data security is the problem, could you encrypt/hashing the data? Understanding why would be useful.
One alternative might be not persist at all, by chaining/nesting synchronous web service calls together, thus achieving reliable messaging.
Another might be to use Azure Connect to domain join Azure compute resource to your local data centre (if you have one), and use you on-premise storage.