SlideShare a Scribd company logo
1 of 21
Download to read offline
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migrating Open Source Databases
from Amazon EC2 to Aurora
PostgreSQL
Joey Kwasniewski
Principal Engineer
ClassPass
D A T 3 3 9
Kevin Jernigan
Principal Product Manager
Amazon
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
About ClassPass
Amazon EC2 PostgreSQL
Migration from Amazon EC2 to Amazon RDS PostgreSQL
Migration from Amazon RDS to Aurora PostgreSQL
Lessons learned
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
About ClassPass
ClassPass is an all-access
membership to a global
network of 10,000 fitness
studios
ClassPass was started in 2013
after the founder struggled to
find a dance class to take after
work in NYC
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ClassPass architecture
Microservices
Over 100 services running many different functions
Most services have stateful data stored in PostgreSQL databases
Many environments
Development and production environments
Team environments
No dedicated database administrators
Teams own management of their own databases
Senior engineers help as issues arise
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2 PostgreSQL
Started using a monolithic application
One database isn’t too hard to manage
One small EC2 instance with standard provisioned EBS volume
We start to get more data and more services
Resizing EC2 instances and EBS volumes to keep up with load
Creating new databases to isolate different services from affecting each other
Backups, replicas, and redundancy
Scripts to create EBS snapshots and database dumps
Multiple EC2 instances with manually configured replication configurations
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon EC2 to RDS PostgreSQL
Still early in lifecycle of company
Some downtime is okay
Dataset is still not extremely large
At time of migration some AWS services did not yet exist
AWS Database Migration Service (AWS DMS) was not yet released, which would have allowed
us to have less downtime
Aurora PostgreSQL was also not released yet
How we did it
Create new RDS instance
Put the application in maintenance
Take a pg_dump of the database
Load the pg_dump into the new RDS instance
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon EC2 to RDS PostgreSQL
> psql -U root -h example.account.us-east1.rds.amazonaws.com --dbname=postgresql
> psql$ create database classpass_example;
> psql$ create role classpass with password ‘example’;
> psql$ grant all on database classpass_example to classpass;
> psql$ q
> pg_dump dbname=classpass_example -f classpass_example.sql
> psql –f classpass_example.sql -h example.account.us-east1.rds.amazonaws.com 
–U root –d classpass_example
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon EC2 to RDS PostgreSQL
Lots of benefits
Easy to add replicas
Multi-AZ automatic failover
Easier to increase storage capacity
Some scaling pains
Still need to manage storage capacity
IO capacity management can be
complicated
Parameter groups
Database version upgrade management
No base operating system to manage
Some databases getting close to 16 TB
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon RDS to Aurora PostgreSQL
Challenges
Large databases with heavy write loads
Mission-critical workflows that need very little downtime
Lots of legacy code using database making architecture changes expensive
Customers facing slowdowns at peak times
What Aurora gives us
Automatic disk capacity growth to 64 TB
Much higher I/O maximums with no need to manually provision
A very easy migration process that allows almost zero downtime
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon RDS to Aurora PostgreSQL
How we did it
Create a CNAME in Amazon Route 53 that points to the RDS instance hostname
Update all configurations that accesses the RDS instance to the CNAME
Created a new Aurora parameter group that closely matched RDS parameter group
Turns off nonessential services to limit writes to the RDS instance
Created a Aurora read replica for the RDS master
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon RDS to Aurora PostgreSQL
How we did it
Wait for all replication data to be fully synced
Stop all writes to the old RDS instance
Promote the Aurora read replica
Update the CNAME to the Aurora read replica hostname
Stop the old RDS instance
Start all services
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Migration from Amazon RDS to Aurora PostgreSQL
0
50
100
150
200
250
300
Workflow 1 Workflow 2 Workflow 3 Workflow 4
Workflow completion time (minutes)
RDS Aurora
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Lessons learned
AWS keeps making things easier
If we had to do this again, AWS DMS and Aurora PostgreSQL would have made the initial
migration faster and with less downtime
Aurora doesn’t solve all problems
If you have very large joins you will still see performance issues
Look at optimizing queries or changing work_mem to do operations all in memory
Don’t wait until you are almost out of a resource
We waited too long and had issues with disk capacity on our RDS instance while migrating to
Aurora
Thank you!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Joey Kwasniewski
jkwasniewski@classpass.com
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

