Skip to content
Certification Guide

Task 3.3 · 22 min read

High-Performing Databases

Services in this lesson

  • Amazon RDSin scope
  • Amazon Aurorain scope
  • Amazon DynamoDBin scope
  • Amazon ElastiCachein scope

What the exam tests

  • Matching the database to the access pattern. Relational data needs joins and transactions, key-value data is read by known keys, and a cache serves answers that repeat.
  • Choosing the migration path. A move to a different engine is a heterogeneous migration, and a move that keeps the engine is homogeneous.
  • Scaling relational reads with RDS read replicas or Aurora Replicas behind a reader endpoint, and knowing that replicas add no write capacity.
  • Scaling a DynamoDB table by its partition key and secondary indexes, and knowing which index can serve a strongly consistent read.
  • Choosing a cache for database read latency (ElastiCache with the right engine, or DAX for DynamoDB), and sizing RDS storage and I/O for throughput.

This lesson owns database read scaling, storage and I/O, DynamoDB key and index design, DAX and ElastiCache for reads, and the engine choice. Other topics live elsewhere:

The core concept

Find the bottleneck before you pick a fix. The read/write ratio in the stem shows which side of the database runs out first. The latency target shows whether you need a cache or a faster store.

A relational database keeps data in tables that SQL queries join, as in Amazon RDS (Relational Database Service) and Amazon Aurora. A key-value database such as Amazon DynamoDB fetches each item by a key you already know.

An analogy: a busy city library

Picture a library on the day a famous author visits:

  • Only the head librarian edits the catalog. Every new book and every change goes through her desk. That's the single writer of an RDS instance or Aurora cluster.
  • Copies of the catalog sit in the reading rooms. Visitors browse them without queueing at her desk. That's a read replica, and each copy is updated a little after the original.
  • A sign by the door answers the questions everyone asks, such as today's opening hours. That's a cache.
  • Coats hang on racks sorted by the owner's surname initial, one attendant per rack. A tour group of Smiths jams the S rack while other racks sit idle. That's a hot partition key in DynamoDB.

Where the analogy breaks: an Aurora Replica isn't a separate copy at all. It reads the same storage as the writer, which is why its lag is so short. And DynamoDB doesn't sort keys like the coat racks, because it hashes each partition key to pick a partition.

Walk one on-sale through it

The diagram is a decision flow. It starts from the read and write profile, splits by data model, then asks which side is the bottleneck.

Enlarge
Match the bottleneck to the layer that relieves it. Replicas relieve reads only, and DAX relieves DynamoDB reads only.

Cedarline Tickets is an event ticketing site. Amara is its database engineer, and Felix is a fan buying a concert ticket during a busy on-sale.

  1. Amara starts at the top of the diagram. Her metrics show that most queries are reads, and pages must load fast. That profile and latency target choose the path.
  2. She splits the data by model. Orders and payments need joins and transactions (changes that succeed or fail together), so they live in an Aurora MySQL cluster. Tickets are read by known keys, so they live in a DynamoDB table.
  3. Felix browses the event listings. Fans run many different queries, so the relational branch leads to Aurora Replicas, read-only instances in the cluster that share its storage. The app sends these reads to the reader endpoint, one address that hands each new connection to a replica.
  4. Felix opens the venue page. Thousands of fans ask for the same venue details, so the answer comes from Amazon ElastiCache, an in-memory cache. The first request misses, reads a replica and stores the answer with a TTL (time to live: how long the cached answer stays valid). Filling the cache only on a miss is lazy loading.
  5. Every later request for that page hits the cache. ElastiCache answers from memory, typically in under a millisecond, and the database runs that query far less often.
  6. Felix pays. The checkout write goes to the writer endpoint, the address of the cluster's only writer. Replicas never take writes, so moving reads off the writer leaves its capacity for checkout.
  7. The ticket is written to DynamoDB. Amara first used the event ID as the partition key: the attribute that decides which partition (a slice of storage and throughput) holds each item. Every ticket for the big concert shared one key, so its writes were throttled (rejected) while the table had capacity to spare.
  8. Amara fixed the key, not the table. She write-shards the event: each ticket is keyed by the event ID plus one of several suffixes. The writes now spread across partitions.
  9. Fans check how many tickets remain. Those reads go through DAX (DynamoDB Accelerator), a cache built for DynamoDB that answers in microseconds. A count a moment old is acceptable, so these are eventually consistent reads, which may miss a very recent write.
  10. Felix opens his confirmation. It must show the ticket he just bought, so the app makes a strongly consistent read, which always returns the latest write. DAX passes that read straight to the table without caching it.

