Key-Value Stores (Redis, DynamoDB) Flashcards

Key-value model explained Redis data structures: strings, lists, sets, hashes, sorted sets Expiry and TTL in Redis Pub/Sub, pipelines, and Lua scripting Redis persistence: RDB, AOF DynamoDB basics: partitions, partition keys, sort keys DynamoDB read/write throughput and autoscaling Consistency models in DynamoDB (eventual vs strong consistency) (47 cards)

1
Q

What is the key-value model in NoSQL?

A

The key-value model stores data as a collection of key-value pairs, where each key is unique and maps directly to a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Redis?

A

Redis is an in-memory key-value data store known for its high performance and support for various data structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What data structures does Redis support?

A

Redis supports strings, lists, sets, sorted sets, and hashes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Redis string?

A

A Redis string is the most basic data type and can hold any binary data up to 512MB, including text and serialized objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Redis list?

A

A Redis list is a collection of ordered values that allows push and pop operations from both ends (like a linked list).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Redis set?

A

A Redis set is an unordered collection of unique values, useful for membership tests and set operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Redis hash?

A

A Redis hash is a map of string fields and string values, ideal for representing objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Redis sorted set?

A

A sorted set in Redis is similar to a set but each element has a score used to order the elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is expiry in Redis?

A

Expiry refers to setting a time-to-live (TTL) on a key, after which the key is automatically deleted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is TTL in Redis?

A

TTL (Time To Live) is the remaining time before a key expires and is automatically removed from Redis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Redis Pub/Sub?

A

Redis Pub/Sub allows message broadcasting between publishers and subscribers using channels.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Redis pipelining?

A

Redis pipelining allows sending multiple commands to the server without waiting for individual responses, improving performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Lua scripting in Redis?

A

Lua scripting enables executing complex operations atomically on the Redis server using the embedded Lua interpreter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are RDB snapshots in Redis?

A

RDB (Redis Database) snapshots are point-in-time snapshots of your dataset saved to disk at specified intervals.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is AOF in Redis?

A

AOF (Append Only File) logs every write operation received by the server for durability and recovery.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is DynamoDB?

A

DynamoDB is a fully managed NoSQL key-value and document database service provided by AWS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a partition in DynamoDB?

A

A partition is a unit of data storage and performance in DynamoDB, determined by partition keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a partition key in DynamoDB?

A

The partition key is a primary key attribute that determines the partition where data is stored.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a sort key in DynamoDB?

A

A sort key is used with a partition key to form a composite primary key, allowing multiple items in the same partition.

20
Q

What is read/write throughput in DynamoDB?

A

Read/write throughput refers to the number of reads and writes per second, which can be provisioned or automatically scaled.

21
Q

What is autoscaling in DynamoDB?

A

Autoscaling automatically adjusts read and write capacity based on demand to maintain performance and cost-efficiency.

22
Q

What is eventual consistency in DynamoDB?

A

Eventual consistency means reads might not reflect the latest write immediately but will do so eventually.

23
Q

What is strong consistency in DynamoDB?

A

Strong consistency guarantees that a read reflects the most recent write for that item.

24
Q

What are key-value stores?

A

Key-value stores are NoSQL databases that use a simple key-value method to store data, enabling fast lookups and inserts.

25
What are advantages of key-value stores?
Advantages include high performance, scalability, simplicity, and suitability for caching and real-time applications.
26
What are disadvantages of key-value stores?
Disadvantages include limited query capabilities and lack of support for relationships and complex transactions.
27
What are best practices for Redis usage?
Use proper eviction policies, set TTLs for temporary data, avoid large keys/values, and monitor memory usage.
28
What are best practices for DynamoDB usage?
Design access patterns first, choose effective partition keys, use indexes wisely, and enable autoscaling.
29
What are common use cases for Redis?
Redis is used for caching, real-time analytics, leaderboards, pub/sub systems, and session storage.
30
What are common use cases for DynamoDB?
DynamoDB is ideal for serverless applications, shopping carts, gaming leaderboards, and IoT device data.
31
How do key-value stores impact system design?
They simplify data access patterns, reduce latency, and support high scalability, but often need denormalized data models.
32
Give an example of a key-value pair in Redis.
Key: 'user:123', Value: '{\"name\": \"Alice\", \"age\": 30}'
33
Give an example of a DynamoDB item.
{ \"userId\": \"123\", \"timestamp\": 1670000000, \"action\": \"login\" }
34
What are architectural implications of using Redis?
Using Redis as a cache can reduce database load, but it requires strategies for cache invalidation and data consistency.
35
What are architectural implications of using DynamoDB?
Using DynamoDB promotes stateless, horizontally scalable architectures but requires careful planning for access patterns.
36
How does Redis perform under load?
Redis offers high throughput and low latency, especially for read-heavy workloads, due to in-memory storage.
37
How does DynamoDB ensure fault tolerance?
DynamoDB automatically replicates data across multiple availability zones and supports point-in-time recovery.
38
How can you monitor Redis?
Use Redis CLI, Redis Monitor, or tools like RedisInsight, Prometheus, and Grafana for metrics and alerts.
39
How can you debug issues in Redis?
Use commands like `MONITOR`, `INFO`, and `SLOWLOG` to trace operations and identify bottlenecks.
40
How can you monitor DynamoDB?
AWS CloudWatch provides metrics on read/write capacity, throttling, latency, and errors for DynamoDB tables.
41
How can you debug issues in DynamoDB?
Use CloudWatch Logs, DynamoDB Streams, and the AWS SDK’s error handling to trace problems and optimize performance.
42
What are real-world tradeoffs of using Redis?
Redis offers speed and simplicity, but requires careful memory management and may lose data on crash without persistence enabled.
43
What are real-world tradeoffs of using DynamoDB?
DynamoDB is scalable and managed, but has query limitations and pricing complexity based on access patterns.
44
What are common Redis interview questions?
Examples: 'How does Redis handle persistence?', 'What is the difference between SET and ZSET?', 'Explain TTL and eviction policies.'
45
What are common DynamoDB interview questions?
Examples: 'How does DynamoDB handle partitioning?', 'What is eventual consistency?', 'Explain Global Secondary Indexes.'
46
What are potential gotchas with Redis?
Unbounded memory usage, blocking commands, expired key resurrection, and data loss without AOF/RDB.
47
What are potential gotchas with DynamoDB?
Hot partitioning, high costs from improper access patterns, eventual consistency surprises, and throughput throttling.