Search code examples
amazon-web-servicesdockeramazon-rdsamazon-ecs

Use RDS or a container (ECS) for database? Advantages and disadvantages


I want to host a database on AWS. RDS is one option but I have heard something about containers (and ECS). I see containers as useful for testing, but I'm uncertain about running a production database on one. What would be the advantages and disadvantages of each of them?


Solution

  • Run a database yourself on an EC2 instance:

    • 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

    Run a database on 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

    Run a database inside a container on an EC2 instance:

    All the advantages & disadvantages of running the DB yourself, plus

    • 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.