Each load went to the layer that owns it. More replicas wouldn't have sped up step 6, and more table capacity wouldn't have fixed step 7.

The rules the exam tests

  • Read the bottleneck first. Replicas and caches relieve reads. A bigger writer, more storage or more IOPS (input/output operations per second, the disk reads and writes storage can handle) relieves writes and I/O.
  • An RDS instance or Aurora cluster has one writer. Read replicas and Aurora Replicas serve reads only, so they add no write capacity.
  • An RDS read replica keeps its own copy of the data. It receives changes through asynchronous replication (copied after the source confirms the write), so it can lag. You watch that lag with the ReplicaLag metric in Amazon CloudWatch.
  • RDS for MySQL and MariaDB allow up to 15 read replicas from one source in the same Region. The app reaches each one through its own endpoint.
  • An Aurora Replica reads the cluster's shared storage volume. The writer uses the same volume, so adding a replica copies no data. AWS says its lag is usually under 100 milliseconds after a write.
  • An Aurora cluster supports up to 15 Aurora Replicas. The reader endpoint spreads new connections across them, so the app never tracks individual readers.
  • The reader endpoint balances connections, not queries.
  • DynamoDB has no single writer. It scales by spreading items across partitions, and each partition has a fixed throughput ceiling.
  • One partition key value always lives on one partition. A hot key throttles even when the table has spare capacity, so fix the key design, not the table size. A good key has many distinct values (high cardinality), while a key with few values (low cardinality) concentrates traffic.
  • DAX speeds up eventually consistent DynamoDB reads only. Strongly consistent and transactional reads pass through to the table uncached.
Deep diveDynamoDB partition limits and adaptive capacity

One read unit is one strongly consistent read of an item up to 4 KB, or two eventually consistent reads. One write unit is one write of an item up to 1 KB.

Each DynamoDB partition is designed for 3,000 read units and 1,000 write units per second.

Adaptive capacity moves frequently accessed items apart, which helps with uneven traffic. It helps only up to the partition maximum, so one key that exceeds it still throttles.

Table capacity is the sum over all partitions, but each partition keeps its own ceiling. That's why raising table capacity doesn't rescue one hot key.

Deep diveAurora endpoint details

The reader endpoint follows replicas as they are added or removed. While the cluster has replicas, it routes only to them, so a write sent there fails. With no healthy replica, it falls back to the writer.

Because it balances connections, a long-lived connection stays on one replica while others sit idle. Many connections, or a new connection per query, spread load better than a few long-lived ones.

A custom endpoint lists only the replicas you choose. Analytics can use large replicas while the web tier uses others, on the same cluster.

Aurora Auto Scaling adds and removes Aurora Replicas to hold a target, such as the replicas' average CPU. Apps benefit when they connect through the reader endpoint.

Deep diveDynamoDB capacity modes and bursts

On-demand capacity mode scales with traffic (pricing is in 4.3). It instantly absorbs up to double the previous peak.

Growth beyond double can throttle unless it is spread over 30 minutes or the table is pre-warmed. New on-demand tables start at 12,000 reads and 4,000 writes per second.

Warm throughput is the request rate a table or index can absorb instantly. It grows with usage, and you can raise it before a known event.

Provisioned mode with auto scaling follows steady traffic. It takes time to react to a sudden burst.

The walkthrough's bottlenecks were reads and one hot key. Three more questions decide many stems: which cache engine to use, how to query DynamoDB a second way, and what to do when the writer waits on storage.

Choosing a cache engine

  • ElastiCache for Valkey or Redis OSS caches any data store your code writes to. It supports strings, lists, sets, sorted sets and hashes, and up to 5 replicas per shard, so cached data survives a node failure.
  • ElastiCache for Memcached stores simple objects only and has no replication. You scale it by adding or removing nodes.
  • DAX caches DynamoDB only and serves eventually consistent reads in microseconds. Strongly consistent reads pass through uncached.

A second way to query DynamoDB

A sort key is an optional second key that orders the items sharing one partition key. A secondary index lets you query a table by an attribute that isn't its key, and there are two kinds.

  • A global secondary index (GSI) has its own partition key, sort key and capacity. You can add one to an existing table, with up to 20 per table.
  • A GSI supports only eventually consistent reads. A strongly consistent read against a GSI is rejected.
  • A GSI is sparse. Only items that carry its key attributes appear in it.
  • A local secondary index (LSI) keeps the table's partition key and changes only the sort key. You must define it when you create the table.
  • An LSI supports strongly consistent reads. Use one when you need strong consistency and the partition key stays the same.

