REALTIME
RECORDIN
G OF DATA
IN AWS
DYNAMO
DB
BY: Shelly & Sagar
overview
■ BRIEF HISTORY OF DATA PROCESSING
■ RELATIONAL (SQL)VS. NONRELATIONAL
(NOSQL)
■ Why noSQL?
■ ACIDVS CAP
■ DynamoDB- what is it?
■ DynamoDB ARCHITECTURE
■ Conditional Writes
■ Provisioned throughput
■ QUERYVS SCAN
■ Operations
■ Benefits
■ Limitations
■ DEMO
TIMELINE OF
DATABASE
TECHNOLOG
Y
RELATIONAL (SQL)VS. NONRELATIONAL
(NOSQL)
Optimised for storage Optimised for compute
Normalized/relational Denormalized/hierarchical
Ad hoc queries Instantiated views
Scale vertically Scale horizontally
Good for OLAP Built for OLTP at scale
SQL NOSQL
DATA STORAGE FORMAT IN SQL
DATA STORAGE FORMAT IN SQL
Why noSQL?
■ DataVelocity – Huge data getting generated
in less time
■ DataVariety – Structured, semi-structures
and unstructured
■ DataVolume –Terabytes and petabytes of
data
■ Dynamic Schema – Flexible data model
■ Auto-sharding – Horizontal scalability
■ Continuous Availability
■ Integrated Caching
■ Replication – Automatic replication to support
high availability
■ Dynamic provisioned throughput
Acid vs CAP
■ ACID properties relates to relational databases
• Atomicity
– Requires each transaction to be all or nothing
• Consistency
– Brings databases from one valid state to another
• Isolation
–Takes care of concurrent execution and avoid overwriting
• Durability
– Committed transactions will remain so in the event of power loss,
crashes etc.
■ CAP theorem relates to noSQL database
• Consistency
– All nodes see the same data at the same time
• Availability
– A guarantee that every request receives a response about whether it
was successful or failed
• Partition tolerance
–The system continues to operate despite arbitrary message loss or
failure of part of the system)
DynamoDB-
what is it?
■ Fully managed nosql database service on
AWS
■ Data model in the form of tables
■ Data stored in the form of items (name –
value attributes)
■ Automatic scaling
■ – Provisioned throughput – Storage scaling
– Distributed architecture
■ Easy Administration
■ Monitoring of tables using CloudWatch
■ Integration with EMR (Elastic MapReduce)
■ – Analyze data and store in S3
BENEFITS OF DYNAMODB
 CONSISTERNT,PREDICTABLE PERFORAMNCE
• single milli second latency
• < 5ms reads OR <10ms writes
• backed by SSD drives
 FLEXIBLE DATA MODEL
• key/attribute pairs
• no schema required
• easy to create and adjust
 SEAMLESS SCALABILITY
• no table size limits
• unlimited storage
• no downtime
 DURABLE
