Are there any special considerations when Caching ASP.NET Pages on Azure?
I understand that page caching is managed in memory by IIS, but does it rely on the same providers as asp.net caching?
I need to cache hundreds of pages each averaging 100KB and I wonder if this will function on Azure as expected because there is a memory limitation considerations on Azure.
I'd recommend Azure Cache services for Output Caching ASP.NET pages. It's simple to configure and can be used by all VM nodes in your deployment.
Azure Cache relies on DistributedCacheOutputCacheProvider. You can also control your Cache Quota size.
Completely agree with #SilverNonja comments however I just wanted to comment about "Memory limitation consideration on Azure". I don't consider your objective is limited due to the limitation in Windows Azure memory because you sure can get a lot in single VM however can u server that many user from one single VM. You really have to run multiple instances of same application and then having the local machine specific cache is the problem.
With Cloud solution where you have more then one instances are running creating a local cache based solutions bring several problems because the requests are being served by different instances at different times. Having a centralize location for shared resources is the best where all the instances can look for the data is the best method and that's why Windows Azure Cache is the best/fast option available for you to use.
Also here is very Simple Sample to use Azure Cache with ASP.NET application:
https://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/
You might wanna try the latest Windows Azure Caching (Preview). It has a better feature set and improved latencies. For more info - http://social.msdn.microsoft.com/Forums/en-US/windowsazuredata/thread/9a2dbd9f-1b9d-4249-a48b-216d9dfdc2bc
Related
We have a multi-tiered architecture running .Net on the UI, then various other tech on additional EC2 instances.
Using load balancers from Amazon's web services, we can scale up as many of those instances as required by the usage. However, we have a big problem with multiple Web UI services.
A User logged in from the 1st instance of the Web UI, cannot make calls to/from the second instance of the Web UI. The Anti-Forgery token prevents this and results in a lot of errors. It doesn't take long and the entire system starts hanging, running CPU usage to 100% and crashing.
I've tried/found:
Removing all Anti-Forgery attributes. It did not work, plus it leaves us open to attacks.
Sharing the Anti-Forgery token and session information across to the other instance. Not sure how to do this cleanly, and it violates our security settings.
Isolating User's to only a single instance... but I cannot find a way to implement this. Only seen a few mentions of it.
I've googled quite a bit and haven't had any luck finding a solid solution.
This is an emergency, so any ideas would be greatly appreciated!
Thank you in advance.
Update:
Here are some resources we are finding:
https://aws.amazon.com/getting-started/hands-on/setting-up-a-redis-cluster-with-amazon-elasticache/
.net + Sharing session over multiple servers with redissessionstateprovider + sessionstate custom mode
Kubernetes + Redis: The antiforgery token could not be decrypted
Good video tutorial for .NetCore: https://www.youtube.com/watch?v=jwek4w6als4
I am migrating the my old ASP.NET Web Forms project to ASP.NET Core Web API and Frontend Angular. in my older application storing user information instace and it's values(like assigned groups,permissions,and other user information).i am going to use JWT i can't store all information in JWT,so should i continue session in my asp.net core application or retrieve this information from database in each request?
Is there any other Best practices are available in modern application development?
Multiple options for this, depending on what you need:
Angular cache. If the data is not sensitive, you can use the rxjs observables to cache some data on the application side. Nothing wrong with some data stored on the browser. Since you are coming from a full postback application, the SPA caching is most times equivalent to old Session object.
Depending on the implementation you might need some cache on the server side too. Since as mentioned you'll have multiple servers, I'd suggest only caching lookups and such, not user related data. If you implement stickyness with servers and sessions (not recommended), this is still an option.
Distributed cache. You might have heard of Redis and such? This is also an option to store cache data to a third service, accessible by all server instances.
It all comes down to complexity vs speed. If the queries are simple enough and lightning fast, then it might be useless to store them in any cache anyway.
I've done all my development of an ASP.net website under the assumption that it will be deployed to a single server. Since we're expanding we're looking at hosting scalably in the cloud with multiple VM's running the website. We are taking expert advise on deployment, but the hired help we have are expecting an ASP.net site that will work in a load balanced environment.
I'm researching what in my solution may need to change for it to work on a multi server deployment.
So far, I've found that all my caching needs to be done on a distributed cache such as NCache. The code changes required for this don't look too bad.
We don't use sessions for user authentication, it's all done via cookies so I don't think that will cause any issues.
What other general considerations need to be made? (I've looked for a guide but can't find one).
If you use sessions to store data between calls, you are going to need to move to the SqlServerSessionProvider. you'll also need to have the same machine key for all servers on the load balancer or viewstate won't work.
Here's a link from Scott Hanselman that list the gotchas.
Let us say i have a website developed in asp.net webforms on .net 4.0 frame work and this needs to be migrated to cloud hosting like rackhosting.
This website currently uses asp.net default membership for user management and also uses several session variables for storing temporary variables.
This website is hosted on a dedicated server hosted inhouse.
so my question is
How to make it work on cloud hosting
One way of doing could be using MS Sql Server based session management
What else i need to take into consideration to make it work on cloud hosting
I have no experience with cloud hosting as one gets confused with the cloud hosting architecture provided by service providers. Microsoft Azure, Amazon etc..
any pointer to a good article and code examples would be great to start with
You will need to use a Session State Provider that will span the servers.
e.g. one that uses App Fabric (or other caching provider) or Sql Server
For sharing sessions you have 2 options:
1. Sticky sessions, easiest to implement because there are no changes to do in code, but you will not be able to autoscale (add or reduce the number of machines based on load). This will be just a setting on your load balancer, so you need to check if the load balancer of your cloud provider has this.
2. Out of proc session and here I suggest to use the ASP.NET Redis session provider (supported by Microsoft). Both AWS and Azure provide Redis as a servce, so it is easy to start with, you don't need to think of its administration. Most important out of proc will mean some code changes, at least marking your classes that go in session as Serilizable, but you will be able to autoscale.
We(our company) is hosting a asp.net C# Cloud Services with a Web Role for a Reporting WebSites.
Unfortunately, usage of the reporting Website is growth that original is only hosting with Medium Size VM and find out its having a memory leak that cause the Cloud Services is always down and stop working. End up we move to A7 VM(Okay, thats expensive) that solved our problem for 2-3 month.Somehow, new stuff develop new function develop that end up the memory is more than enough(its 56GB RAM) but the process is not really can fulfilled such expensive usage in the same time.
Looking for solution on the web and found out there was a shared cache that can be used.
We decided to move from A7 to XM VM (A7 not supported shared cache) and with a Dedicated Roles For Shared cahce.
What we wish to achieve is load balance between few instances(if one down, it will redirect to another instances) and having the dedicated roles stored all of our session stuff.Am i going the correct direction for this?
And if yes, how to achieve this? I look into this and is that really need to sign up a preview program for cache services for using this?
Appreciate for the advice and please point out my mistake if any.
**Somehow, after reading stuff from web i found out the above mention method is a new method and the old ways is In-Role Cache that i can see it from here. Is that possible to used this method for sharing Session State among multiple instances even if one of the instances is down and route to another instances that are available and used back the session?
The best option for you is to use the Windows Azure Cache Service (Preview). This will let you share session state among multiple instances of your application.
You will need to sign up for the preview service. the cache core is mature and customers are encouraged to use this service in their production applications.
This service lets you use the cache from multiple cloud services, allowing you to share data across applications too. Also, this removes the dependency for you to use XL VMs just because In-Role Cache wasn't supported on A7.
Also, to be clear, Cache has 3 flavors -
1. Shared Caching - This is a multi-tenant service and is being deprecated
2. In-Role Caching - Here the cache is deployed in your cloud service and can only be used from within the cloud service. This is of two types - Co-Located & Dedicated.
3. Cache Service (preview) - The newly released service.
There is nothing called Dedicated Shared Cache. :)