Storage and I/O for the writer

More IOPS helps only when the database is waiting on storage, so check the bottleneck first.

Aurora grows its volume by itself in 10 GB steps, so you don't size it in advance. RDS storage is yours to size.

On RDS, gp3 is the general purpose volume type and io2 Block Express is the provisioned IOPS type. 3.1 Storage performance covers both.

Storage autoscaling grows RDS storage for you, up to a maximum storage threshold you set. It can't keep up with a very large bulk load. Allocate enough storage before the load, and keep the maximum storage threshold above the expected size.

Deep diveExact storage limits on Aurora and RDS

Aurora volumes reach 256 TiB from Aurora MySQL 3.10. Earlier versions stop at 128 TiB.

On gp3 volumes for Db2, MariaDB, MySQL and PostgreSQL, the baseline below 400 GiB is 3,000 IOPS and 125 MiB/s. From 400 GiB it rises to 12,000 IOPS and 500 MiB/s, and you can provision more IOPS on top.

Oracle reaches the higher gp3 baseline at 200 GiB. SQL Server has no threshold.

Provisioned IOPS on io2 Block Express goes up to 256,000 IOPS on Db2, MariaDB, MySQL and PostgreSQL.

Choosing the engine

The engine comes after the access pattern. An app already on MySQL or PostgreSQL usually keeps that engine, which is a homogeneous migration.

In a homogeneous migration the schema and SQL carry over. The data moves with native tools or AWS DMS (Database Migration Service).

A heterogeneous migration changes the engine. AWS SCT (Schema Conversion Tool) converts the schema and application code, and AWS DMS moves the data.

Decision guide

Decision guide
If the question says…Reach for…Because…
Reporting or browsing reads slow the writer of a relational databaseRDS read replicas, with the reads pointed at each replica's endpointReplicas take the reads. The writer keeps its capacity for checkout writes.
Many read-only connections to an Aurora cluster, with no tracking of reader namesThe Aurora reader endpoint over up to 15 Aurora ReplicasIt spreads new connections across replicas and follows them as they come and go.
Analytics readers need bigger instances, and the web tier must not use themAn Aurora custom endpoint that lists only those replicasEach app uses its own set of instances, so workloads stay isolated on one cluster.
Read capacity must follow CPU on the replicas over a dayAurora Auto Scaling on the average CPU of the Aurora ReplicasIt adds and removes replicas to hold the target. The reader endpoint picks them up.
The same relational query results are requested again and again, and sub-millisecond reads matterElastiCache with lazy loading and a TTLThe cache answers repeats, so the writer runs each distinct query less often.
Cached data must survive a node failure, or the team needs sorted sets, lists or hashesValkey or Redis OSS with replicasReplicas copy each shard, and the engine supports data structures. Memcached has no replicas and only simple objects.
Simple object caching across many nodes, with no replication neededElastiCache for MemcachedSimple key-value objects spread across nodes, which you add or remove with demand.
DynamoDB reads need microsecond latency, and eventually consistent reads are acceptableDAX in front of the tableDAX serves cached items in microseconds. It suits key-value reads, not complex queries.
Strongly consistent reads or transactions must be fast on DynamoDBThe table directly, not DAXDAX passes strongly consistent and transactional reads through without caching them.
One popular partition key value is throttled while the table has spare capacityA partition key with many distinct values, or write shardingThroughput per partition is capped. More key values spread the traffic.
A table must be queried by an attribute that is not its keyA global secondary index on that attributeA GSI has its own key and capacity. It is eventually consistent and sparse.
Unpredictable bursts on a DynamoDB table, with no capacity forecastOn-demand capacity modeIt absorbs up to double the previous peak at once. Pre-warm before a known event.
Steady, predictable traffic on DynamoDBProvisioned mode with auto scalingIt follows steady traffic. It reacts slowly to sudden, unannounced bursts.
A relational database with long idle periods and unpredictable daytime burstsAurora Serverless v2 within a capacity rangeCapacity moves between the minimum and maximum you set. Cost framing is in 4.3.
Storage fills during a large load, even with storage autoscaling onAllocate enough storage before the loadAutoscaling can't keep up with very large loads.
An RDS volume is limited by its IOPS baselineGrow gp3 to 400 GiB or more, or move to io2 Block ExpressOn MySQL or PostgreSQL, gp3 reaches 12,000 IOPS at 400 GiB. io2 goes to 256,000.
Users are far from the database Region and need faster readsAn Aurora or RDS cross-Region read replicaReads are served in the user's Region. Writes still go to the source Region.
A database must move to a different engineAWS Schema Conversion Tool for the schema and code, and AWS DMS for the dataA heterogeneous migration converts the schema before the data moves.
Same engine, new home (for example, self-managed MySQL to Aurora MySQL)A homogeneous migration with native tools or AWS DMSThe schema and SQL carry over, so the application changes least.