• consistent disk writes only
• replication across data canters and availability zones
DynamoDB ARCHITECTURE
PRIMARY
KEY
(MANDATO
RY FOR
EVERY
TABLE) –
HASH OR
HASH +
RANGE
DATA
MODEL IN
THE FORM
OF TABLES
DATA
STORED IN
THE FORM
OF ITEMS
(NAME –
VALUE
ATTRIBUTE
S)
SECONDAR
Y INDEXES
FOR
IMPROVED
PERFORMA
NCE
–
LOCALSEC
ONDARYIN
DEX
–
GLOBALSE
CONDARYI
NDEX
• SCALAR
DATA TYPE
(NUMBER,
STRING
ETC) OR
QUERYVS
SCAN
• Query
– Search based on primary key and examines only matching data
– Maximum 1MB result
– Query result sorted by range key
– Query result can be opted to give strong consistency
– Query can be done based on secondary index
– Requires less provisioned throughput
– Query performance depends on amount of data retrieved
• Scan
– Examines every item and then applies filter
– Maximum 1MB result
– Scan result is always eventually consistent
– Required high provisioned throughput
– Scan performance depends on table size
– Secondary index does not have any impact on scan performance
– Parallel scan can be performed usingTotalSegments
Components of the System
Nodemcu
DHT11 temperature and
moisture sensor
OLED Display
Architecture of the system
Code –To
connect to
AWS IOT
server
■ #include "FS.h"
#include <ESP8266WiFi.h>
#include <PubSubClient.h
#include <NTPClient.h>
#include <WiFiUdp.h>
const char* AWS_endpoint = "a3hu9vk57nb9k8-ats.iot.us-east-
1.amazonaws.com"; //MQTT broker ipvoid callback(char* topic, byte*
payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
}
WiFiClientSecure espClient;
PubSubClient client(AWS_endpoint, 8883, callback, espClient)
Library for
showing data on
OLED Display
■ #include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED
display width, in pixels
#define SCREEN_HEIGHT 64 // OLED
display height, in pixels
// Declaration for an SSD1306 display
connected to I2C (SDA, SCL pins)
Adafruit_SSD1306
display(SCREEN_WIDTH,
SCREEN_HEIGHT, &Wire, -1);
Library for
reading from
DHT sensor
■ #include <DHT.h>
void loop()
{
float h = dht.readHumidity(); // Reading
Temperature form DHT sensor
float t = dht.readTemperature(); //
Reading Humidity form DHT sensor
float tF=(t*1.8)+32;
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT
sensor!");
return;
UPLOADING
CODETOTHE
HARDWARE
CREATINGTHE URLTO CONNECTTO
AWS IOT CORE
STRATINGTHE MQTT PROTOCOLTO
RECEIVE DATA
DATA RECEIVEDTHROIGHT MQTT
PROTOCOL
DATA STORED IN AWS DYNAMO DB
DATA SEEN FROMTHE OUTPUT
SCREEN OF ARDUINO IDE
LETS GO FOR
DEMO
LIMITATION
S of
DynamoDB
64KB limit on item size (row size)
1 MB limit on fetching data
Pay more if you want strongly consistent data
Size is multiple of 4KB (provisioning throughput wastage)
Cannot join tables
Indexes should be created during table creation only
No triggers or server side scripts
Limited comparison capability (no not_null, contains etc)
References ■ https://docs.aws.amazon.com/amazondyn
amodb/
■ http://en.wikipedia.org/wiki/Consistent_ha
shing
■ https://youtu.be/vCRXqVld8_c
■ https://youtu.be/28FS2qix2u4
■ https://electronicsinnovation.com/storing-
esp8266-data-into-amazon-dynamodb-
using-aws-iot-coremqtt-arduino/
■ https://www.slideshare.net/AmazonWebSe
rvices/introduction-to-amazon-dynamodb-
73191648
THANKYOU
Dynamodb ppt

Dynamodb ppt

  • 1.
    REALTIME RECORDIN G OF DATA INAWS DYNAMO DB BY: Shelly & Sagar
  • 2.
    overview ■ BRIEF HISTORYOF DATA PROCESSING ■ RELATIONAL (SQL)VS. NONRELATIONAL (NOSQL) ■ Why noSQL? ■ ACIDVS CAP ■ DynamoDB- what is it? ■ DynamoDB ARCHITECTURE ■ Conditional Writes ■ Provisioned throughput ■ QUERYVS SCAN ■ Operations ■ Benefits ■ Limitations ■ DEMO
  • 3.
  • 4.
    RELATIONAL (SQL)VS. NONRELATIONAL (NOSQL) Optimisedfor storage Optimised for compute Normalized/relational Denormalized/hierarchical Ad hoc queries Instantiated views Scale vertically Scale horizontally Good for OLAP Built for OLTP at scale SQL NOSQL
  • 5.
  • 6.
  • 7.
    Why noSQL? ■ DataVelocity– Huge data getting generated in less time ■ DataVariety – Structured, semi-structures and unstructured ■ DataVolume –Terabytes and petabytes of data ■ Dynamic Schema – Flexible data model ■ Auto-sharding – Horizontal scalability ■ Continuous Availability ■ Integrated Caching ■ Replication – Automatic replication to support high availability ■ Dynamic provisioned throughput
  • 8.
    Acid vs CAP ■ACID properties relates to relational databases • Atomicity – Requires each transaction to be all or nothing • Consistency – Brings databases from one valid state to another • Isolation –Takes care of concurrent execution and avoid overwriting • Durability – Committed transactions will remain so in the event of power loss, crashes etc. ■ CAP theorem relates to noSQL database • Consistency – All nodes see the same data at the same time • Availability – A guarantee that every request receives a response about whether it was successful or failed • Partition tolerance –The system continues to operate despite arbitrary message loss or failure of part of the system)
  • 9.
    DynamoDB- what is it? ■Fully managed nosql database service on AWS ■ Data model in the form of tables ■ Data stored in the form of items (name – value attributes) ■ Automatic scaling ■ – Provisioned throughput – Storage scaling – Distributed architecture ■ Easy Administration ■ Monitoring of tables using CloudWatch ■ Integration with EMR (Elastic MapReduce) ■ – Analyze data and store in S3
  • 10.
    BENEFITS OF DYNAMODB CONSISTERNT,PREDICTABLE PERFORAMNCE • single milli second latency • < 5ms reads OR <10ms writes • backed by SSD drives  FLEXIBLE DATA MODEL • key/attribute pairs • no schema required • easy to create and adjust  SEAMLESS SCALABILITY • no table size limits • unlimited storage • no downtime  DURABLE • consistent disk writes only • replication across data canters and availability zones
  • 11.
    DynamoDB ARCHITECTURE PRIMARY KEY (MANDATO RY FOR EVERY TABLE)– HASH OR HASH + RANGE DATA MODEL IN THE FORM OF TABLES DATA STORED IN THE FORM OF ITEMS (NAME – VALUE ATTRIBUTE S) SECONDAR Y INDEXES FOR IMPROVED PERFORMA NCE – LOCALSEC ONDARYIN DEX – GLOBALSE CONDARYI NDEX • SCALAR DATA TYPE (NUMBER, STRING ETC) OR
  • 12.
    QUERYVS SCAN • Query – Searchbased on primary key and examines only matching data – Maximum 1MB result – Query result sorted by range key – Query result can be opted to give strong consistency – Query can be done based on secondary index – Requires less provisioned throughput – Query performance depends on amount of data retrieved • Scan – Examines every item and then applies filter – Maximum 1MB result – Scan result is always eventually consistent – Required high provisioned throughput – Scan performance depends on table size – Secondary index does not have any impact on scan performance – Parallel scan can be performed usingTotalSegments
  • 13.
    Components of theSystem Nodemcu DHT11 temperature and moisture sensor OLED Display
  • 14.
  • 15.
    Code –To connect to AWSIOT server ■ #include "FS.h" #include <ESP8266WiFi.h> #include <PubSubClient.h #include <NTPClient.h> #include <WiFiUdp.h> const char* AWS_endpoint = "a3hu9vk57nb9k8-ats.iot.us-east- 1.amazonaws.com"; //MQTT broker ipvoid callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println(); } WiFiClientSecure espClient; PubSubClient client(AWS_endpoint, 8883, callback, espClient)
  • 16.
    Library for showing dataon OLED Display ■ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
  • 17.
    Library for reading from DHTsensor ■ #include <DHT.h> void loop() { float h = dht.readHumidity(); // Reading Temperature form DHT sensor float t = dht.readTemperature(); // Reading Humidity form DHT sensor float tF=(t*1.8)+32; if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return;
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
    DATA STORED INAWS DYNAMO DB
  • 23.
    DATA SEEN FROMTHEOUTPUT SCREEN OF ARDUINO IDE
  • 24.
  • 25.
    LIMITATION S of DynamoDB 64KB limiton item size (row size) 1 MB limit on fetching data Pay more if you want strongly consistent data Size is multiple of 4KB (provisioning throughput wastage) Cannot join tables Indexes should be created during table creation only No triggers or server side scripts Limited comparison capability (no not_null, contains etc)
  • 26.
    References ■ https://docs.aws.amazon.com/amazondyn amodb/ ■http://en.wikipedia.org/wiki/Consistent_ha shing ■ https://youtu.be/vCRXqVld8_c ■ https://youtu.be/28FS2qix2u4 ■ https://electronicsinnovation.com/storing- esp8266-data-into-amazon-dynamodb- using-aws-iot-coremqtt-arduino/ ■ https://www.slideshare.net/AmazonWebSe rvices/introduction-to-amazon-dynamodb- 73191648
  • 27.