SlideShare a Scribd company logo
Denish Patel
Database Architect, OmniTI
Deploying PostgreSQL on
Amazon EC2
A case study
1
Tuesday, May 7, 13
Story teller?
✤ Denish Patel
✤ denish@omniti.com
✤ Database Architect at OmniTI
✤ Heterogeneous Environment
✤ PostgreSQL, Oracle , MySQL, NoSQL
✤ Scalability, Performance & Simplicity
✤ OmniTI is hiring Database Engineer!
2
Tuesday, May 7, 13
Situation
✤ Startup
✤ Ruby on Rails Shop
✤ Entire IT architecture on Amazon Cloud
✤ 2 Identical Database Environments on EC2
✤ 4 Production Instances
✤ 50GB Each PostgreSQL 9.0 Master - Slave ( 2 Pairs)
✤ 2 QA and 2 Dev environments
3
Tuesday, May 7, 13
Situation
✤ Weekly flake out issues on EC2 instances
✤ Weekly backups using pg_dump
✤ No file system level backup
✤ Master-slave wasn’t working for months!
✤ Schema mismatch between 2 environments
✤ Almost NO monitoring in-place for DBs
4
Tuesday, May 7, 13
Situation
✤ Prod , QA and Dev ...
✤ M1 Extra large instances (m1.xlarge)
✤ 15 GB RAM, 4 Virtual Cores with 2 EC2 compute units each
✤ Configuration Management tool - Puppet
5
Tuesday, May 7, 13
The Amazon Cloud
✤ Business Benefits
✤ Offloading heavy lifting
✤ Lowers cost
✤ Reduces time to market
6
Tuesday, May 7, 13
Amazon Data Centers
7
Tuesday, May 7, 13
Amazon Instances
✤ High CPU
✤ High IO
✤ High Memory
8
Tuesday, May 7, 13
Amazon StorageTypes
9
Tuesday, May 7, 13
Network and Security
✤ Amazon Security Groups
✤ Keep your Amazon EC2 firewall permissions as restrictive as
possible.
✤ Elastic IP Address (EIP)
10
Tuesday, May 7, 13
Deployment Strategies
✤ Sizing Instances and Storage Types
✤ Configuration Management
✤ High Availability
✤ Replication
✤ Failover
✤ Operations
✤ Upgrade, Backups, Maintenance tools
✤ Monitoring
11
Tuesday, May 7, 13
Sizing Instances/Storage
✤ Understand your database , schema and data
✤ Env 1: 50GB , Env 2: 25GB
✤ 2 large archival tables
✤ Working Set about 20-30GB in total
✤ Both environments are inter-related.
✤ Decided to consolidate both environment into single cluster
12
Tuesday, May 7, 13
Sizing Instances/Storage
✤ m2.2xlarge: 34.2GB RAM, 4 Virtual Core
✤ Storage
✤ EBS
✤ RAID 10
✤ Not EBS optimized ( Cost Savings!)
✤ 850 GB
13
Tuesday, May 7, 13
Deployment Phase #1
us-east-1
AV1
AV2
us-west-1
App
Servers
db-master db-slave-
backup
db-slave
Streaming Replication
WAL shipping (OmniPITR)
14
Tuesday, May 7, 13
Configuration Management
✤ Automation
✤ Repeatability
✤ Maintainability
✤ Security
15
Tuesday, May 7, 13
Configuration Management
16
Tuesday, May 7, 13
Puppetizing Postgres
✤ DB server role
✤ PostgreSQL installation
✤ Installing common tools
✤ 3 Roles : prod-master role , prod-slave role, prod-slave-backup role
✤ PostgreSQL Configuration Files: postgresql.conf, pg_hba.conf
✤ Scripts, crontabs
17
Tuesday, May 7, 13
High Availability
✤ Replication
✤ Failover
18
Tuesday, May 7, 13
Replication
✤ Streaming replication
✤ WAL shipping , OmniPITR
✤ Different AV zones
✤ At least 1 slave in different Region
19
Tuesday, May 7, 13
Failover
✤ EIP - about 3 minutes to propagate changes after failover
✤ Failover tools
✤ Semi-automated script
✤ pgbouncer
✤ puppet
20
Tuesday, May 7, 13
Deployment Phase #2
us-east-1
AV1
AV2
us-west-1
App
Servers
db-master
db-slave-
backup
db-slave
Streaming Replication
WAL shipping (OmniPITR)
pgbouncer
21
Tuesday, May 7, 13
pgbouncer
✤ Session Pooling
✤ Supports all Postgres features
✤ Transactions Pooling
✤ Does NOT support PREPARE transactions
22
Tuesday, May 7, 13
Operations
23
Tuesday, May 7, 13
Database Upgrade
✤ Upgraded from PostgreSQL 9.0 to PostgreSQL 9.2
✤ Minimal outage upgrade using Mimeo
✤ http://www.pateldenish.com/2012/10/an-easy-way-to-reduce-
outage-window-for-postgresql-upgrade.html
24
Tuesday, May 7, 13
Beware!!
✤ Sept 24th, 2012
✤ PostgreSQL 9.1.0 to 9.1.5 & 9.2.0
✤ VACUUM all tables in your database & Rebuild Indices
✤ http://wiki.postgresql.org/wiki/20120924updaterelease
✤ April 4th, 2013
✤ PostgreSQL 9.0.* to 9.1.* & 9.2.*
✤ Security release
✤ http://www.postgresql.org/support/security/faq/2013-04-04/
25
Tuesday, May 7, 13
Backups
✤ Online Backups
✤ Daily, db-slave , OmniPITR
✤ Test the backups!!!!
✤ Schema Backups
✤ pg_extractor
✤ Offsite Backup
✤ sending backups to Amazon S3
26
Tuesday, May 7, 13
Tools
✤ tracking schema in git : pg_extractor
✤ pg_bloat_report
✤ Pg log errors reporting : tail_n_mail
✤ Log analysis: pgbadger
✤ log_min_duration_statement = 50 ms
✤ log_line_prefix= '%t [%r] [%p]: [%l-1] user=%u,db=%d,e=%e '
27
Tuesday, May 7, 13
Monitoring
28
Tuesday, May 7, 13
Database Checks
29
Tuesday, May 7, 13
Database Checks
30
Tuesday, May 7, 13
System Checks
31
Tuesday, May 7, 13
Business Metrics
32
Tuesday, May 7, 13
Histograms!
33
Tuesday, May 7, 13
References
✤ http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/
Storage.html
✤ OmniTI labs tools
✤ https://github.com/omniti-labs/pgtreats
✤ OmniPITR
✤ https://github.com/omniti-labs/omnipitr
34
Tuesday, May 7, 13