More Related Content

What's hot

PreReLa #1 (PRL1-R1) - AWS re:Invent 2018
PreReLa #1 (PRL1-R1) - AWS re:Invent 2018PreReLa #1 (PRL1-R1) - AWS re:Invent 2018
PreReLa #1 (PRL1-R1) - AWS re:Invent 2018
Amazon Web Services
 

What's hot (20)

Build a Kubernetes Cluster with Amazon EKS
Build a Kubernetes Cluster with Amazon EKSBuild a Kubernetes Cluster with Amazon EKS
Build a Kubernetes Cluster with Amazon EKS
 
Make Your Disaster Recovery Plan Resilient & Cost-Effective (ENT213-S) - AWS ...
Make Your Disaster Recovery Plan Resilient & Cost-Effective (ENT213-S) - AWS ...Make Your Disaster Recovery Plan Resilient & Cost-Effective (ENT213-S) - AWS ...
Make Your Disaster Recovery Plan Resilient & Cost-Effective (ENT213-S) - AWS ...
 
Best Practices for Building Multi-Region, Active-Active Serverless Applicatio...
Best Practices for Building Multi-Region, Active-Active Serverless Applicatio...Best Practices for Building Multi-Region, Active-Active Serverless Applicatio...
Best Practices for Building Multi-Region, Active-Active Serverless Applicatio...
 
Mastering Identity at Every Layer of the Cake (SEC401-R1) - AWS re:Invent 2018
Mastering Identity at Every Layer of the Cake (SEC401-R1) - AWS re:Invent 2018Mastering Identity at Every Layer of the Cake (SEC401-R1) - AWS re:Invent 2018
Mastering Identity at Every Layer of the Cake (SEC401-R1) - AWS re:Invent 2018
 
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
Amazon EC2 Foundations (CMP208-R1) - AWS re:Invent 2018
 
Optimizing Storage for Enterprise Workloads and Migrations (STG202) - AWS re:...
Optimizing Storage for Enterprise Workloads and Migrations (STG202) - AWS re:...Optimizing Storage for Enterprise Workloads and Migrations (STG202) - AWS re:...
Optimizing Storage for Enterprise Workloads and Migrations (STG202) - AWS re:...
 
Optimize Your Oracle Licenses on Amazon Web Services (DAT211) - AWS re:Invent...
Optimize Your Oracle Licenses on Amazon Web Services (DAT211) - AWS re:Invent...Optimize Your Oracle Licenses on Amazon Web Services (DAT211) - AWS re:Invent...
Optimize Your Oracle Licenses on Amazon Web Services (DAT211) - AWS re:Invent...
 
AWS Data Transfer Services Deep Dive
AWS Data Transfer Services Deep Dive AWS Data Transfer Services Deep Dive
AWS Data Transfer Services Deep Dive
 
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
 
Reuters Lives: Scaling & Monitoring Live Video in the Cloud (DEV316-S) - AWS ...
Reuters Lives: Scaling & Monitoring Live Video in the Cloud (DEV316-S) - AWS ...Reuters Lives: Scaling & Monitoring Live Video in the Cloud (DEV316-S) - AWS ...
Reuters Lives: Scaling & Monitoring Live Video in the Cloud (DEV316-S) - AWS ...
 
Best Practices for Running SQL Server on Amazon RDS (DAT323) - AWS re:Invent ...
Best Practices for Running SQL Server on Amazon RDS (DAT323) - AWS re:Invent ...Best Practices for Running SQL Server on Amazon RDS (DAT323) - AWS re:Invent ...
Best Practices for Running SQL Server on Amazon RDS (DAT323) - AWS re:Invent ...
 
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
 
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
 
