AWS - Databases DynamoDB, RDS

AWS - Databases


There are 3 main database types in software world:

Relational databases (MySql, Postgre, Amazon RDS etc.)
Non-relational databases (Mongo, Amazon DynamoDB etc.)
Graph databases (Amazon Neptune, NebulaGraph etc.)

For your specific use case they have advantages and disadvantages.  We will cover relational and non-relational databases in this post. 

Relational databases - as name implies stores information based on defined relation. Organized by tables, columns, rows. Supports complex queries and joins.

Non-relational databases - contrary to the relational databases non-relational databases are more flexible. Documents, key/value, columns and graphs are some forms can be used to organize data.


Databases in Amazon


There are few ways to use database in AWS :
  1. Database on EC2 - We deploy any database software onto our instance and use it like this.
  2. Amazon RDS  - Amazon provided service, under the hood you can use (MySql,Postgre,Maria Amazon Aurora etc.) relational database engine.
  3. Amazon DynamoDB - Amazon provided service, non-relational database
  4. Amazon ElastiCache - Amazon provided service, in-memory database, good for speed-critical applications.
  5. Amazon RedShift - Data warehouse for large number of data. For data analytics purposes.

Amazon RDS 


Amazon RDS is managed relational database service. Good for consumer facing applications also referred as Online Transaction Processing applications. You must choose database instance type as well. Under the hood Amazon RDS uses Amazon Elastic Block Storage (EBS) and S3 (for backups). We need to choose database engine as well. 

Horizontal scaling - We can choose better database instance for better performance. 
Vertical scaling - We can use RDS read replica to scale it vertically enlighten the load of primary database. For example we can program web application so that it will read data from RDS read replica but write into primary database. 

Let's create our database instance:

  1.  Type RDS into the searchbar available in the main page.





  2. Click it and then Create database button




  3. During initialization step, do not forget to select free tier for testing purposes.




  4. That is it, when database created, click onto it, you will be able to create replicate from this instance.





One more thing if you want to be sure everyhing is set up nicely, you can try to use cli tool called "telnet IP 3306" if connection is successful you will see text appeared in the display asks your password, otherwise it will hang.



Amazon DynamoDB

Amazon DynamoDB is fully AWS managed highly available nosql database. It is fully serverless service allows document,key/value pair storing. Easily scalable with just one push of the button. 



Let's create nosql table and add some items using cli

  1. Type DynamoDB and click to the icon like below




  2. Create table



  3. This is one of the crucial part. If you already have experience with any database, you already know that primary key is important column in table to identify interested row. Additional to that there is secondary primary key that will be used for sorting purposes. Name them as you like.




  4. After creating table, we need to insert some data into it. To add bulk data into our freshly created database we need to use cloud-shell. You can click the icon highlighted in the screenshot below.





  5. And form a json object based on your needs. Here "test" is my table name, "PutRequest" will put the items into database. Check the example below, see that each entry named as "item" rest are columns and corresponding data entry.  




  6. Save the file as json file and upload it to cloudshell like below.



  7. Use the command below to insert objects into nosql database. If it is successful it won't display any error messages.



  8. If everything goes according to our plan, when you check dynamoDB service you will face with the items you have  just inserted.




  9. Even though this tutorial showed basic concept of Amazon dynamoDB, you can use aws-cli utility to sort,insert,delete,update and more.


  




Comments

Popular posts from this blog

S3 - Create a static website

S3