← Solutions Architect Associate study path

Performance and cost · 12 min

How do you choose a database on AWS?

In this lesson you will learn which AWS database service fits each data model, when it makes sense for AWS to manage the database instead of you and when to pay for provisioned or serverless capacity.

A is where an application keeps the information it has to look up and change all the time, such as the customers, products and orders of an online store. AWS has more than 15 database services, and on the SAA-C03 exam a question on this topic describes some data and asks you for the service where it should be stored. The AWS decision guide organizes that choice with three questions: what shape your data has, who is going to manage the database and whether you pay for fixed capacity or for what you use. For example, the same store may need one database for its orders and a different one for the shopping cart, because that data has different shapes.

Transactional and analytical databases

The guide covers databases for transactional applications (OLTP), which are the ones that receive many small reads and writes from users at the same time, such as an ordering system. Each of those operations is a , and the database has to save it in an instant. For example, each time a store customer pays, the database records the order and subtracts the product from the inventory.

To analyze huge volumes of data (OLAP), on the other hand, the guide points to Amazon Redshift, which is a data warehouse: a store where data from many years is brought together to produce reports, not to serve customers one by one. That is why, if the scenario asks for reports on years of sales, the answer goes through Redshift and not through a transactional database. For example, the report "which products sold the most each December since the store opened" goes in Redshift.

Within OLTP there are two families of databases, relational and nonrelational. Each service in those families is built for a data model, which is the way the database arranges the information: in tables, in key and value pairs, in documents or in graphs. For example, the store's orders fit well in a table with fixed columns, while the friendships in a social network are better drawn as a graph of people joined by lines.

Decision tree: tables and SQL lead to RDS or Aurora, key-value to DynamoDB, documents to DocumentDB, wide columns to Keyspaces, graphs to Neptune, and below, time series, data warehouse, search, durable memory and cache

Relational databases

The four AWS relational services: Amazon RDS, Amazon Aurora, Amazon Aurora DSQL and Aurora PostgreSQL Limitless Database, with what sets each one apart

Relational databases store data in tables, like a spreadsheet, and relate some tables to others. They are queried with , which lets you combine several tables in a single query with an operation called a JOIN. For example, the store has a table of customers and another of orders, and a JOIN tells it what each customer bought.

The program that runs a relational database is called an engine, such as PostgreSQL or MySQL. AWS has four services in this family:

  • Amazon RDS, which is a managed relational database with six engines (PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and Db2), where AWS takes care of automated , and Multi-AZ deployments, which keep a copy of the database in another Availability Zone in case the first one fails.
  • Amazon Aurora, which is compatible with MySQL and PostgreSQL, has up to five times the of standard MySQL and is the one AWS suggests for migrating or modernizing a relational database that today sits in a company's data center.
  • Amazon Aurora DSQL, which is distributed, serverless SQL compatible with PostgreSQL. It works in several Regions at once, you can write in all of them (active-active replication) and it has strong consistency, which means that every read always sees the latest write.
  • Amazon Aurora PostgreSQL Limitless Database, which grows horizontally by spreading the data across several machines with automatic sharding, when writes or storage go beyond what a single Aurora instance can handle.

For example, an ERP, which is the system a company uses to run its purchasing, sales and payroll, usually uses a relational engine such as SQL Server and fits in RDS. In the same way, a store that already uses MySQL on its own server and wants AWS to handle backups can move to RDS for MySQL, and if it later needs more speed it can move to Aurora without leaving MySQL.

Nonrelational databases

Nonrelational databases store data in other models, without fixed tables, and each service is chosen by the model the scenario names:

  • Amazon DynamoDB, which is key-value and serverless: it stores each item under a key, like a locker with its number. It responds in single-digit milliseconds at any scale and is used for shopping carts, user sessions and applications with millions of users at once.
  • Amazon DocumentDB (with MongoDB compatibility), which stores documents in format that you can query by their fields, and each document can have different fields.
  • Amazon Keyspaces (for Apache Cassandra), which uses wide columns, where each row can have many columns of its own, and is used to migrate Cassandra databases.
  • Amazon Neptune, which stores graphs, that is, things joined by relationships, and is used for social networks, fraud detection and recommendations.
  • Amazon ElastiCache, which is a cache: it keeps copies of the most requested data in and is placed in front of another database to read in microseconds. It works with Valkey, Memcached and Redis OSS.
  • Amazon MemoryDB, which is a durable in-memory database, because it doesn't lose data if it restarts, and is used as a primary database with microsecond reads.
  • Amazon Timestream, which stores time series, which are measurements with their date and time, such as data from devices and a system's metrics.

