amazon rds for postgresql grant mcalister – senior principal engineer oct 24, 2014

28
Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Upload: britton-hensley

Post on 12-Jan-2016

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Amazon RDS for PostgreSQL

Grant McAlister – Senior Principal Engineer

Oct 24, 2014

Page 2: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Amazon Relational Database Service

RDS is a managed Relational database service that is simple to deploy, easy to scale, reliable and cost-effective

Managed Service

Easy to Scale and Operate

Choice of Database Engines

High Availability

High Performance

Amazon Relational Database Service (RDS)

Page 3: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Availability – Read and Write – Multi-AZ

SecondarySecondary Primary

Physical Synchronous

Replication

Primary

AZ1 AZ2

DNS

cname update

Application Application

Primary Update

Page 4: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Backups and Disaster Recovery

• DB Snapshots– User-driven snapshots of database– Kept until explicitly deleted

• Automated Backups– Nightly system snapshots + transaction backup– Enables point-in-time restore to any point in retention period, up to

the last 5 minutes– Max retention period = 35 days

• Cross region copy– Change regions– Disaster recovery

Page 5: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Push Button Scaling

• Scale nodes vertically up or down– 14 Current Generation DB Instance Classes– db.t2.micro (AWS Free Usage Tier)– db.r3.8xlarge(32 virtual cores, 244GB)

• Online Storage Scaling 5GB-3TB– Magnetic & General Purpose SSD– Provisioned IOPS (SSD) up to 30,000

• Scale out nodes horizontally– Shard based on data or workload characteristics– Fast and easy database creation

Page 6: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Security

DB

Application

Internet

IAM

VPC

Page 7: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Amazon RDS for PostgreSQL

• Database Versions: PostgreSQL 9.3.1, 9.3.2, and 9.3.3

• Includes valuable RDS functionality– Fast Deployment– Backups and Point-in-Time-Recovery– Snapshots and Restore– Compute and Storage Scaling – Multi-AZ– Provisioned IOPs

Page 8: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

DB Parameter Groups

{DBInstanceClassMemory/12582880}Filter=“connection”

Page 9: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Launching a Postgres DB Instance

Page 10: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Select Production Use (or not)

Page 11: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Instance Details

Page 12: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Additional Configuration

Page 13: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Management Options

Page 14: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Running Instance

Page 15: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Log File Access

Page 16: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Log Parameters

Page 17: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Log File Access

Page 18: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Viewing a Log File

Date Time: SELECT pg_sleep(1);Date Time: checkpoint startingDate Time: checkpoint complete: wrote 1 buffers (0.0%); 0 transaction log file(s) added, 0 removed, 1 recycled; write=0.000 s, sync=0.003 s, total=0.016 s; sync files=1, longest=0.003 s, average=0.003 s

Page 19: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Permissions

superuser role (Postgres)

rds_superuser role (RDS provided)

Load and Use ExtensionsView and Kill SessionsCreate Tablespace …

Page 20: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Extensions

• PostGIS available• rds.extensions parameter:

– btree_gin– btree_gist– chkpass– citext– cube– dblink– dict_int– dict_xsyn– earthdistance– fuzzystrmatch

– hstore– intagg– intarray– isn– ltree– pgcrypto– pgrowlocks– pg_trgm– plperl– plpgsql

– pltcl– postgis– postgis_tiger_geocoder– postgis_topology– sslinfo– tablefunc– tsearch2– unaccent– uuid-ossp

Page 21: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

High Performance

16,500+ Read and 8,500+ Write = 25,000+ IOPS

Page 22: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Getting Started

• Launch an instance from AWS Console• Configure Network• Load Extensions• Export from existing database using pg_dump• Import to RDS using pg_restore

Page 23: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Learnings from RDS PostgreSQL - Magic Parameters

• Example – fsync = 0– Can be dangerous if you don’t understand what won’t be fsync’d

(i.e. create extension)– Safer to turn of synchronous_commit – TEST to make sure changing parameters makes sense– Dependent on “YOUR ENVIRONMENT”

Page 24: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

both on fsync=0 sync commit=0 fsync=0 & sync commit=00

2000

4000

6000

8000

10000

12000

14000

16000

1800032 thread insert

16 segments 256 segmentsTr

ansa

ction

s pe

r Sec

ond

<%4

104%

Page 25: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

both on fsync=0 sync commit=0 fsync=0 & sync commit=00

20

40

60

80

100

120

140

160

Bulk load 2GB of data

16 segments 256 segmentsTi

me

- Sec

onds

<%3

Page 26: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

fsync=1 & sync commit=0 fsync=0 & sync commit=00

5

10

15

20

25

30

35

29.1 28.8

26.125.223.9

Index build on 20GB table

maintenance_work_mem=16MB & checkpoint_segments=16maintenance_work_mem=1024MB & checkpoint_segments=16maintenance_work_mem=1024MB & checkpoint_segments=1024

Tim

e - M

inut

es

Page 27: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

maintenance_work_mem0

5

10

15

20

25

30

35

29.1

23.4 23.9

28

Index build on 20GB table

1651210244096

Tim

e - M

inut

es

Page 28: Amazon RDS for PostgreSQL Grant McAlister – Senior Principal Engineer Oct 24, 2014

Thank YouQuestions?