Database Flashcards

1
Q

RDS SUpports which DBs?

A

MySQL,
PostgreSQL,
MariaDB,
Oracle,
MS SQL Server,
Amazon Aurora.

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

RDS not showing updates straight away. Whats cause?

A

RDS Read Replcias use asycnh replication so will be “eventually consistent”.

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

Do RDS ReadReplicas require a change to SQL Connection String?

A

Read Replicas add new endpoints with their own DNS name. We need to change our application to reference them individually to balance the read load.

Multi AZ keeps same connecting string.

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

Whats an altnerative to enabling sticky sessions to allow users to keep state?

A

Storing Session Data in ElastiCache is a common pattern to ensuring different EC2 instances can retrieve your user’s state if needed.

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

How to create a DR RDS for regional outage so that and outage, the DR can quickly be made read/write

A

Create a READ replica in a different Region and enable multi AZ on read replica.

A read replica can be promoted to become the production DB incase of disaster.

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

How many read replicas can RDS have?

A

15

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

which RDS DB does NOT support IAM Database Authentication

A

oracle

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

Can you create encrypted Read Replicas from an unencrypted RDS DB instance.

A

NO

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

How many Aurora Read Replicas can you have in a single Aurora DB Cluster?

A

15

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

Which databases does Aurora support?

A

MYSQL and Postgress

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

What is the maximum number of Read Replicas you can add in an ElastiCache Redis Cluster with Cluster-Mode Disabled?

A

5

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

What Elastic Cache Caching Strategies are there?

A

Lazy Load -> Update Cache only when data is accessed.

WriteThrough -> All new data written to Cache

TTL / Evictions -> For small cache. LRU. Data auto expires after fixed time.

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

How would you improve performance of dynamoDb?

A

Amazon DynamoDB Accelerator (DAX) is a fully managed, highly available, in-memory cache for Amazon DynamoDB that delivers up to a 10 times performance improvement—from milliseconds to microseconds—even at millions of requests per second.

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

DynamoDB eventually consistent v strongly consistent

A

Eventual consistency is cheaper and faster 1 RCU = 2 reads but data may not be latest

Strongly consistent slower. More £. 1 RCU = 1 read. More accurate.

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

DynamoDB provisions. Size of 1rcu and 1 wcu ?

A

With DynamoDB, there are costs to reading and writing data. These costs are packaged into RCU (Read Capacity Units) and WCU (Write Capacity Units).
1 RCU = 4KB read
1 WCU = 1KB write

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

max row size for dynamo

A

400kb

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

What are the two read/write capacity modes for dynamo?

A

Provisioned (Default). Specify number of read/writes per second in advance.

OnDemand - auto scales. 2.5 times more £. Use for unpredicatable workloads.

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

How does dynamo let you exceed provisioned throughput temporarily ?

A

Throughput can be exceeded temporarily using Burst Capacity

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

what should you do If Dynamo Burst is consumed,

A

exponential back off

(A gradual re-try with larger and larger gap between retry)

20
Q

How often can you switch between Dynamo read/wrie capacity modes?

A

once ever 24 hours

21
Q
A
22
Q

we want to write 10 items per second for 2KB of data in Dynamo. What should the WCU (Write Capacity Unit)

A

20 WCU

1 WCU = 1 write per second for 1KB.

23
Q

we write 6 items per second for 4.5KB in dynamoDB. What should the WCU be.

A

30 wcu

4.5k rounded up to nearest 1K. so 5 * 6=30.

24
Q

We Write 120 items per Minute for 2KB in dynamoDB. What is WCU?

A

WCU=4. (120/60 x 2)

Or put another way. We have WCU of 4. How many reads per second do we get for 2kB? 4/2=2

25
Q

What is the RCU for DynamoDB for both Strong and Eventually Consistent Reads.

A

For STRONGLY Consistent Read, one RCU = One Read per second for 4KB.
Items Per Second * ((KB to nearest 4) / 4 )

For Eventually Consistent Read, one RCU = TWO reads per second for 4KB.
Items Per Second / 2 * ((KB to nearest 4 ) / 4)

26
Q

What is the RCU required for 10 Strongly Consistent reads per second for 4KB.

A

10 RCUs.

10 * (4/4) = 1

27
Q

What is the RCU required for 10 Eventually Consistent reads per second for 4KB.

A

5 RCUs.

10/2 * (4/4)

28
Q

