Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheServiceTicketManager cleanup issues #41

Closed
sunnymoon opened this issue Mar 6, 2016 · 4 comments
Closed

CacheServiceTicketManager cleanup issues #41

sunnymoon opened this issue Mar 6, 2016 · 4 comments

Comments

@sunnymoon
Copy link

When the memory pressure is hig on the HttpContext.Current.Cache, it gets cleared by IIS. Then the user is actually "logged out" in the middle of an otherwise authenticated session.

Implementing the storage of local tickets on the HttpContext Cache seems flawed by design, since collection of items might not be totally controlled.

@phantomtypist
Copy link
Contributor

@sunnymoon this could be solved by the RFC for a distributed cache provider in issue #61, correct?

I think any time you use an in-memory cache, such as System.Web.Caching or System.Runtime.Caching, you are going to run into the possibility of IIS recycling the app pool. The in-memory caching just isn't durable.... there is no serialization to disk.

I guess another possibility is making a cache provider for the proxy and service ticket managers that is in-memory, but also serializes to local disk for durability. Any chance you'd be up for writing that?

@lanorkin
Copy link
Contributor

lanorkin commented Aug 9, 2017

@phantomtypist I don't think backing up in-memory to file is good idea. It will require significant efforts to implement it in a good way (like support multithreading, possible issues with file read/write, issues with network drives etc), and it still won't work in distributed environments, like scale up in Azure etc.

There are many ways which will lead to in-memory cache cleanup, so I think it would be just good to emphasize that default (and the only) implementation of cache is in-memory. Actually it is even commented in source code here https://github.com/apereo/dotnet-cas-client/blob/master/DotNetCasClient/State/CacheProxyTicketManager.cs#L27 in CacheServiceTicketManager summary:

An IServiceTicketManager implementation that relies on the ASP.NET Caching model for ticket
storage. Generally this implies that the ticket storage is maintained locally on the web
server (either in memory or on disk). A limitation of this model is that it will not
support clustered, load balanced, or round-robin style configurations.

I think highlighting it in the repository readme to warn users is really good idea.

For real-life production cases something like in-memory cache + database can be useful, but that is really part of #61 IMO.

@phantomtypist
Copy link
Contributor

I'll be finalizing the 1.1.0 release today and at the same time cleaning up a bit of the documentation on the readme. I'll add a note for that. Some of the content from the readme will be migrated to the GitHub wiki in this repo too.

I'm going to close this issue as the in-memory caching is working by design (in .NET, that is.) If anybody wants a scenario where the tickets survive an IIS or AppPool recycle, then they'll have to use the option(s) eventually created by issue #61.

@sunnymoon
Copy link
Author

We've implemented an alternative with a static global variable. The reallity is if the application pool gets recicled we'll loose all logged in session, true.

But actually the webcache is actually cleared by .net at any point in time, nevermind the pool recycling. It depends only on memory pressure and not memory exhaustion...

Please read
https://msdn.microsoft.com/en-us/library/system.web.caching.cache.effectivepercentagephysicalmemorylimit.aspx

For additional details...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants