Highway to Hell
- r Stairway to
Cloud?
PGConf.EU 2018, Lisbon
ALEXANDER KUKUSHKIN 25-10-2018
Please write title, subtitle and speaker name in all capital letters
Highway to Hell or Stairway to Cloud? PGConf.EU 2018, Lisbon - - PowerPoint PPT Presentation
Please write title, subtitle and speaker name in all capital letters Highway to Hell or Stairway to Cloud? PGConf.EU 2018, Lisbon ALEXANDER KUKUSHKIN 25-10-2018 Put images in the grey dotted box "unsupported placeholder" ABOUT
Highway to Hell
Cloud?
PGConf.EU 2018, Lisbon
ALEXANDER KUKUSHKIN 25-10-2018
Please write title, subtitle and speaker name in all capital letters
2
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
Database Engineer @ZalandoTech The Patroni guy alexander.kukushkin@zalando.de Twitter: @cyberdemn
3
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder"
4
Please write the title in all capital letters
5
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Data migration & switchover About the old setup Choosing your cloud options Retain access & make it secure
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Backup & recovery Conclusions
6
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Primary Replica
app1 app2 app3 data center
vip vip
7
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
○ two tables per event ■ Hot data (last 10 days) ■ Archived data ○ No primary/unique keys!
8
Put images in the grey dotted box "unsupported placeholder" - behind the
stays white) Write the quote in all capital letters
9
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
10
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Data migration & switchover About the old setup
Choosing your cloud options
Retain access & make it secure
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Backup & recovery Conclusions
11
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
○ i3 instances ○ EBS backed instances ■ gp2 ■ io1
12
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ All instances are sharing the same storage!
gp2 EBS, $0.119/GB-month
13
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ low latency ○ high bandwidth and throughput
○ Minimum 3 instances for HA
14
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
instances
volume: ○ gp2: 160 MB/s, 10000 IOPS ○ io1: 500 MB/s, 32000 IOPS
15
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
30000 IOPS 10000 IOPS
16
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
experiments
○ Ideally, replicate production workload
17
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
HA Cluster Single Instance
18
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
○ 32 vCPU cores ○ 244 GB RAM ○ 37500 IOPS ○ 875 MB/s
○ 6 * 3333 GB, raid 0
19
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Data migration & switchover About the old setup Choosing your cloud options
Retain access & make it secure
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Backup & recovery Conclusions
20
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ DNS ○ “Proxy” (iptables/HAProxy/pgbouncer)
○ Internet traffic MUST be encrypted! ○ Some of the legacy applications are not using SSL ■ Nobody wants to fix legacy code :( ○ How to protect from Man-in-the-Middle attack?
21
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
primary pgbouncer 5432
Primary
5432
Replica
replica pgbouncer
app1 app2 app3 data center
Cluster Security Group
vip vip
22
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
the CA private key
certificate from pgbouncer
Postgres server certificate
23
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ ssl_cert_file = ‘server.crt’ ○ ssl_key_file = ‘server.key’ ○ ssl_ca_file = ‘ca.crt’
○ hostssl all all A.B.C.D/32 md5 clientcert=1 ○ hostnossl all all A.B.C.D/32 reject
data center public ip
24
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ pool_mode = session ○ auth_file = users.conf ○ auth_query = “SELECT * FROM pgbouncer.user_lookup($1)” ○ server_tls_sslmode = verify-ca ○ server_tls_ca_file = ca.crt ○ server_tls_cert_file = client.crt ○ server_tls_key_file = client.key
25
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Data migration & switchover
About the old setup Choosing your cloud options Retain access & make it secure
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Backup & recovery Conclusions
26
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ via VPN? ○ via SSH tunnel?
○ WAL-E ○ pgBackRest ○ WAL-G
27
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Replica Replica
app1 app2 app3 data center
Primary Replica
S3 bucket: Backup + WAL
wal-e w a l
w a l
etcd
vip vip
28
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
12 hours
9 hours
4 hours replication lag in such setup is usually about a few seconds and determined by amount of write activity on the primary.
29
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
1. Shutdown the main application writing into DB 2. Move the replica virtual ip to the pgbouncer host 3. Shutdown the replica in the data center 4. Move the primary virtual IP to the pgbouncer host 5. Shutdown the primary in the data center 6. Promote replica in the Cloud 7. Start the main application 8. Start replicas in the data center with the new recovery.conf
30
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Replica Replica
app1 app2 app3 data center
Primary Replica
S3 bucket: Backup + WAL
wal-e wal-e wal-e
etcd
primary pgbouncer replica pgbouncer
vip vip
31
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Replica Replica
app1 app2 app3 data center
Primary Replica
S3 bucket: Backup + WAL
wal-e wal-e wal-e
etcd
primary pgbouncer replica pgbouncer
vip
vip SSL
32
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Replica Replica
app1 app2 app3 data center
Primary
S3 bucket: Backup + WAL
wal-e wal-e wal-e
etcd
primary pgbouncer replica pgbouncer
vip
vip SSL
33
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Replica Replica
app1 app2 app3 data center
Primary
S3 bucket: Backup + WAL
wal-e wal-e wal-e
etcd
primary pgbouncer replica pgbouncer vip SSL vip SSL
34
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Replica Replica
app1 app2 app3 data center
S3 bucket: Backup + WAL
wal-e wal-e
etcd
primary pgbouncer replica pgbouncer vip SSL vip SSL
35
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Primary Replica
app1 app2 app3 data center
S3 bucket: Backup + WAL
wal-e wal-e
etcd
primary pgbouncer replica pgbouncer vip SSL vip SSL
36
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Cluster Security Group
Primary Replica
app1 app2 app3 data center
Replica Replica
S3 bucket: Backup + WAL
wal-e wal-e wal-e
etcd
wal-e primary pgbouncer SSL replica pgbouncer SSL vip vip
37
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Data migration & switchover About the old setup Choosing your cloud options Retain access & make it secure
Put images in the grey dotted box "unsupported placeholder" Please write the title in all capital letters
Backup & recovery
Conclusions
38
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
○ is too slow on big volumes of data :( ○ can’t take basebackup from the replica :(
○ incremental & differential backups ○ can’t use AWS instance profile credentials :(
○ delta backups ○ configurable compression methods: lz4, lzma, zstd, brotli ○ backward compatible with WAL-E
39
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
40
Please write the title in all capital letters Put images in the grey dotted box "unsupported placeholder" Use bullet points to summarize information rather than writing long paragraphs in the text box
41
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Switchover synchronous_commit = ‘off’
42
Please write the title in all capital letters Use bullet points to summarize information rather than writing long paragraphs in the text box
Put images in the grey dotted box "unsupported placeholder" - behind the
capital letters