Reputation: 1551
I have a pretty standard (Asp.Net Core) web app which is deployed in Azure. I'm using multiple app servers that are not using session affinity, so the same user might hit different servers during subsequent requests.
I'd like to use Azure DocumentDB to handle some data storage for me. The usage pattern is that each logged-in user will issue a command up to 10 times per minute to read and then update a data record. Each user will read and write one record. Each user has their own record.
After reading the DocumentDB documentation regarding consistency, I'm left with a few question on how they work.
My requirements are
I'm thinking I need to use "Session" consistency, but I'm not sure how to handle the SessionToken in the context of a web farm scenario.
I suppose I could store the SessionToken as a cookie, but what is the lifespan of a DocumentDB "session"? The documentation seems to be silent on this. Also, what happens if the user logs out and back in and the session is expired?
Maybe I don't have a full understanding of how writes are replicated within DocumentDB and perhaps the solution to all of this in how the read/write regions for DocumentDB are configured?
If I have one primary read/write DocumentDB in my primary data center region and a secondary "read" DocumentDB in another region, does that address my consistency and fail-over requirements?
Any clarification would be much appreciated!
Upvotes: 1
Views: 269
Reputation: 8003
DocumentDB session tokens never expire. You can certainly follow the cookie pattern to guarantee strong consistency for a user across login/logout. If the account is setup with bounded staleness, you can also guarantee strong reads by using a second DocumentClient that only reads from the write region of the account.
Upvotes: 2