For example, the store keeps each customer's cart in DynamoDB with the customer number as the key, and keeps in Neptune which customers buy similar things so it can recommend products to them.

Match each case with its database

0 of 5 pairs

Tap a case and then the service.

0 of 5 pairs.

Who manages the database?

Managing a database is all the work it takes to keep it running: installing patches, taking backups, giving it more capacity when it grows and keeping it up if something fails.

The three paths to move a database to AWS: rehost on EC2, replatform on RDS and refactor to Aurora or to a purpose-built database

To move a database you already have to AWS, the guide describes three paths:

  • Rehost, where you install the engine on an Amazon EC2 instance, which is a rented virtual computer. It is the fastest path, although patching, backups, capacity and availability are still your job.
  • Replatform, where you move the database to Amazon RDS without changing the application and AWS takes care of those tasks.
  • Refactor, where you switch to Aurora or to a purpose-built database such as DynamoDB, which usually forces you to change the application.

Of these three paths, the database on EC2 is the one that leaves you the most management work. That is why, when the question says "least operational overhead", rule out the database on EC2, unless the scenario asks for a level of control over the engine or the server that the managed service doesn't give. For example, if the store needs to install an engine add-on that RDS doesn't allow, EC2 becomes an option again.

Provisioned or serverless capacity?

With provisioned capacity you choose the size of the database and pay for it even if you don't use it. With serverless, on the other hand, capacity goes up and down on its own and you pay for what you use. The guide lists Aurora DSQL, Aurora Serverless, DynamoDB, ElastiCache, Keyspaces, Timestream for LiveAnalytics and Neptune Serverless as serverless. For example, a provisioned database for the store costs the same at three in the morning, when nobody is shopping, as in the afternoon, while a serverless one costs less when there is little use.

Two services on that list measure and charge for capacity with their own rules:

  • Aurora Serverless v2, which measures its capacity in ACUs (Aurora capacity units), scales up and down in steps of half an ACU, can go down to zero ACUs with automatic pause and is the one AWS recommends for highly variable workloads, with heavy use for a while and long periods of little or no use.
  • DynamoDB, which has two capacity modes, on-demand and provisioned.

In DynamoDB, on-demand mode is the default and the one AWS recommends for most tables, because you pay per request and don't plan capacity. Provisioned mode, on the other hand, charges you for the reads and writes per second that you set, even if you don't use them, and makes sense when traffic is steady and easy to predict. For example, a school whose grading system gets almost the same use every day can set its capacity with provisioned, while a store with surprise sales is better off using on-demand.

Which capacity mode?

A DynamoDB table has received the same traffic all day for a year, and the team knows precisely how much it will grow. They want the most predictable cost. Which mode do they choose?

Several databases in one application

The guide points out that an application can use several databases, each one for the part it handles best, instead of forcing all the data into a single one. For example, a store can keep orders in Aurora, the cart in DynamoDB and its users' sessions in ElastiCache.

cloud path tip: if an option on the exam has more pieces than the others, check whether each piece fits its part of the application before you rule it out.

If your account uses the new experience

In a new experience account, RDS, Aurora, DynamoDB and ElastiCache are in the free plan, and DocumentDB, Neptune and MemoryDB need the paid plan. Keyspaces, DAX and AWS Database Migration Service aren't available. Also, no cross-Region feature works in this account, so you try multi-Region Aurora DSQL and DynamoDB global tables in a full account. For example, you can create a DynamoDB table to practice, but not copy it to a second Region.

On the exam

The questions on this topic describe the data and how it is read. These words in the question point to the service:

  • "JOIN", "transactions", "SQL" or an engine by name (Oracle, SQL Server), which point to RDS or Aurora.
  • "Millions of requests per second", "key-value" or "serverless", which point to DynamoDB.
  • "MongoDB", which points to DocumentDB, and "Cassandra", which points to Keyspaces.
  • "Relationships", "graph" or "social network", which point to Neptune.
  • "Highly variable usage" or "periods with no activity" in a relational database, which point to Aurora Serverless v2.

For example, if the question says "a reservation application uses Oracle and needs transactions", the engine name points to RDS.

Review question

A company has an on-premises Oracle database for its reservation system. It wants to move it to AWS in three months without changing the application, and it wants to stop handling patching and backups. Later on it plans to evaluate dropping its commercial licenses. What does it do first?

Next