PostgreSQL is a high-performance, enterprise-class open-source relational database that supports both SQL (relational) and JSON (non-relational) queries. PostgreSQL is highly reliable and is known for its integrity and accuracy, having been developed over 20 years by a large open-source community.
PostgreSQL is used as a primary data repository for many web, mobile, geospatial, and analytics applications. The most recent major release is PostgreSQL 12.
Amazon Web Services (AWS) provides PostgreSQL as a fully managed AWS database service, using Amazon Relational Database Service (RDS) and Amazon Aurora, an Amazon-developed database engine which is fully compatible with PostgreSQL.
In this post, we’ll review AWS managed PostgreSQL with RDS and Aurora. We’ll also present a second option—running PostgreSQL on an Amazon EC2 compute instance with EBS storage, to achieve the same level of control as in your local data center.
In this article, you will learn:
Let’s explore the two main options for deploying PostgreSQL on AWS as a managed service - Amazon Relational Database Service (RDS), and Amazon Aurora.
We’ll also cover Babelfish with Aurora, an innovative service that lets you migrate Microsoft SQL Server databases to PostgreSQL and save on license costs.
Amazon RDS lets you deploy fully managed PostgreSQL database instances. It provides automated backups, and lets you easily create database snapshots, with point in time restore. Amazon does not provide access to the physical hosts running the database instances (for example, using SSH).
You can manage your RDS PostgreSQL instances using standard management utilities such as pgAdmin or psql.
Amazon RDS for PostgreSQL lets you easily run your PostgreSQL database on Amazon RDS DB Instances. You get to use all of the familiar features of PostgreSQL, and leverage RDS management capabilities. You can easily deploy new databases and migrate your existing applications and tools. RDS provides you with features to simplify and automate the process.
There are several backup and recovery options available when using RDS PostgreSQL, including:
In addition to automated backups and DB snapshots, RDS provides features for replication, including multi-AZ deployments and read replicas.
Multi-AZ deployments
Once you enable this feature, RDS starts automatically creating and modifying your DB instance, to ensure database availability. The system automatically creates and manages a replica of your database and puts it in “standby” within another availability zone. Any database updates will be then made concurrently on both the main and standby databases. This allows RDS to failover to the updated standby if your main database fails.
Read replicas
The read replicas feature can help you provision read-heavy databases beyond the capacity of a single instance. To do this, you need to create one or more replicas of your source database instance. You can then serve read traffic from multiple data copies, and increase the aggregate read throughput of your application. This works within an AWS region. To ensure consistency, any changes to the instance source are propagated to all associated read replicas.
Amazon Aurora PostgreSQL is an Amazon-developed database engine that is compatible with PostgreSQL and fully complies with ACID requirements (Atomicity, Consistency, Isolation, Durability). It can run as part of Amazon RDS, and is also provided in a serverless model, known as Aurora Serverless.
Aurora PostgreSQL is a fully managed service that lets you operate and easily scale existing and new PostgreSQL databases. It takes care of database management concerns like setup, patching and upgrades, backup and recovery, failover, and high availability. RDS provides automated migration tools to convert existing RDS PostgreSQL databases to Aurora PostgreSQL.
Amazon provides you with the capabilities needed to migrate your PostgreSQL database workloads to Aurora. AWS Database Migration Service (DMS), for example, can help you significantly accelerate the migration process. Amazon offers the first six months of DMS for free, when your target database is Aurora.
Aurora provides automatic and continuous backups of point in time copies, which are stored in Amazon S3. While the process is automated, you can define a retention period of up to 35 days and restore your backups at any time. You can choose to restore any second, and up to the last five minutes of the retention period.
Aurora provides machine learning (ML) capabilities that are available for use directly from your database. You can leverage this feature to gain ML-based predictions, which can be queried using SQL. Aurora lets you securely integrate with AWS ML services, which provide ready-made ML algorithms you can add to your application.
Amazon Aurora Serverless provides a layer that automatically manages your infrastructure. Once you enable Aurora Serverless, you do not need to manage database instances. The system automatically starts, shuts, and scales the capacity of your database according to the needs of your application.
Babelfish is a new translation layer for Amazon Aurora PostgreSQL, which allows Aurora to communicate with applications written for Microsoft SQL Server. Babelfish is a built-in Amazon Aurora feature offered at no extra cost.
Migrating from an old SQL Server database is time-consuming and resource intensive. Amazon provides the Database Migration Service (DMS), which can automatically migrate database architecture and data. However, application migration is often an issue, and in many cases, it is necessary to rewrite application code to interact with the database.
Babelfish allows Aurora PostgreSQL to understand T-SQL (Microsoft's SQL dialect) and communicate with applications written for SQL Server. Applications that were originally written for SQL Server 2014 or newer can run in Aurora with almost no code changes. As a result, organizations can migrate from SQL Server to Aurora with low cost and minimal risk.
Learn more about how to migrate your database to PostgreSQL in our articles:
The above fully managed options are ideal for cloud-native or re-architected applications that do not require complete control over the environment. For more control over configuration, environment and tuning, you can opt for a self-managed deployment.
Self managing PostgreSQL in AWS involves running an EC2 instance with a PostgreSQL image. This gives you complete control over database configuration, allowing you to fine tune configuration and performance, just like you would do in your on-premises data center.
You can self-manage PostgreSQL on AWS by using two additional services—Amazon Elastic Block Store (EBS) and Amazon EC2.
To set this up, you need to first install and deploy your PostgreSQL database on an EC2 instance. You can simplify the process of setting up the deployment by using Amazon Machine Images as templates for your EC2 instances:
The next step is to attach an EBS volume, which provides pluggable and durable storage for your data. Once you set up your self-managed database, you need to continuously maintain and monitor its operation.
Pros of managed deployments:
Cons of managed deployments:
Pros of self-managed deployments:
Cons of self-managed deployments:
NetApp Cloud Volumes ONTAP helps you get all the benefits of the self-managed deployment option—without the complexity.
NetApp Cloud Volumes ONTAP, the leading enterprise-grade storage management solution, delivers secure, proven storage management services on AWS, Azure and Google Cloud. Cloud Volumes ONTAP supports up to a capacity of 368TB, and supports various use cases such as file services, databases, DevOps, or any other enterprise workload, with a strong set of features including high availability, data protection, storage efficiencies, Kubernetes integration, and more.
Cloud Volumes ONTAP extends your control and provides more capabilities, including a number of automatic features that aren’t available using either the managed service option on RDS or the native AWS storage model.
When using NetApp Cloud Volumes ONTAP you can leverage the following features:
Cloud Volume ONTAP allows you to leverage self-managed PostgreSQL in EC2 with enterprise capabilities, achieving the following additional benefits:
Learn more from our customers in our Database Case Studies with Cloud Volumes ONTAP blog, and visit our Cloud Volumes ONTAP for PostgreSQL solution page.