Failover decisions for a cross-Region replica are in 2.2.

Correct pattern

REFERENCE PATTERN: a relational site that sends reads to a reader endpoint and caches repeats. Beside it, a DynamoDB table whose key spreads traffic and whose sparse index answers a second question.

The relational part needs no special syntax. The app sends writes to the cluster writer endpoint and browsing or reporting reads to the reader endpoint. Repeated lookups go through ElastiCache with lazy loading.

The DynamoDB part is a table definition. The partition key holds a customer ID with many distinct values, and the sort key orders each customer's orders. A global secondary index covers the orders that are still open:

{
  "TableName": "<your-orders-table>",
  "AttributeDefinitions": [
    { "AttributeName": "CustomerId", "AttributeType": "S" },
    { "AttributeName": "OrderId", "AttributeType": "S" },
    { "AttributeName": "OrderStatus", "AttributeType": "S" },
    { "AttributeName": "OrderDate", "AttributeType": "S" }
  ],
  "KeySchema": [
    { "AttributeName": "CustomerId", "KeyType": "HASH" },
    { "AttributeName": "OrderId", "KeyType": "RANGE" }
  ],
  "BillingMode": "PAY_PER_REQUEST",
  "GlobalSecondaryIndexes": [
    {
      "IndexName": "OpenOrdersIndex",
      "KeySchema": [
        { "AttributeName": "OrderStatus", "KeyType": "HASH" },
        { "AttributeName": "OrderDate", "KeyType": "RANGE" }
      ],
      "Projection": { "ProjectionType": "ALL" }
    }
  ]
}

The index is sparse. Only items that carry an OrderStatus attribute appear in it, so closed orders that drop the attribute cost nothing in the index.

Queries against OpenOrdersIndex are eventually consistent. To read back an order it has just written, the app reads the base table by CustomerId and OrderId with a strongly consistent read.

Why it works: each concern goes to the layer that owns it. Replicas and the cache take reads off the writer. The partition key spreads DynamoDB writes, and the index answers the second access pattern without a scan.

Traps

TRAPExam traps
The trapWhy it failsCorrect pattern
Adding read replicas to fix slow checkout writesReplicas take reads only. Every write still goes to the source.Move the reads to replicas, and size or tune the writer for its writes.
Sending writes to the Aurora reader endpointIt routes to read-only replicas while any exist, so writes fail.Send writes to the writer (cluster) endpoint and reads to the reader endpoint.
Expecting the reader endpoint to spread every query across replicasIt balances connections. A long-lived connection stays on one replica.Use many connections, or a new connection per query, or a custom endpoint for each workload.
Using a low-cardinality partition key such as a status or a regionEvery item with one value lands on one partition, which throttles despite spare capacity.Pick a partition key with many distinct values, or write-shard the hot value across several suffixes.
Raising table capacity to fix throttling on one keyEach partition has its own ceiling. A single hot key stays capped.Fix the key design. Raise capacity only when the whole table is short of it.
Adding a GSI and expecting a strongly consistent read from itGSIs support only eventually consistent reads. A strongly consistent read is rejected.Read the base table for strong consistency, or use a local secondary index if the partition key stays the same.
Creating a local secondary index to query by a different partition keyAn LSI keeps the table's partition key and must be defined at table creation.Use a global secondary index for a new partition key.
Putting DAX in front of a table whose reads must be strongly consistentDAX passes those reads through uncached, so it adds nothing for them.Read those items directly from the table, and use DAX for eventually consistent reads.
Choosing Memcached for a cache that must survive a node failureMemcached has no replication, so a lost node loses its data.Use Valkey or Redis OSS with replicas, in a replication group.
Relying on storage autoscaling to absorb a very large bulk loadAutoscaling can't keep pace with a very large load.Allocate enough storage before the load, and keep the maximum storage threshold above the expected size.

Compare

