multi-master postgresql architectures in cloud · agenda what is multi-master? physical vs logical...

66
Multi-Master Multi-Master PostgreSQL PostgreSQL Architectures Architectures in Cloud in Cloud Gülçin Yıldırım Jelínek Gülçin Yıldırım Jelínek 1

Upload: others

Post on 21-May-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Multi-MasterMulti-MasterPostgreSQLPostgreSQLArchitecturesArchitecturesin Cloudin CloudGülçin Yıldırım JelínekGülçin Yıldırım Jelínek 1

Page 2: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

select * from me;select * from me;Board of Directors @ Cloud Services Manager @ Main Organizer @ Member @  MSc, Computer & Systems Eng. @ BSc, Applied Mathematics @ Writes on 2ndQuadrant From TurkeyLives in Prague

PostgreSQL Europe2ndQuadrant

Prague PostgreSQL MeetupPostgres Women

TalTechYildiz Technical University

blog

Github: @apatheticmagpie

gulcin 2

Page 3: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

AgendaAgendaWhat is Multi-Master?What is Multi-Master?Physical vs Logical ReplicationPhysical vs Logical ReplicationPostgres-BDR Postgres-BDR Multi-Master ArchitecturesMulti-Master ArchitecturesMulti-Master Postgres in Cloud (GDS)Multi-Master Postgres in Cloud (GDS)Our Experience with Cloud PostgresOur Experience with Cloud PostgresConclusionConclusionQuestionsQuestions

3

Page 4: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

What is Multi-Master?What is Multi-Master?

Replicate writes between multiple mastersReplicate writes between multiple mastersAsynchronous with conflictsAsynchronous with conflictsConflict-free (consensus)Conflict-free (consensus)

4

Page 5: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Physical vs Logical ReplicationPhysical vs Logical Replication

Replay WALWAL cannot be changed

Bit copy of upstreamAll or nothingSame major version

Can't write to downstream

Logical decoding Extension APIRow changesCommitted changes

Selective replicationCross-versionCan write to all nodes

5

Page 6: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Physical vs Logical ReplicationPhysical vs Logical Replication

6

Page 7: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Postgres-BDRPostgres-BDR

Multi-masterMulti-masterAsynchronousAsynchronousEventually consistentEventually consistent

Does not prevent concurrent writesDoes not prevent concurrent writesOptimistic conflict detection (after commit)Optimistic conflict detection (after commit)Automatic conflict resolutionAutomatic conflict resolution

Used for Logical Replication development in PGUsed for Logical Replication development in PG

7

Page 8: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Multi-Master Architectures - IMulti-Master Architectures - I

Geographically distributed clusterGeographically distributed cluster8

Page 9: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

AlwaysOn ArchitectureAlwaysOn Architecture

Multi-Master Architectures - IIMulti-Master Architectures - II

9

Page 10: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

AlwaysOn ArchitectureAlwaysOn Architecture

Application

ConnectionRouter

M-Lead

Multi-Master Architectures - IIMulti-Master Architectures - II

9

Page 11: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

AlwaysOn ArchitectureAlwaysOn Architecture

Application

ConnectionRouter

Postgres-BDR

M-Lead M-Shadow

Multi-Master Architectures - IIMulti-Master Architectures - II

9

Page 12: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Global Database as a ServiceGlobal Database as a Service

Bundled up best PostgreSQLpractices into our cloudservice, with high-availability,and 24x7 support by the bestPostgreSQL engineers! 

We developWe hostWe manageWe supportYOU USE!

10

Page 13: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

GDS FlavoursGDS Flavours

11

Page 14: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Single MasterSingle Master

Development1 primary databaseNo support

Test1 primary database1 replica databaseGold Support

Production1 primary database2 replica databasesBackupsPlatinum Support

12

Page 15: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Multi MasterMulti Master

Bi-Directional Replication withPostgres-BDR 3.0High availabilityGeographically distributed clusterZero Downtime Upgrades

Different Postgres versionsFlexibility

Different configurationDifferent instance sizes (CPU,disk, memory etc)

13

Page 16: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

physical rep.

bi-directional replication

subcluster a subcluster b

geo cluster

Multi Master ArchitectureMulti Master Architecture

physical rep.

14

Page 17: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

AlwaysOnAlwaysOnProvides at least 4 Nines (99.99%)availabilityDeployed in single region with twodifferent availability zones:

2 BDR primary2 physical replicaBackup

“Very High Availability” described inthe BDR whitepaper.

15

Page 18: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

