Lab 2 Using RDS with ASP.NET Applications
Amazon RDS (Relational Database Services) make relational database very easy to use and also operate and make more flexible. By using RDS, administrator make her/his self more free and also a benefit is for cost efficient, and more re-sizable capacity. There are total six different database which is provide by AWS like Amazon Aurora, PostgreSQL, MYSQL, MariaDB, Oracle and Microsoft SQL server. Most benefits on AWS RDS, they will manage backup, software patching, recovery and also automatic failure detection. You can automatically backups performed when ever you need and also own backup snapshot for that database.
This lab Will cover following steps which is as bellow,
- Create RDS using MYSQL.
- Create Connection with MySQL Workbench.
- Create RDS Replica.
- Check for fail-over.
Step 1. In here first login in AWS and go to services then click on RDS to create Database Instance as given bellow image,
After click on RDS services in Database for creating a new instance for Database just click on Launch a DB Instance,
After click on Create New Instance select a DB engine or a provider you want to go, in here I will go with MYSQL and click on Select,
After select engine for DB, Select which kind of class for DB instance you want also you can see a licence model and also Engine Version for this DB, Also provide you want to create DB in multiple zone or not if yes select multi-AZ Deployment yes which shows in given image as bellow,
In the bottom on the same page provide a storage volume which we want, I will go with 5 GB, and then give a identification name ans also user name and the password which will use to connect this Instance.
Before going further make sure you already created security group if not then go to VPC services and then click on Security group from the left side panel and create it for future step use,
After creating Security group select VPC also security group for this instance, select available zone for this instance and also provide a name of the DB,
At the bottom side just maintain a retention period for backup if I select 0 days means I do not want to create backup for my database,
After click on launch DB Instance We will get a success message as bellow.
After all this process just go to the instance tab from the left side panel and see the status for the creating Instance, It must be available for use. Also copy that endpoint for this instance.
Step 2. After that status go to the Security group and change inbound setting for this instance as provide bellow image, in here use MYSQL/Aurora type using TCP protocol and allow all traffic to access this instance, we also change this IP by specific IP
I also give a custom source by using my IP which is my systems IP and by this rule this connection only allow of this network IP,
Step 3. For next step open MYSQL workbench from where we are going to connect this created MYSQL RDS instance, for this click on new connection and provide all details like connection name, hostname where I provide end point of that instance, port number also, after that user name and the password of that instance, and hit on test connection so you will get a other popup of successful connection message as provide bellow,
After get successful connection with RDS just run a provided SQL script to create schema and tables,
After creating tables click on product table and and import CSV file for the product list as bellow, you can see the list of the product from the product table.
Step 4. Creating Replica for this RDS Instance just select RDS instance and go to the action and then select create read replica,
After that also select class of that replica and also name of the instance and for which instance we are going to crate this replica just select that RDS, also select available zone for this,
After creating this replica just add all the credential and then test that connection,
Step 5. Changes in config file and put connection for this RDS over there as bellow image,
After that open default web page to change the connection string form StoreSqlDb to StoreSqlDbReplica,
After that try to create account after browse a application in the browser,
Enter requirement field and hit on create user,
After creating user you can see I already login with that user name,
You can also saw a new user entry in the database of that user,
After rebooting of primary RDS the application was still working as we saw in this image and i also login with the same user as in bellow image,
In this lab We learn about hot to create DB instance and how to use it with different types of class and also at how many different zone we want to use to create same DB instance. After creating this also there are very good thing to create replica means to create same DB in the same zone or using different zone so if one DB will fail down at that time we will divert all traffic on the other one and we can manage the complete process.
For Amazon RDS here is no any minimum charges like other services so in this service what ever we use they will charge accordingly to our use and need. Like in here I am using db.t2.micro instance so they will charge only $0.026 per hour and it is also base on on which region I am creating this instance if I create a same instance in US West (Oregon) then they will charge $0.017 per hour. For this also base on how many available zone we use if we use multiple zone in same region then they will charge for the same instance type is $0.052 per hour. Second thing is how many storage we need if We use general purpose SSD storage in Asia Pacific region using single zone they will charge $0.138 per GB per month and in Asia Pacific region for multiple zone for same storage type they will charge $0.276 per GB per month. For same region for Input output capacity charges for is$0.11 per IOPS per month for single zone but for multiple zone they will charge $0.22 per IOPS per month. For both type in IOPS storage rate is same as in SDD but in magnetic storage it is different like for storage in single zone in same region is $0.11 per GB per month and I/O rate is $0.11 per 1 million request. But for multiple zone they increase storage rate form $0.11 to $0.22 per GB per month but I/O rate is same.
So I think by using this service from AWS there are many benefits related to cost and we save lot just we have to decide in which region our business are running and how many zone we need if we take out a exactly requirement then it will beneficial.