Compare
AspectRDS read replicaAurora Replica
StorageIts own copy, fed by replicationShares the cluster volume with the writer
Replication lagAsynchronous, watched with ReplicaLagUsually less than 100 ms
CountUp to 15 per source in one Region (MySQL and MariaDB)Up to 15 per cluster
How the application finds itA separate endpoint for each replicaThe reader endpoint, which covers all of them
Scaling by metricManualAurora Auto Scaling on average replica CPU
Compare
AspectGlobal secondary indexLocal secondary index
Partition keyAny attributeThe same as the table
Sort keyOptional, any attributeAn attribute other than the table's sort key
Read consistencyEventually consistent onlyEventually or strongly consistent
When you create itAdded to an existing tableOnly when the table is created
Items includedOnly items with the index key attributes (sparse)Items whose table item has the sort key attribute
Limit20 per tableSee the DynamoDB quotas page
Compare
AspectDAXElastiCache for Valkey or Redis OSSElastiCache for Memcached
CachesDynamoDB onlyAny data store your code writes toAny data store your code writes to
Data typesItems and query resultsStrings, lists, sets, sorted sets, hashesSimple objects
ReplicationRead replicas within one clusterUp to 5 replicas per shard, with cluster mode for shardingNo replication
Strongly consistent readsPassed through, not cachedYour code decides what to cacheYour code decides what to cache
Reach for it whenDynamoDB reads need microsecondsA shared cache with structures or a need for replicasA simple object cache scaled by adding nodes

Worked exam scenario

Exam scenario

A ticketing company runs an RDS for MySQL DB instance. About 90 percent of its queries are reads: event listings, seat maps and a reporting job that runs every hour. The checkout writes are slowing down during the reporting job. The team wants to move the reads off the primary with the LEAST change to checkout, and it wants reporting to stop competing with writes. Which solution meets these requirements?

  1. A.Enable a Multi-AZ DB instance deployment and send the reporting job to the standby DB instance.
  2. B.Increase the allocated storage and provisioned IOPS of the primary DB instance.
  3. C.Create RDS read replicas, point the listings, seat maps and reporting at them, and keep checkout writes on the source.
  4. D.Move the event listings and seat maps to a DynamoDB table keyed by event ID.
Show the walkthrough
  1. Mark the requirements: mostly reads, the writer is slowing down, LEAST change to checkout, and reporting must not compete with writes.
  2. Name the pattern: read replicas take reads from the writer. Checkout keeps writing to the source, and reporting reads from a replica.
  3. A puts a standby in place for failover. A Multi-AZ DB instance standby serves no reads, so reporting still has nowhere to go. Eliminate.
  4. B raises I/O capacity. The stem describes a read load on the writer, not a storage wait, so more IOPS addresses the wrong bottleneck. Eliminate.
  5. D is a rewrite of the listings and seat maps into a new data model, which is far from the LEAST change. Eliminate.
  6. C moves the reads without touching the write path, and it keeps reporting off the writer. Answer: C.

Answer: C

Check your understanding

Question 1: A relational application connects every read and write through the cluster writer endpoint of an Aurora cluster. The team wants read queries spread across three Aurora Replicas without listing replica names in the application. Which change fits best?
Question 2: A DynamoDB table uses Status as its partition key, and 'open' is 95 percent of the items. Writes to open items are throttled, while the table's provisioned write capacity is far above the total write rate. What is the MOST effective fix?
Question 3: Which TWO statements about Amazon ElastiCache for Valkey or Redis OSS and ElastiCache for Memcached are correct? (Choose TWO.) (Choose TWO.)
Question 4: A product catalog stored in DynamoDB is read about 50,000 times per second. Stale reads of a few seconds are acceptable, but the team wants microsecond read latency. The writes are rare. Which change meets this requirement?

Build it

Do the DynamoDB keys and indexes lab. You create a table with a sparse global secondary index and query it both ways. Then you watch a strongly consistent read against the index get rejected.

Key takeaways

  • Read the ratio and the latency target first. The bottleneck decides whether you add replicas, a cache, a faster store or more I/O.
  • RDS read replicas and Aurora Replicas take reads only. Aurora Replicas share the cluster volume, and the reader endpoint spreads connections across up to 15 of them.
  • DynamoDB throughput is capped per partition. Spread traffic with a high-cardinality partition key or write sharding before you add table capacity.
  • A global secondary index is eventually consistent and sparse. A local secondary index keeps the table's partition key and must be created with the table.
  • DAX speeds up eventually consistent DynamoDB reads. Valkey and Redis OSS add replication and data structures, and Memcached is a simple cache with no replicas.
  • Choose the database by access pattern, scale relational reads with replicas and a cache, and scale DynamoDB by spreading traffic across partition key values, not by raising table capacity.

Hands-on lab: Keys, Sparse Indexes and Read Consistency

Sources

Last reviewed