Databases (DynamoDb, RDS) Flashcards
What type of DB is Dynamo Db
No SQL db
What are key features of Dynamo DB
DNAMO
- Distributed across multiple servers
- NoSQL (semi structured / unstructured data)
- Adapts provisioning (on demand or provisioned capacity)
- Managed Service (hardware, config, scaling, backup etc)
- Out of the box encryption (in transit and at rest)
What are key value pairs in Dynamo DB
data structure used to store and retrieve data
What is a sort key in Dynamo Db
organizes and orders items within the partition of a table (like a label / category)
Which has better performance scanning or querying Dynamo db
Query has better performance than scanning
Querying can be efficient with partition key and sort key
Scanning should be avoided because it is slow and more expensive
When would you use provisioned Dynamo DB vs on demand Dynamo DB
Provisioned is for predictable workloads with known read and write patterns
On demand capacity is for flexible, pay as you go pricing without the need to forecast usage
How do we provision and pay for a Dynamo Db table?
- Provisioned Dynamo DB table
- Expect 1 read per second can scale up or down by 2 - On demand Dynamo DB table
- spins up, answers request and turns off
Describe a real life use case for Dynamo DB
Netflix uses DynamoDB to manage customer meta data, preferences and session info because of its scalability, low latency, and high availability
- Ability to handle massive volumes of data is well-suited to the dynamic and high demand of Netflix
- Flexible data storage and retrieval of various types of customer data enables personalization and customization of user experiences.
What is RDS
Is the service that RUNS the database engine ie., oracle, sql
RDS is the database admin
What is Aurora?
Aurora is a db engine that can be managed with RDS
It is cloud native
Why would you want a Aurora Single Master
If you have a simple app that doesn’t need complex data distribution or multiple masters
It has ONE ‘master’ database that handles all read and write requests
It’s like a central librarian managing all books and can make changes to them
Why would you want Aurora Multi Master
If you have a globally distributed or highly responsive app
You will have multiple ‘masters’ capable of reading and writing at the same time
It’s like having multiple librarians who can check out and update books independently
Why do you need Aurora Multiple Read Replicas
create copies of your database for reading data, making ur app faster because you serve customers in different locations
Why would you need Aurora Serverless
- pay as you go
- auto scales based on demand
ideal for unpredictable apps
Where does elasticache fit in the architecture?
Elasticache sits between apps and dbs
ie., ec2 elasticache rds
It is a managed service you can used with caching engines such as REDIS or MEMCACHED
Name the 2 main types of keys used in Dynamo DB
Partition Key (Hash Key)
Sort Key (Range Key)
Elasticache is a managed service that you can use with which 2 caching engines..
REDIS
MEMCACHED
What does RDS stand for?
Relational Database Service
Why is RDS useful?
RDS makes it easier for users to run, manage and scale relational databases without the overhead of traditional database administration tasks
How do you identify and analyze slow performing SQL queries in your RDS database?
Enable slow log query feature
What does TDE stand for?
Transparent Data Encryption
What do you use Transparent Data Encryption (TDE) for?
Use Tranparent Data Encryption (TDE) to encrypt data at rest which protects the data
What is Systems Manager param store used for?
secure way to store and manage configuration data, secrets and other params
What is Systems Manager param store used for in RDS?
securley manages and stores configuration data and secrets
such as database credentials and other sensitive information, that can be securely retrieved by applications
What is Systems Manager param store used for?
Systems Manager param store allows you to securely store and manage configuration data, secrets and other params
Name the RDS database engine that was created by AWS and is entirely cloud native?
Aurora
Name the RDS storage that is a good option for a broad range of use cases such as providing single-digit millisecond latencies and cost-effective storage
General-purpose SSD
Which has more ElastiCache features. Redis or Memcached?
Redis has more features than Memcached
What is a projection expression?
It is a String that identifies the attributes you want when you perform a getItem, query or scan to read data from a table
Example:
aws dynamodb get-item \
–table-name ProductCatalog \
–key file://key.json \
–projection-expression “Description, RelatedItems[0], ProductReviews.FiveStar”
This projection expression retrieves a top-level scalar attribute (Description), the first element in a list (RelatedItems[0]), and a list nested within a map (ProductReviews.FiveStar).
When do you use Redis Elasticache vs Dynamo DB Accelerator (DAX)?
Use Redis Elasticache when you need flexible data storage and advanced caching needs such as data manipulation
Use DAX for improved read performance and reduced DynamoDB read traffic.
What is a global secondary index in dynamo db?
a global secondary index allows you to query the table using alternate attributes as partition keys and sort keys which improves query performance
There is an e-commerce platform where the primary table stores information about products, including attributes such as ProductID (primary key), Name, Price, Category, and Availability.
You want to be able to quickly query products from a given category
What could you add to implement this?
Add a global secondary index on the Category column
Ie.,
aws dynamodb update-table \
..
..
–global-secondary-index-updates \
“[{
"Create": {
"IndexName": "YourGSIName",
….
What is a partition key in dynamo db?
you specify the partition key attribute to distribute data evenly across partitions
It acts as input to the hash function, determining the partition where the item will be stored
What are global tables in dynamo db?
allow you to create tables that are automatically replicated across multiple AWS Regions, providing a highly available and durable solution for globally distributed applications
low-latency access to data for your globally distributed application, with high availability and disaster recovery capabilities.
Global Tables help you maintain data consistency across different regions and provide a reliable and scalable solution for applications that require global data access without compromising on performance or availability.
Give 3 examples of when you might want to change the read capacity in dynamo db?
to manage fluctuating traffic patterns
optimize performance
reduce costs
Why would your Dynamo DB app throw a Throttling error?
the provisioned throughput capacity for a table or an index is exceeded
What is write around cache using Dynamo DB DAX what is the benefit?
directly writes data to DynamoDB so cache data is always up to date
What is write through cache using Dynamo DB DAX and what is the benefit
Write-through cache with DynamoDB DAX writes data to the cache first, improving read performance by making frequently accessed data readily available.
What is use side cache using redis along with Dynamo DB and the benefit
Using Redis as a side cache with DynamoDB involves storing frequently accessed data in Redis for faster retrieval, leading to improved application performance and reduced latency.
What is write through cache using Redis along with Dynamo DB and its benefit
Write-through cache with Redis and DynamoDB means writing data to Redis first and then to DynamoDB, leading to improved read performance as frequently accessed data is readily available in both the cache and the primary data store.
what does it mean to use global secondary index with projected attributes in aws?
allows you to specify which attributes from the main table should be copied to the index.
Is separating the Lambda handler from the core logic is generally considered a best practice
Yes
What happens if you enable dynamo db triggers?
you are configuring your DynamoDB table to automatically invoke a specified AWS Lambda function or an Amazon Kinesis Data Stream when certain events occur on the table. These events are typically changes to the data within the table, such as inserts, updates, or deletions
What happens if you enable dynamo db streams?
Enabling DynamoDB Streams allows you to capture and track changes to items in a DynamoDB table in real time. You can use this feature to trigger actions, process data, and integrate with other AWS services, creating powerful, event-driven applications.
What would you use to schedule a Lambda function to run on a regular basis?
WS CloudWatch Events or AWS EventBridge to create a scheduled event that triggers the Lambda function
Name the 2 types of Dynamo DB read operations?
eventually consistent reads
strongly consistent reads
When do you use strongly consistent reads instead of eventually consistent reads
Use strongly consistent reads in DynamoDB when you need the most recent data for critical operations
Use eventually consistent reads when slightly outdated data is acceptable for non-critical operations