Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Web Farm - Setup - Caching - Sessions #6347


User avatar
0
[email protected] created

We are trying to scale up our application to run across multiple servers but are struggling to get this working.

Environment:

  • Docker Containers - AWS Fargate
  • AWS Application Load Balancers
  • Redis
  • Linux
  • Kestral (not IIS)

The problem seems to be around sharing the session information - I looked into it (there isn't much documentation for this so I could be wrong) and it would seem that sessions are just dealt with in the Cookies rather then storing them in a Cache?

From what I can see the Cache encryption/decryption is based off MachineKey which in an environment like above - changes every time a deploy is made (invalidating everyones sessions by making the cookies unreadable) and is different on every instance of the container.

I am trying to work out how to store this MachineKey so every container can encrypt/decrypt the cookies it looks like this is possible by using redis to store this: Microsoft.AspNetCore.DataProtection.Redis provides this ability but the Redis Setup is in Web.Core and the Cookie stuff seems to be handled by Web.Mvc (its the only thing that already has Microsoft.AspNetCore.DataProtection as part of cookies but adding: services.AddDataProtection().PersistKeysToRedis(); requires a redis connection that only exists in Web.core

Has anyone been able to sort this on there applications? It seems fundamental to 1. not clearing out sessions every time an application is deployed 2. scaling without running one BIG Server without load balancing and redudancy.


1 Answer(s)