A table is provisioned to have 10 read capacity units and each item has a size of 4 KB.
How many eventual and strong consistent read requests can the table handle per second?

A

Strongly Consistent = 10 (1 RCU = 1 read for 4kb).

Eventually = 20. (2 Reads per RCU)

29
Q

what happens if we exceed provisioned RCU and whats usual cause?

A

we get “ProvisionTrhoughputExceededException”

Usually caused by HotKeys or very large items.

30
Q

SOlutions for DynamoDB ProvisionTrhoughputExceededException

A

use the Exponential Backoff,

Distribute the keys as much as possible

use DynamoDB Accelerator (DAX).

31
Q

What do DnyamoDB Batch Operations do?

A

Allow you to reduce latency with fewer API calls.

Operations done in paralell. Batches are not transactional by default so part can fail.

BatchWriteItem
Up to 25 PutItem and/or DeleteItem in one call

Up to 16MB of data written, up to 400KB per item.
Cant update Items.

BatchGetItem
Returns items from one or more tables
Up to 100 items or 16MB of data

32
Q

How do you use SQL with Dynamo?

A

PartiQL.

Can’t do joins across tables but can handle standard SQL

33
Q

How Many LSI’s can a table have ?

A
  1. Must be defined at table creation time.

Local Secondary Index. Uses same Primary Key + One other secondary Column.

34
Q

How do you create an altneraitve primary key on DnyamoDB?

A

GSI - Global Secondary Index

Alternative Primary Key and optionally sort key. Must provision RCU and WCU. Can be added AFTER table is created. Basically this creaets an index using a different primary key (+optional Sort col)

35
Q

How to auto delete Dnyamo items after set time

A

use TTL- Time TO Live

DOesnt consume WCU. Can take up to 48 hours to remove.

36
Q

How to store objects > 400KB in DynamoDB?

A

Use S3

If you want to store large objects like videos,images, you can store those in S3 then store the S3 link in DynamoDB.

Another strategy often used is to use DynamoDB as an indexing system on top of S3. S3 is good for stroging large objects but hard to query. You can have a LAMBDA function to automatically insert data into DynamoDB when S3 is updated.

User-> S3 -> LAMBDA -> DynamoDB

You coud use this to tehn search DynamoDB for items of a certain size, or produced on certain date etc.

37
Q

How many RCU/WCU do Dynamo Transactional reads/write require?

A

Twice as many as it does two actions, Prepare and COmmit

If we want 3 TRANSACTIONAL writes per second with size of 5KB, WCU would be 30 >= (53)2

If we have 5 TRANSACTIONAL reads per second of 5KB, WCU would be 20 >= 5*(8/4) * 2

38
Q

Does RDS offer auto scaling ?

A

RDS auto scaling provides automated storage scaling for MySQL, PostgreSQL, MariaDB, SQL Server, and Oracle databases

39
Q

How far back can you restore DynamoDB tables

A

up to 35 days to the second using PITR - Point In Time Recovery.

40
Q

does Dynamo allow dupliate keys?

A

By default, it does not allow duplicates. However, if you are using a secondary index, there is a possibility of duplicates if the indexed attributes are not unique.

41
Q

Does RDS support auto-scaling?

A

Yes, RDS does support auto-scaling, but it is not automatically activated like in other services such as DynamoDB

42
Q

RDS Automated Backups supported in AZ or REGION?

A

Automated backups are limited to a single AWS Region (Multi AZ) while manual snapshots and Read Replicas are supported across multiple Regions.

43
Q

REDIS CLUSTER MODE ENABLED

A

Cluster Mode comes with the primary benefit of horizontal scaling up and down of your Redis cluster, with almost zero impact on the performance of the cluster.

44
Q

You are not concerned about your response receiving stale data from your database and need to perform 16 eventually consistent reads per second of 12 KB in size each.

How many read capacity units (RCUs) do you need?

A

24

One read capacity unit represents two eventually consistent reads per second, for an item up to 4 KB in size. So that means that for an item of 12KB in size, we need 3 RCU (12 KB / 4 KB) for two eventually consistent reads per second. As we need 16 eventually consistent reads per second, we need 3 * (16 / 2) = 24 RCU.

45
Q

REDiS - Can nodes be cross REgion ?

Can you promote replicate to primary when using Redis Cluster Mode ?

A

While using Redis with cluster mode enabled, you cannot manually promote any of the replica nodes to primary

Correct selection
All the nodes in a Redis cluster must reside in the same region