PreReLa #1 (PRL1-R1) - AWS re:Invent 2018
PreReLa #1 (PRL1-R1) - AWS re:Invent 2018PreReLa #1 (PRL1-R1) - AWS re:Invent 2018
PreReLa #1 (PRL1-R1) - AWS re:Invent 2018
 
Autonomous DevSecOps: Five Steps to a Self-Driving Cloud (ENT214-S) - AWS re:...
Autonomous DevSecOps: Five Steps to a Self-Driving Cloud (ENT214-S) - AWS re:...Autonomous DevSecOps: Five Steps to a Self-Driving Cloud (ENT214-S) - AWS re:...
Autonomous DevSecOps: Five Steps to a Self-Driving Cloud (ENT214-S) - AWS re:...
 
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
 
Advanced Traffic Management with Amazon Route 53 Traffic Flow (NET407-R1) - A...
Advanced Traffic Management with Amazon Route 53 Traffic Flow (NET407-R1) - A...Advanced Traffic Management with Amazon Route 53 Traffic Flow (NET407-R1) - A...
Advanced Traffic Management with Amazon Route 53 Traffic Flow (NET407-R1) - A...
 
Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...
Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...
Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...
 
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
Scaling Up to Your First 10 Million Users (ARC205-R1) - AWS re:Invent 2018
 
Extending Data Centers to the Cloud: Connectivity Options and Best Practices ...
Extending Data Centers to the Cloud: Connectivity Options and Best Practices ...Extending Data Centers to the Cloud: Connectivity Options and Best Practices ...
Extending Data Centers to the Cloud: Connectivity Options and Best Practices ...
 

Similar to Migrating Open Source Databases from Amazon EC2 to Aurora PostgreSQL (DAT339) - AWS re:Invent 2018

ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...
ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...
ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...
Amazon Web Services
 

Similar to Migrating Open Source Databases from Amazon EC2 to Aurora PostgreSQL (DAT339) - AWS re:Invent 2018 (20)

Best Practices for Migrating Oracle Databases to the Cloud - AWS Online Tech ...
Best Practices for Migrating Oracle Databases to the Cloud - AWS Online Tech ...Best Practices for Migrating Oracle Databases to the Cloud - AWS Online Tech ...
Best Practices for Migrating Oracle Databases to the Cloud - AWS Online Tech ...
 
