High-Performing Databases and Caching

Topics Covered

Choosing the Right Database

Relational databases

Key value and document databases

In-memory databases

Analytics databases

Matching requirements to a database

Managed versus self managed

Schema flexibility

Reading database clues in questions

Polyglot persistence

Durability and availability across database types

Cost shape of each database

Worked example

Quick check

Serverless database options

Quick reference

Security as part of database choice

Final tip

Database questions are among the most common on the exam. They usually describe a workload's data model, access patterns, scale and consistency needs and ask which database fits, or how to make an existing database faster. The AWS in Practice lessons RDS and Aurora Architecture, DynamoDB Key Design and Capacity and ElastiCache and Caching Tiers cover these services in depth.

Relational databases

Relational databases store data in tables with a fixed schema and support SQL, joins across tables, secondary indexes and ACID transactions spanning many rows. Amazon RDS runs MySQL, PostgreSQL, MariaDB, Oracle, SQL Server and Db2, handling provisioning, patching, backups and failover. Amazon Aurora is a MySQL and PostgreSQL compatible engine built for the cloud with higher throughput and faster failover. Relational databases suit applications with complex queries, reporting across related data and strong consistency, such as orders, billing and inventory.

Key value and document databases

DynamoDB is a serverless key value and document database that delivers single digit millisecond latency at any scale, with no servers or capacity planning when using on-demand mode. It scales by distributing items across partitions by key, so access patterns must be known in advance and designed into keys and indexes. It suits user profiles, shopping carts, session data, gaming state, IoT data and any workload with very high request rates and simple access by key. It is a poor fit for ad hoc queries and complex joins.

Each database family fits a different access pattern.

In-memory databases

ElastiCache provides Redis, Valkey and Memcached as managed caches with sub millisecond latency. MemoryDB is a durable, Redis and Valkey compatible in-memory database that stores data in a multi-AZ transaction log, so it can be the primary database for microservices that need microsecond reads and millisecond writes. The distinction matters: ElastiCache is primarily a cache in front of another database, while MemoryDB can be the system of record.

Analytics databases

Amazon Redshift is a columnar data warehouse for complex analytical queries across large data sets, with massively parallel processing and integration with S3 through Redshift Spectrum. It suits business intelligence and reporting, not high volume transactional writes. Analytical queries run against an operational database slow down the application; offloading them to Redshift, or to read replicas for lighter reporting, is a common pattern. The analytics lesson covers Redshift, Athena and OpenSearch.

Matching requirements to a database

Read the requirements in order. Complex relationships, joins and transactions point to RDS or Aurora. Massive scale with simple key access, unpredictable traffic or a serverless architecture point to DynamoDB. Microsecond reads on top of an existing database point to ElastiCache or DAX. Durable in-memory primary storage points to MemoryDB. Analytical queries on large data point to Redshift or Athena. Graphs, documents, time series and Cassandra compatibility point to purpose built databases covered later in this lesson.

Managed versus self managed

Running a database on EC2 gives full control over the engine and operating system but makes you responsible for patching, backups, replication and failover. RDS Custom gives operating system access for Oracle and SQL Server applications that need it while keeping some automation. Unless a question requires an unsupported engine, version or configuration, a managed database is the better answer for performance and operational effort.

Schema flexibility

Relational schemas need migrations to add columns, while DynamoDB and document databases allow each item to have different attributes. Flexibility suits evolving applications, but questions about strict integrity, foreign keys and multi row transactions still point to relational databases. DynamoDB does support transactions across up to 100 items, so transactional needs alone do not rule it out when access patterns are simple.

Reading database clues in questions

Exam scenarios rarely name the data model directly; they describe it. Phrases such as relationships between customers, orders and invoices, reporting that joins several tables or the need to roll back a transfer if any step fails describe relational needs. Phrases such as millions of requests per second, single digit millisecond latency at any scale, fully serverless or access by device ID describe DynamoDB. Phrases such as leaderboard, session store or reduce read load on the database describe a cache. Phrases such as business intelligence dashboards across years of data describe a warehouse. Practising this translation is more valuable than memorising feature lists.

Polyglot persistence

Large applications often use several databases, each for the part of the system it suits best. An e-commerce platform might keep orders in Aurora, the product catalogue in DynamoDB or DocumentDB, sessions and carts in ElastiCache, search in OpenSearch, recommendations in Neptune and analytics in Redshift. Each service owns its data, and events or change streams keep derived stores up to date. The exam does not expect every design to use many databases, but it does expect you to recognise when one database is being forced into a workload it does not fit.

Durability and availability across database types

RDS Multi-AZ keeps a synchronous standby in another zone, Aurora keeps six copies of data across three zones, DynamoDB replicates across three zones automatically and ElastiCache can replicate to replicas in other zones with automatic failover. These differences mean that DynamoDB and Aurora are highly available by default for storage, while RDS single instance deployments and ElastiCache without replicas are not. When performance and availability requirements appear together, prefer the option that satisfies both without extra components.

Cost shape of each database

RDS and Aurora provisioned instances cost the same per hour whether busy or idle, so steady workloads suit them and idle development databases waste money unless stopped or run on Aurora Serverless v2. DynamoDB on-demand costs nothing when idle and scales with requests, which suits spiky or low volume workloads, while provisioned capacity is cheaper for steady heavy use. Redshift clusters cost per node hour, with Redshift Serverless charging for compute used. The cost lessons return to these trade-offs, but noticing the cost shape helps eliminate options in performance questions that also ask for cost effectiveness.

Worked example

A ticketing company stores events, venues, seats and orders, and buyers must never be sold the same seat twice. During on-sales, millions of fans refresh event pages. Orders and seat assignments live in Aurora, where transactions guarantee a seat is sold once. Event pages are served from CloudFront and ElastiCache, so the database only sees purchases. Queue position for each fan during the on-sale is kept in DynamoDB, keyed by fan ID, because it needs massive write throughput and simple key access. Each piece of data sits in the store that fits its access pattern.

Quick check

Before choosing, state whether the data has relationships that need joins, how the data is looked up, the request rate, how consistent reads must be and whether queries are known in advance. Those answers almost always point to one family.

Serverless database options

Several databases now scale without choosing instance sizes. DynamoDB on-demand, Aurora Serverless v2, ElastiCache Serverless, Redshift Serverless, Keyspaces and Timestream all adjust capacity automatically. They suit new applications with unknown demand, development environments and spiky workloads. For large, steady workloads, provisioned options with commitments are often cheaper. When a question stresses no capacity planning or the least operational overhead, a serverless option is usually right.

Quick reference

Relational: RDS or Aurora. Key value at scale: DynamoDB. Cache: ElastiCache or DAX. Durable in-memory: MemoryDB. Warehouse: Redshift. Search: OpenSearch.

Security as part of database choice

All managed databases support encryption at rest with KMS and in transit with TLS, placement in private subnets and access control through IAM or database users. DynamoDB uses IAM policies directly, even down to items and attributes with fine grained conditions, while relational databases combine network controls with database users or IAM database authentication. Security requirements rarely change which database fits, but they shape how it is configured.

Matching data to the right family early avoids expensive redesigns later.

Final tip

Read the access pattern twice before reading the answer options.

Getting this first choice right matters more than any later tuning.

Start from the access pattern

Joins and transactions: RDS or Aurora. Key access at any scale: DynamoDB. Microsecond cache: ElastiCache or DAX. Durable in-memory: MemoryDB. Analytics: Redshift or Athena.