Lab 3: Using DynamoDB as a Session State Provider

Lab 3 Using DynamoDB as a session State Provider

This service is know as a NoSQL database service and it is really good for application because of consistent, single-digit millisecond latency at any scale. this one is complete manage by cloud database and support both things like document and key-values. Use of this data base is in many ways like IoT, Gaming, web and mobile technology. You are able to create up to 256 tables in one account.

This lab Will cover following steps which is as bellow,

  1. Making DynamoDb table.
  2. Store value in here
  3. Managing Nuget packets
  4. Checking session table like for the cart item list

 

 

Step 1. To create a AWS Dynamo DB just login and then go to the services click on DynamoDB service which is in database option,

After that we are in the main page of DynamoDB on that page click on Create table,

 

After click on create table, give a table name and also a primary key for the table so by using this key value can fetch in further process, In here I have to change that primary value by session id instead of  hash,

 

After unchecked a checkbox we are able to make custom read and write capacity for this table, I can go with 3 for read and 1 for write capacity,

 

After heat on create we are able to view a new created table for session state as bellow,

 

Step 2. After complete this process just go to the account credential page of ours account to download file for access key which is required for the connection of the table to the local application, Bellow you can see the option that how to get Access Key for the account .For Access Key we are able to active only one key at a time and if we are not able to download that file at the same time we have to create that key again.

 

Step 3. After complete all the process on cloud just on the visual studio and open application on it and then go to tools and click on NuGet Packet Manager and select manage NuGet packages for Solution

NuGet is a Visual Studio 2010 extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework.

Nuget is a free, open-source package management system offered by the Microsoft ASP.Net team to the developer community to ease the process of integrating any 3rd party open source component into our project.

 

After opened new window of the NuGet packet click on browse to download AWS SDK for .NET  and also session provider extension packets for the application. I show which version is proper working for which packet so install that packet for that version,

 

 

 

Step 4. Till this time We all know that this code is only for the local browser if we want to make it globally then we have to change a code so I am going to do it in this step, open web.config an change some code which helps to create a session for the product on the cloud services which is as bellow,

 

In upper image you can see a code in side a red border that was change in code and inside the green border  where we put AWS access ket and also a region for that services,

Also, We have to add a namespace [Serializable] in ShoppingCart.cs file of the application. By using this Serialization, it is possible to converting an object into a stream of bytes in order to store the object or transmit it to a database. Its main purpose is to save the state of an object in order to be able to retrieve data when ever we need,

 

Step 5. After this changes just browse application in to the browser and add some product to the cart and buy it,

 

Here We saw the list of the product which we selected to buy,

 

 

At the end you can see about the value in the DynamoDB table which was inserted by the complete process.

 

Errors That can Arise:

This is the error that I got While running application before installing package:

To resolve this error I have to install that package which i show in step 3.

 

Conclusion
In this lab We to store product in session table and also whenever we login again we can finnd that same product in the cart table and we can procude further. So it will  be easy for the user and confi also because some times they went logout for  some problems so after again login they suppose to get same thing where they left.

Budget Plan
For Amazon DynamoDB on first login customer get 25 GB free storage with 25 read and write capacity that will enough to handle up to 200 million requests per month and also 2.5 million read capacity from DynamoDB streams for free.

Charges also depend on the how many times you access a specific table for read and write in table that  your created like for Asia Pacific Sydney region writing capacity is 36,000 per hour this is a maximum level and charges is $0.0074 per hour. Same for Read capacity is 180,000 per hour and this one and the charges is $0.0074 which is same to write one.

For storage in the same region which I talking about, first 25 GB storage per month is free but after that charges is $0.285 per GB per month. Now for DynamoDB streams, there is no charge for the active this services but there is a charges for reading data from the DynamoDB Streams. Like For the same region Asia Pacific Sydney, for every month, this first 2.5 million DynamoDB Streams read request units are free after that $0.02282 per 100,000 DynamoDB Streams read request. There is some data transfer charges but when it will happen in the outside of the region then it will charge as per how many GB you want to transfer like for first 10 GB per month it is $0.140.

For cost reduction make sure you can create this services in the same region where you need to use it else you will get charge for data transfer which is free for the same region. Also With DynamoDB Triggers, you only pay for the number of requests for your AWS Lambda function and the duration for which your AWS Lambda function executes. You are not charged for the reads that your AWS Lambda function makes to the stream (via DynamoDB Streams) associated with the table.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s