I wanted to get some numbers to prove my reading that DynamoDB Key-Value storage has better read performance compare to relational DB (MySQL, PostgreSQL, Aurora). So I decided to compare READ Latencies of DynamoDB & AWS-Aurora (which is a/c to AWS website - "up to five times faster than standard MySQL databases and three times faster than standard PostgreSQL databases")
Step1: Created a Table in Aurora with the following Schema and added 1.02 million records to that table.
Table gift_log (
gift_uuid BINARY(16) NOT NULL,
user_uuid BINARY(16) NOT NULL,
parent_uuid BINARY(16),
operation_time TIMESTAMP,
operation VARCHAR(20) NOT NULL,
gift_type VARCHAR(20) NOT NULL,
parent_type VARCHAR(20),
relation_type VARCHAR(20),
PRIMARY KEY (gift_uuid)
);
Used Golang Client that uses MySQL driver for database/sql package to query table.
Step2; Created DynamoDB table with following Attributes. Added 1 million Items to the table. DID NOT use any sort key. All queries used Partition key.
Table: GiftLog {
gift_uuid Binary (Partition Key)
user_uuid Binary
operation_time Number,
operation String,
gift_type String,
parent_type String
}
Used Golang Client that uses AWS Go-SDK to query DynamoDB table.
AURORA
startTime := time.Now().UnixNano()
rows, err := db.Query("SELECT * FROM gift_log WHERE gift_uuid=?", giftIDsToRead[i])
endTimt := time.Now().UnixNano()
DynamoDB
queryInput := &dynamodb.QueryInput{
TableName: aws.String(tableName),
KeyConditions: map[string]*dynamodb.Condition{
"GiftUUID": {
ComparisonOperator: aws.String("EQ"),
AttributeValueList: []*dynamodb.AttributeValue{
{
B: giftIDsToRead[i],
},
},
},
},
}
startTime := time.Now().UnixNano()
resp, err := svc.Query(queryInput)
endTime := time.Now().UnixNano()
Aurora Latency: 543.89 DynamoDB Latency: 2934.96 usec
These numbers don't seem right. Am I not comparing apples to apples?