Amazon Web Services

Where should I run my database on AWS?

February 28, 2023

There are multiple options when it comes to running your database on AWS. This guide will help you understand the different options and help you decide which one is best for your use case.

Before we go into the details, let’s take a look at the different options:

  • Running a database in RDS
  • Running a database in EC2
  • Running a database in a container

Running a database in RDS

Amazon Relational Database Service (RDS) is a managed service that makes it easy to set up, operate, and scale a relational database in the cloud. One of the key benefits is it helps you automate time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. Let’s summarize the pros and cons of running a database in RDS:

  • Limited selection of DBs
  • You can run Aurora, Amazon’s proprietary DB
  • Some (few) configuration options are not permitted
  • No access to the underlying machine
  • Automatic backups
  • Basic maintenance is automated
  • You can’t run a cheaper DB than the smallest machine Amazon will rent

Running a database in EC2

When running a database in EC2, you are responsible for the entire stack. You need to set up the machine, install the database, configure it, and maintain it. Let’s summarize the pros and cons of running a database in EC2:

  • You choose the database
  • You control all the configuration
  • You control what else runs on that machine
  • Backup, restoration, and other tasks can be customized
  • You are wholly responsible for keeping the DB running
  • You are wholly responsible for backups

Running a database in a container (ECS, EKS, Fargate)

Running a database in a container may be the best option for you. It gives you the flexibility of running a database in EC2, but with the benefits of running a database in RDS. In summary, the pros and cons of running a database in a container are All the advantages & disadvantages of running the DB yourself, plus the following:

  • You have to do some extra work to persist data across containers
  • You can easily run the exact same DB setup for local development, in test, and in production
  • You pay some additional overhead (small)
  • Process isolation makes it easy to share a machine (maybe your entire workload is less than a t2.micro)

Running a DB in a container under ECS doesn’t really get you advantages over managing the containers yourself. But if you’re using ECS for the rest of your stack and you’re putting the DB in a container, then you’d just want to use ECS for that also.

© All rights reserved — cs.fyi