Last post Jun 17, 2019 03:56 PM by bruce (sqlwork.com)
Jun 17, 2019 02:57 AM|jal2|LINK
Asp.Net MVC Session seems detrimental to our performance.
I'd like to just use a ConcurrentDictionary as an alternative but I need Session-IDs to maintain separate info for each browser. How do I get SessionIDs if I've disabled Asp.net Session?
Maybe I could set Session to ReadOnly. But will that really put an end to Session-Locking?
Two questoins then:
(1) Is there an alternative way to get Session-IDs?
(2) For a given controller, is ReadOnly Session truly lock-free?
Jun 17, 2019 07:34 AM|Brando ZWZ|LINK
As far as I know the ConcurrentDictionary is also store the data into the local machine's memory. I couldn't understand why you use this as an alternative.
Normally, if you find the session will effect your application's performance, we will modify the session provider.
For example, we could use redis as the the session provider instead of using inproc. That means it will use the redis instead of the memey storage. It will increase your web application performance.
More details about how to use redis as the session provider, you could refer to below article:
Jun 17, 2019 03:56 PM|bruce (sqlwork.com)|LINK
as a sessionid is just a guid in a cookie, you could easily roll your own sessionid, and store in a cookie. a concurrent dictionary would be similar to inproc session. you will need to expire and remove session data just like inproc session, or you could
have memory issues. also like inproc, a recycle will lose session data.
the session state handler also updates the expiration date of session cookie on each request, so you should do the same.
note: if you upgrade to asp.net core, you get async session with no locking.