More Related Content

PDF
Postgres in Amazon RDS
Denish Patel
 
PDF
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
PostgreSQL-Consulting
 
ODP
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Experts, Inc.
 
PDF
Out of the box replication in postgres 9.4(pg confus)
Denish Patel
 
PDF
Out of the box replication in postgres 9.4
Denish Patel
 
ODP
Shootout at the AWS Corral
PostgreSQL Experts, Inc.
 
ODP
Shootout at the PAAS Corral
PostgreSQL Experts, Inc.
 
PPT
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Command Prompt., Inc
 
Postgres in Amazon RDS
Denish Patel
 
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
PostgreSQL-Consulting
 
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Experts, Inc.
 
Out of the box replication in postgres 9.4(pg confus)
Denish Patel
 
Out of the box replication in postgres 9.4
Denish Patel
 
Shootout at the AWS Corral
PostgreSQL Experts, Inc.
 
Shootout at the PAAS Corral
PostgreSQL Experts, Inc.
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Command Prompt., Inc
 

What's hot (18)

ODP
Logical replication with pglogical
Umair Shahid
 
PDF
Linux tuning to improve PostgreSQL performance
PostgreSQL-Consulting
 
PDF
PostgreSQL WAL for DBAs
PGConf APAC
 
PDF
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
PDF
Streaming replication in practice
Alexey Lesovsky
 
PDF
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
Masao Fujii
 
ODP
GUC Tutorial Package (9.0)
PostgreSQL Experts, Inc.
 
PPTX
Streaming replication in PostgreSQL
Ashnikbiz
 
PDF
Architecture for building scalable and highly available Postgres Cluster
Ashnikbiz
 
PDF
Logical Replication in PostgreSQL - FLOSSUK 2016
Petr Jelinek
 
PDF
Replication Solutions for PostgreSQL
Peter Eisentraut
 
PDF
Linux internals for Database administrators at Linux Piter 2016
PostgreSQL-Consulting
 
PDF
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
PDF
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
PPT
PostgreSQL9.3 Switchover/Switchback
Vibhor Kumar
 
PDF
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
Equnix Business Solutions
 
ODP
Fail over fail_back
PostgreSQL Experts, Inc.
 
PPTX
PostgreSQL Hangout Parameter Tuning
Ashnikbiz
 
Logical replication with pglogical
Umair Shahid
 
Linux tuning to improve PostgreSQL performance
PostgreSQL-Consulting
 
PostgreSQL WAL for DBAs
PGConf APAC
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
Streaming replication in practice
Alexey Lesovsky
 
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
Masao Fujii
 
GUC Tutorial Package (9.0)
PostgreSQL Experts, Inc.
 
Streaming replication in PostgreSQL
Ashnikbiz
 
Architecture for building scalable and highly available Postgres Cluster
Ashnikbiz
 
Logical Replication in PostgreSQL - FLOSSUK 2016
Petr Jelinek
 
Replication Solutions for PostgreSQL
Peter Eisentraut
 
Linux internals for Database administrators at Linux Piter 2016
PostgreSQL-Consulting
 
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
PostgreSQL9.3 Switchover/Switchback
Vibhor Kumar
 
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
Equnix Business Solutions
 
Fail over fail_back
PostgreSQL Experts, Inc.
 
