Duration: 60 minutes
The purpose of the lab is to implement Amazon DynamoDB as the backing store for session state in an ASP.NET Core application. Optionally (given time) add support for session state in distributed applications by storing cookie encryption keys in AWS Parameter Store.
The ASP.NET Core Session middleware stores session information in memory (in process) with the default implementation of IDistributedCache. Storing session in memory has drawbacks, including a lack of durability, the inability of session state to survive failure of the process or the underlying hardware, and no way to query session information for analytics. Additionally, when scaling out an application horizontally (using a web-farm, containers or serverless platforms), having the state tied to the web-application requires implementing “sticky sessions”, which introduces complexity and load-balancing problems.
Amazon DynamoDB is an ideal store for session state - it’s durable, scalable and has single-digit millisecond response times. By storing the cookie-encryption keys used by the Session middleware in AWS Parameter store, we can also scale out our solution horizontally without using sticky sessions.
The following exercises should be completed in order for this lab:
Create an Amazon DynamoDB table using the AWS Management Console
Create an ASP.NET Core MVC web-application project and add Session support
Implement IDistributedCache that reads/writes to DynamoDB, configure it in Startup, and test locally.
(Optional) Add support for distributed applications by implementing IXmlRepository and test locally.
The following are the prerequisites required in order to complete the lab:
Microsoft Visual Studio 2017 or above installed on your computer
AWS Toolkit for Visual Studio