Running Oracle Databases on Amazon RDS and Migrating to PostgreSQL (DAT307-R1...
Running Oracle Databases on Amazon RDS and Migrating to PostgreSQL (DAT307-R1...Running Oracle Databases on Amazon RDS and Migrating to PostgreSQL (DAT307-R1...
Running Oracle Databases on Amazon RDS and Migrating to PostgreSQL (DAT307-R1...
 
Running SQL Server on Amazon RDS and Migrating to MySQL (DAT306-R1) - AWS re:...
Running SQL Server on Amazon RDS and Migrating to MySQL (DAT306-R1) - AWS re:...Running SQL Server on Amazon RDS and Migrating to MySQL (DAT306-R1) - AWS re:...
Running SQL Server on Amazon RDS and Migrating to MySQL (DAT306-R1) - AWS re:...
 
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDSDAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
 
GPS: Migrate Your Databases with the AWS Database Migration Service and AWS S...
GPS: Migrate Your Databases with the AWS Database Migration Service and AWS S...GPS: Migrate Your Databases with the AWS Database Migration Service and AWS S...
GPS: Migrate Your Databases with the AWS Database Migration Service and AWS S...
 
GPSWKS408-GPS Migrate Your Databases with AWS Database Migration Service and ...
GPSWKS408-GPS Migrate Your Databases with AWS Database Migration Service and ...GPSWKS408-GPS Migrate Your Databases with AWS Database Migration Service and ...
GPSWKS408-GPS Migrate Your Databases with AWS Database Migration Service and ...
 
SQL Server to Amazon Aurora Migration, Step by Step (DAT405) - AWS re:Invent ...
SQL Server to Amazon Aurora Migration, Step by Step (DAT405) - AWS re:Invent ...SQL Server to Amazon Aurora Migration, Step by Step (DAT405) - AWS re:Invent ...
SQL Server to Amazon Aurora Migration, Step by Step (DAT405) - AWS re:Invent ...
 
Use AWS DMS to Securely Migrate Your Oracle Database to Amazon Aurora with Mi...
Use AWS DMS to Securely Migrate Your Oracle Database to Amazon Aurora with Mi...Use AWS DMS to Securely Migrate Your Oracle Database to Amazon Aurora with Mi...
Use AWS DMS to Securely Migrate Your Oracle Database to Amazon Aurora with Mi...
 
Managed Relational Databases - Amazon RDS
Managed Relational Databases - Amazon RDSManaged Relational Databases - Amazon RDS
Managed Relational Databases - Amazon RDS
 
DAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudDAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the Cloud
 
ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...
ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...
ABD324_Migrating Your Oracle Data Warehouse to Amazon Redshift Using AWS DMS ...
 
Migrating Your Databases to AWS – Tools and Services (Level 100)
Migrating Your Databases to AWS – Tools and Services (Level 100)Migrating Your Databases to AWS – Tools and Services (Level 100)
Migrating Your Databases to AWS – Tools and Services (Level 100)
 
Managed Relational Databases
Managed Relational DatabasesManaged Relational Databases
Managed Relational Databases
 
A Practitioner’s Guide on Migrating to, and Running on Amazon Aurora - DAT315...
A Practitioner’s Guide on Migrating to, and Running on Amazon Aurora - DAT315...A Practitioner’s Guide on Migrating to, and Running on Amazon Aurora - DAT315...
A Practitioner’s Guide on Migrating to, and Running on Amazon Aurora - DAT315...
 
Accelerate Oracle to Aurora PostgreSQL Migration (GPSTEC313) - AWS re:Invent ...
Accelerate Oracle to Aurora PostgreSQL Migration (GPSTEC313) - AWS re:Invent ...Accelerate Oracle to Aurora PostgreSQL Migration (GPSTEC313) - AWS re:Invent ...
Accelerate Oracle to Aurora PostgreSQL Migration (GPSTEC313) - AWS re:Invent ...
 
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
 
Hands-On: Building a Migration Strategy for SQL Server on AWS (WIN310) - AWS ...
Hands-On: Building a Migration Strategy for SQL Server on AWS (WIN310) - AWS ...Hands-On: Building a Migration Strategy for SQL Server on AWS (WIN310) - AWS ...
Hands-On: Building a Migration Strategy for SQL Server on AWS (WIN310) - AWS ...
 
Hands-On Building and Deploying .NET Applications on AWS (DEV331-R1) - AWS re...
Hands-On Building and Deploying .NET Applications on AWS (DEV331-R1) - AWS re...Hands-On Building and Deploying .NET Applications on AWS (DEV331-R1) - AWS re...
Hands-On Building and Deploying .NET Applications on AWS (DEV331-R1) - AWS re...
 
Migrating database to cloud
Migrating database to cloudMigrating database to cloud
Migrating database to cloud
 
Enterprise-Database-Migration-Strategies-and-Options-on-AWS
Enterprise-Database-Migration-Strategies-and-Options-on-AWSEnterprise-Database-Migration-Strategies-and-Options-on-AWS
Enterprise-Database-Migration-Strategies-and-Options-on-AWS
 

More from Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Migrating Open Source Databases from Amazon EC2 to Aurora PostgreSQL (DAT339) - AWS re:Invent 2018

  • 1.
  • 2. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migrating Open Source Databases from Amazon EC2 to Aurora PostgreSQL Joey Kwasniewski Principal Engineer ClassPass D A T 3 3 9 Kevin Jernigan Principal Product Manager Amazon
  • 3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Agenda About ClassPass Amazon EC2 PostgreSQL Migration from Amazon EC2 to Amazon RDS PostgreSQL Migration from Amazon RDS to Aurora PostgreSQL Lessons learned
  • 4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 5. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. About ClassPass ClassPass is an all-access membership to a global network of 10,000 fitness studios ClassPass was started in 2013 after the founder struggled to find a dance class to take after work in NYC © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 6. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ClassPass architecture Microservices Over 100 services running many different functions Most services have stateful data stored in PostgreSQL databases Many environments Development and production environments Team environments No dedicated database administrators Teams own management of their own databases Senior engineers help as issues arise
  • 7. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 8. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon EC2 PostgreSQL Started using a monolithic application One database isn’t too hard to manage One small EC2 instance with standard provisioned EBS volume We start to get more data and more services Resizing EC2 instances and EBS volumes to keep up with load Creating new databases to isolate different services from affecting each other Backups, replicas, and redundancy Scripts to create EBS snapshots and database dumps Multiple EC2 instances with manually configured replication configurations
  • 9. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 10. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon EC2 to RDS PostgreSQL Still early in lifecycle of company Some downtime is okay Dataset is still not extremely large At time of migration some AWS services did not yet exist AWS Database Migration Service (AWS DMS) was not yet released, which would have allowed us to have less downtime Aurora PostgreSQL was also not released yet How we did it Create new RDS instance Put the application in maintenance Take a pg_dump of the database Load the pg_dump into the new RDS instance
  • 11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon EC2 to RDS PostgreSQL > psql -U root -h example.account.us-east1.rds.amazonaws.com --dbname=postgresql > psql$ create database classpass_example; > psql$ create role classpass with password ‘example’; > psql$ grant all on database classpass_example to classpass; > psql$ q > pg_dump dbname=classpass_example -f classpass_example.sql > psql –f classpass_example.sql -h example.account.us-east1.rds.amazonaws.com –U root –d classpass_example
  • 12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon EC2 to RDS PostgreSQL Lots of benefits Easy to add replicas Multi-AZ automatic failover Easier to increase storage capacity Some scaling pains Still need to manage storage capacity IO capacity management can be complicated Parameter groups Database version upgrade management No base operating system to manage Some databases getting close to 16 TB
  • 13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon RDS to Aurora PostgreSQL Challenges Large databases with heavy write loads Mission-critical workflows that need very little downtime Lots of legacy code using database making architecture changes expensive Customers facing slowdowns at peak times What Aurora gives us Automatic disk capacity growth to 64 TB Much higher I/O maximums with no need to manually provision A very easy migration process that allows almost zero downtime
  • 15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon RDS to Aurora PostgreSQL How we did it Create a CNAME in Amazon Route 53 that points to the RDS instance hostname Update all configurations that accesses the RDS instance to the CNAME Created a new Aurora parameter group that closely matched RDS parameter group Turns off nonessential services to limit writes to the RDS instance Created a Aurora read replica for the RDS master
  • 16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon RDS to Aurora PostgreSQL How we did it Wait for all replication data to be fully synced Stop all writes to the old RDS instance Promote the Aurora read replica Update the CNAME to the Aurora read replica hostname Stop the old RDS instance Start all services
  • 17. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Migration from Amazon RDS to Aurora PostgreSQL 0 50 100 150 200 250 300 Workflow 1 Workflow 2 Workflow 3 Workflow 4 Workflow completion time (minutes) RDS Aurora
  • 18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 19. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lessons learned AWS keeps making things easier If we had to do this again, AWS DMS and Aurora PostgreSQL would have made the initial migration faster and with less downtime Aurora doesn’t solve all problems If you have very large joins you will still see performance issues Look at optimizing queries or changing work_mem to do operations all in memory Don’t wait until you are almost out of a resource We waited too long and had issues with disk capacity on our RDS instance while migrating to Aurora
  • 20. Thank you! © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Joey Kwasniewski jkwasniewski@classpass.com
  • 21. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.