3-Databases Flashcards

1
Q

How is data on DynamoDB stored?

A

On SSDs that are replicated in 3 geographically distinct data centres

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

What are the conceptual elements of DynamoDB?

A

Tables are broad collections of data, they consist of items which each have attributes

It supports both the key-value and document data models

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

How can access to DynamoDB be restricted?

A

IAM provides very fine-grained control.

The dynamodb:LeadingKeys and dynamodb:attributes conditions restrict access to items and attributes respectively

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

How are items in DynamoDB reference?

A

With a primary key

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

How do primary keys work in DyanmoDB?

A

There are two kinds: a partition key is based on a unique attribute i.e. user ID

If the partition key is not unique, a composite key is used instead. It consists of a partition key and a sort key

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

What is the purpose of database indexes?

A

They allow fast queries to be performed on specific columns/attributes

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

What indexes does DynamoDb support?

A

Local Secondary Index - same partition key as the original table but different sort key, Can only be created when the table is created

Global Secondary Index - can be added later. Hase a differetn partition key and a different sort key as the original table

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

What API calls are used to get data out of DynamoDB?

A

Query, Scan, Get and BatchGetItem

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

How does Query work in DynamoDB?

A

It finds items based on the primary key of a table or index.

It is eventually consistent by default but can be set to strongly consistent

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

How can Query be refined?

A

It usually returns all attributes but the ProjectionExpression parameter can control this

Usually results are ascending by sort key but setting ScanIndexForward to false reverses this

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

How does Scan work in DynamoDB?

A

It dumps all items in a table and filters those of interest

The attributes it returns can be controlled with the ProjectionExpression parameter

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

How can the performance impact of scans be minimised?

A

Performing parallel scans - by default data is processed sequentially in 1 MB blocks

Set a lower-page size as this means fewer items are returned per API call

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

What are the consistency models of Scan and Query?

A

Scan is eventually consistent

Query is eventually consistent by default but can be made strongly consistent

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

How is DyanmoDB capacity managed?

A

Manually with capacity units, or automatically with the On-Demand Capacity option

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

How is DynamoDB throughput calculated?

A

Each write capacity unit allows for 1 x 1 KB write per second

Each read capacity unit allows for either 1 x 4 KB strong consistent read per second or 2 x 4 KB eventually consistent reads per second

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

How can DynamoDB be made even more performant?

A

With DAX, an in-memory caching service

17
Q

What caching strategy does DAX use?

A

Write-through

18
Q

What operations does DAX accelerate?

A

Only read operations that can be eventually-consistent

19
Q

What happens if the request rate for a table is too high? How can this be managed?

A

The client will trigger a ProvisionThroughputExceed exception.

This is managed by retrying with exponential backoff

20
Q

What is the consistency model of DAX?

A

It is eventually consistent

21
Q

What database model do DynamoDB Transactions enable?

A

ACID (Atomic, Consistent, Isolated, Durable)

22
Q

What is ACID?

A

A requirement that database operations are:

Atomic - all or nothing
Consistent - always leave the database in a valid state
Isolated - no cross-transaction dependency
Durable - successfully committed changes remain if the system goes down

23
Q

How can old items in DynamoDB be managed?

A

The ExpirationTime attribute sets them to expire when that time is reached

Expired items are deleted within 24 hours

24
Q

What are DynamoDB streams?

A

Logs consisting of item level events to that DyanmoDB table in time-order

They are encrypted and retained for 24 hours

By default, only the primary key is recorded. If more is needed, use Before and After Images

25
Q

What is ElastiCache?

A

An in-memory cache that optimises read-heavy applications or those that have repeated compute-intensive queries

26
Q

What cache engines does ElastiCache support? How do they differ?

A

Memcached - isn’t clustered so no multi-AZ support

Redis - Supports complex data structures such as sorted lists and sets. It supports master / slave replication and mult-AZ

27
Q

What cache strategies does ElastiCache support?

A

Both engines support Lazy loading and write-through

28
Q

How does ElastiCache prevent caches from becoming stale?

A

With TTL