Using compute services to run databases

Natasha Ong
This is some text inside of a div block.
4 min read

In a nutshell:

You can install and configure databases on EC2 instances or containers for control and customisation, but it comes with more management.
🔄 Flip it and reverse it: Managed database services (e.g., RDS) are much simpler to use in comparison, but they come with some limitations on customisation and control over the database environment.

Niceeee, you've aced compute services! Before we move on, there's one last thing to know about them. (You got this!)

One thing we haven't covered yet is compute services' ability to run databases. Remember the database services we've learnt a few topics ago - RDS, DynamoDB, Aurora and more? So, while AWS offers these managed database services, they're not your only options.

You also have the option to set up databases yourself on virtual machines (EC2 instances), or use containerised databases with services like Amazon ECS or EKS. 🤯

What would that look like?

  • Control: EC2 and containers offer the highest level of control over your database environment. You can fine-tune configurations, choose specific database software, and customise as needed.
  • Scalability: You're responsible for scaling resources, which gives you flexibility but also means active management.

If you'd like a quick refresher on managed database services (e.g., Amazon RDS), here's how they compare:

  • Control: Managed services handle much of the operational tasks, including patching, backups, and scaling. This reduces administrative overhead.
  • Scalability: Scaling is often automated (phew).

But why would I want to use compute services?

Ah gooooood question!

Using EC2/Containers for databases is great for...

  • Precise control over your database environment.
  • Custom apps with unique database requirements.
  • Legacy apps that need specific database software.

Using managed database services is great for...

  • Startups and small businesses that prioritise ease of management.
  • Modern apps with fluctuating workloads.
  • People wanting to focus on app development, not database administration.

How would compute services make it work?

Setting up a database using compute services can be broken down into five key steps:

  1. Choose your compute service: Choose between EC2 instances and containers.
  2. EC2 instances give you full control over your database environment, including software choice and customisation. or containers for microservices-based applications.
  3. Containers package your database software, configuration files, data, and dependencies, making it easy to run your database on different computers.
  4. Set up your environment: Configure your EC2 instances or containers to match your database requirements. For EC2, this means instance type, security groups, storage, and networking. For containers, configure Docker templates, computing power limits, memory, and more.
  5. Install and configure the database: Install and configure your chosen database software (e.g., MySQL, PostgreSQL). Adjust parameters, manage security settings, and optimise configurations to fit your application's needs.
  6. Data migration: If you're migrating an existing database, transfer your data using tools like AWS Database Migration Service (DMS).
  7. Monitor and ensure security: EC2 and container-based databases need you to handle performance, setting up any alerts, and security. You'll also handle backups, patches, and scaling on your own.

In comparison, managed databases handle most of the management:

  • It comes with a lot of the environment set up done already, so you'll only need to specify some basic things like the database engine type (e.g. MySQL), the instance class (e.g. t2.micro) and the storage size.
  • There is already a pre-configured database software of your choice, so you'd skip step 3.
  • Database migration is often handled seamlessly with built-in tools, so again you'd skip step 4.

Management tasks - backups, patches and scaling - so you'd have minimal effort in step 5 before.