AlwaysOn ArchitectureAlwaysOn Architecture

M-Lead M-Shadow

bi-directional replication

physical rep.

16

Page 19: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

17

Page 20: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

1. Set your database password first2. Choose the instance you want to connect3. Choose one of the provided connection string types4. Connect with your db client

17

Page 21: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

1. Set your database password first2. Choose the instance you want to connect3. Choose one of the provided connection string types4. Connect with your db client

17

Page 22: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

1. Set your database password first2. Choose the instance you want to connect3. Choose one of the provided connection string types4. Connect with your db client

17

Page 23: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

1. Set your database password first2. Choose the instance you want to connect3. Choose one of the provided connection string types4. Connect with your db client

17

Page 24: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

1. Set your database password first2. Choose the instance you want to connect3. Choose one of the provided connection string types4. Connect with your db client

17

Page 25: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

How to Connect to your DB?How to Connect to your DB?

1. Set your database password first2. Choose the instance you want to connect3. Choose one of the provided connection string types4. Connect with your db client

17

Page 26: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Database ConfigurationDatabase Configuration

18

Page 27: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Database ConfigurationDatabase Configuration

18

Page 28: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Database ConfigurationDatabase Configuration

Search parameter name

18

Page 29: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Monitoring DashboardMonitoring Dashboard

19

Page 30: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Dynamic ScalingDynamic Scaling

20

Page 31: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Dynamic ScalingDynamic Scaling

20

Page 32: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Dynamic ScalingDynamic Scaling

20

Page 33: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Dynamic ScalingDynamic Scaling

20

Page 34: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

LoggingLogging

21

Page 35: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

LoggingLogging

21

Page 36: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

LoggingLogging

Action log of all clusters

21

Page 37: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

LoggingLogging

Action log of all clusters

21

Page 38: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

LoggingLogging

Action log of all clusters

Filter by cluster name

21

Page 39: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

BenchmarksBenchmarks

22

Page 40: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

BenchmarksBenchmarks

22

Page 41: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

BenchmarksBenchmarks

22

Page 42: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

BenchmarksBenchmarks

TPS

22

Page 43: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

BenchmarksBenchmarks

TPS

Latency

22

Page 44: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

SecuritySecurity

SSL connections only

Encrypted Data at Rest

No SUPERUSER 

VPC Peering

IP Whitelisting

Authenticate with 2ndQuadrant SSO

23

Page 45: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Automated BackupsAutomated Backups

24

Page 46: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Automated BackupsAutomated Backups

24

Page 47: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Automated BackupsAutomated Backups

24

Page 48: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Automated BackupsAutomated Backups

24

Page 49: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Automated BackupsAutomated Backups

24

Page 50: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Automated BackupsAutomated Backups

Filter backups by status and cluster 24

Page 51: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Scheduled BackupsScheduled Backups

25

Page 52: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Scheduled BackupsScheduled Backups

25

Page 53: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Scheduled BackupsScheduled Backups

Backup schedule

25

Page 54: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Scheduled BackupsScheduled Backups

Backup schedule

25

Page 55: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Scheduled BackupsScheduled Backups

Backup retentionBackup schedule

25

Page 56: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Point-in-Time RecoveryPoint-in-Time Recovery

26

Page 57: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Point-in-Time RecoveryPoint-in-Time Recovery

26

Page 58: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Point-in-Time RecoveryPoint-in-Time Recovery

Pick time26

Page 59: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

DocumentationDocumentation

27

Page 60: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

DocumentationDocumentation

27

Page 61: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

DocumentationDocumentation

Docs (WiP)

27

Page 62: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

DocumentationDocumentation

Docs (WiP)

27

Page 63: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

DocumentationDocumentation

Docs (WiP)

Interactive API docs

27

Page 64: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Postgres Cloud ManagerPostgres Cloud Manager

28

Page 65: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

ConclusionConclusionPostgres in Cloud is a go!Postgres in Cloud is a go!Multi-Master addsMulti-Master adds new possibilitiesnew possibilitiesIt's possible to createIt's possible to create your own cloudyour own cloudindependent ofindependent of the platformthe platformAutomation enablesAutomation enables easy managementeasy managementPostgres SupportPostgres Support applies to Cloud!applies to Cloud!

29

Page 66: Multi-Master PostgreSQL Architectures in Cloud · Agenda What is Multi-Master? Physical vs Logical Replication Postgres-BDR Multi-Master Architectures Multi-Master Postgres in Cloud

Questions?Questions?

Tešekkürler!Tešekkürler!

30