PostgreSQL Hangout Parameter Tuning
Ashnikbiz
 
Ad

Similar to Deploying postgre sql on amazon ec2 (20)

PDF
Pgbr 2013 postgres on aws
Emanuel Calvo
 
PDF
Elephants in the Cloud
Mike Fowler
 
PDF
Best Practices & Lessons Learned from Deployment of PostgreSQL
EDB
 
ODP
Pro PostgreSQL, OSCon 2008
Robert Treat
 
PPTX
Automating Disaster Recovery PostgreSQL
Nina Kaufman
 
PPTX
Automating the Entire PostgreSQL Lifecycle
anynines GmbH
 
PDF
Top 10 Tips for an Effective Postgres Deployment
EDB
 
PDF
How to Upgrade Major Version of Your Production PostgreSQL
Keisuke Suzuki
 
PDF
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
PDF
Postgres in Production - Best Practices 2014
EDB
 
PPTX
Migrate to platform of your choice
Ashnikbiz
 
PPTX
Amazon RDS for PostgreSQL - PGConf 2016
Grant McAlister
 
PDF
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
PavelKonotopov
 
PDF
Patroni - HA PostgreSQL made easy
Alexander Kukushkin
 
PDF
Yandex.Mail success story
dev1ant
 
PPTX
Pg conf 2017 HIPAA Compliant and HA DB architecture on AWS
Glenn Poston
 
PDF
10/ EnterpriseDB @ OPEN'16
Kangaroot
 
PPTX
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Grant McAlister
 
PDF
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Payal Singh
 
PDF
Postgres Open
Ines Sombra
 
Pgbr 2013 postgres on aws
Emanuel Calvo
 
Elephants in the Cloud
Mike Fowler
 
Best Practices & Lessons Learned from Deployment of PostgreSQL
EDB
 
Pro PostgreSQL, OSCon 2008
Robert Treat
 
Automating Disaster Recovery PostgreSQL
Nina Kaufman
 
Automating the Entire PostgreSQL Lifecycle
anynines GmbH
 
Top 10 Tips for an Effective Postgres Deployment
EDB
 
How to Upgrade Major Version of Your Production PostgreSQL
Keisuke Suzuki
 
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
Postgres in Production - Best Practices 2014
EDB
 
Migrate to platform of your choice
Ashnikbiz
 
Amazon RDS for PostgreSQL - PGConf 2016
Grant McAlister
 
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
PavelKonotopov
 
Patroni - HA PostgreSQL made easy
Alexander Kukushkin
 
Yandex.Mail success story
dev1ant
 
Pg conf 2017 HIPAA Compliant and HA DB architecture on AWS
Glenn Poston
 
10/ EnterpriseDB @ OPEN'16
Kangaroot
 
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Grant McAlister
 
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Payal Singh
 
Postgres Open
Ines Sombra
 
Ad

More from Denish Patel (15)

PDF
Advanced Postgres Monitoring
Denish Patel
 
PDF
Out of the Box Replication in Postgres 9.4(PgConfUS)
Denish Patel
 
PDF
Out of the Box Replication in Postgres 9.4(pgconfsf)
Denish Patel
 
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
Denish Patel
 
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
Denish Patel
 
PDF
Choosing the "D" , Lightning talk
Denish Patel
 
PDF
Scaling postgres
Denish Patel
 
PDF
Two Elephants Inthe Room
Denish Patel
 
PPTX
Deploying Maximum HA Architecture With PostgreSQL
Denish Patel
 
PPT
Deploying Maximum HA Architecture With PostgreSQL
Denish Patel
 
PDF
P90 X Your Database!!
Denish Patel
 
PDF
Achieving Pci Compliace
Denish Patel
 
PDF
Using SQL Standards? Database SQL comparition
Denish Patel
 
PDF
Oracle10g New Features I
Denish Patel
 
PDF
Yet Another Replication Tool: RubyRep
Denish Patel
 
Advanced Postgres Monitoring
Denish Patel
 
Out of the Box Replication in Postgres 9.4(PgConfUS)
Denish Patel
 
Out of the Box Replication in Postgres 9.4(pgconfsf)
Denish Patel
 
Out of the Box Replication in Postgres 9.4(PgCon)
Denish Patel
 
Out of the Box Replication in Postgres 9.4(PgCon)
Denish Patel
 
Choosing the "D" , Lightning talk
Denish Patel
 
Scaling postgres
Denish Patel
 
Two Elephants Inthe Room
Denish Patel
 
Deploying Maximum HA Architecture With PostgreSQL
Denish Patel
 
Deploying Maximum HA Architecture With PostgreSQL
Denish Patel
 
P90 X Your Database!!
Denish Patel
 
Achieving Pci Compliace
Denish Patel
 
Using SQL Standards? Database SQL comparition
Denish Patel
 
Oracle10g New Features I
Denish Patel
 
Yet Another Replication Tool: RubyRep
Denish Patel
 

Deploying postgre sql on amazon ec2