SlideShare a Scribd company logo
Service Platform Architect
Brandon Kang
sangjinn@gmail.com
https://tech.brandonkang.net
July 2020
How to Replicate
PostgreSQL Database
/ / 0 2 /
.
2 : / 2 . /
A
@ /: /
/ /
Replication Overall
Primary Server
• A server for both READ and WRITE
Standby Server = Slave server, Backup server, Replica, etc.
• A server where the data is kept in sync with the master continuously
• A warm standby server can’t be connected until it is promoted to primary
• A hot standby server accepts connections and serves read-only queries
• Data is written to the master server and propagated to the slave servers
• When primary server has an issue, a standby server will take over and
continue to take ‘WRITE” process
WAL Shipping Replication
WAL(Write-Ahead Logging)
• A log file where all the modifications to the database
• WAL is used for recovery after a database crash, ensuring data integrity
• WAL is used in database systems to achieve atomicity and durability
WAL based Replication ­ Streaming WAL Records
• Write-ahead log records are used to keep the data in sync
• WAL record chunks are streamed by database servers to synchronize
• Standby server connects to the master to receive the WAL chunks
• WAL records are streamed as they are generated
• The streaming of WAL records need not wait for the WAL file to be filled
Streaming Replication
PRIMARY
Server
Standby
Server
WAL
Sender
WAL
Receiver
WAL Record
READ ONLYREAD/WRITE
pg_wal
directory
WAL
File
pg_wal
directory
WAL
File
Synchronize
- WAL Record1
- WAL Record2
- WAL Record3
……
Replication Configuration
Primary Node ­ pg_hba.conf
/PG_HOME/DATA/pg_hba.conf
# Allow replication connections from localhost,
# by a user with the replication privilege.
# TYPE DATABASE USER ADDRESS METHOD
host replication repl_user IPaddress(CIDR) md5
Restart PostgreSQL service on the primary node
Internal IP ranges
Firewall Open for this.
Replication Configuration
Primary Node ­/PG_HOME/DATA/postgres.conf
# Possible values are replica|minimal|logical
wal_level = hot_standby
archive_mode = on #Syncronize with Primany node using wal archive
archive_command = ‘cp %p /PG_TBS/backup/archive/%f’ #psql_superuser archive backup
# required for pg_rewind capability when standby goes out of sync with master
wal_log_hints = on
# sets the maximum number of concurrent connections from the standby servers.
max_wal_senders = 2
# The below parameter is used to tell the master to keep the minimum number of
# segments of WAL logs so that they are not deleted before standby consumes them.
# each segment is 16MB
wal_keep_segments = 16
Replication Configuration
Secondary Node ­/PG_HOME/DATA/postgres.conf
hot_standby = on
Secondary Node ­/PG_HOME/DATA/recovery.conf
standby_mode = ‘on’
restore_command = ‘cp %p /PG_TBS/backup/archive/%f “%p”’
Primary_conninfo = ‘host=… ports=… user=postgres password= application_name=slave1’
# Explaining a few options used for pg_basebackup utility
# -X option is used to include the required transaction log files (WAL files) in the
# backup. When you specify stream, this will open a second connection to the server
# and start streaming the transaction log at the same time as running the backup.
# -c is the checkpoint option. Setting it to fast will force the checkpoint to be
# created soon.
# -W forces pg_basebackup to prompt for a password before connecting
# to a database.
pg_basebackup -D <data_directory> -h <master_host> -X stream -c fast -U
repl_user -W
Replication Configuration
Secondary Node ­ pg_basebackup utility
# Explaining a few options used for pg_basebackup utility
# -X option is used to include the required transaction log files (WAL files) in the
# backup. When you specify stream, this will open a second connection to the server
# and start streaming the transaction log at the same time as running the backup.
# -c is the checkpoint option. Setting it to fast will force the checkpoint to be
# created soon.
# -W forces pg_basebackup to prompt for a password before connecting
# to a database.
pg_basebackup -D <data_directory> -h <master_host> -X stream -c fast -U repl_user -W
Example)
$pg_basebackup ­h localhost ­p 5170 -u postgres ­D /PG_TBS/cluster -checkpoint=fast --progress
Replication Configuration
Secondary Node ­ Replication configuration file
# Specifies whether to start the server as a standby. In streaming replication,
# this parameter must be set to on.
standby_mode = ‘on’
# Specifies a connection string which is used for the standby server to connect
# with the primary/master.
primary_conninfo = ‘host=<master_host> port=<postgres_port> user=<replication_user>
password=<password> application_name=”host_name”’
# Specifies recovering to a particular timeline. The default is to recover along the
# same timeline that was current when the base backup was taken.
# Setting this to latest recovers to the latest timeline found
# in the archive, which is useful in a standby server.
recovery_target_timeline = ‘latest’
Start PostgreSQL service on the Standby node
Replication Testing
postgres=# select * from pg_stat_replication ;
-[ RECORD 1 ]----+---------------------------------
pid | 1114
usesysid | 16384
usename | repuser
application_name | walreceiver
client_addr | 127.0.0.1
client_hostname |
client_port | 52444
backend_start | 08-MAR-20 19:54:05.535695 -04:00
state | streaming
..
sync_priority | 0
sync_state | async
ps ­ef | grep postgres
[Master] wal sender process check
[Standby] wal receiver & startup process check
SELECT * FROM pg_stat_replication; Query execution on the Primary/Standby nodes
Replication Testing
pg_is_in_recovery(): A function to check if standby server is still in recovery mode or not
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)
pg_last_xact_replay_timestamp(): A function shows time stamp of last replica transaction
postgres=# select pg_last_xact_replay_timestamp();
pg_last_xact_replay_timestamp
----------------------------------
08-MAR-20 20:54:27.635591 -04:00 (1 row)
SELECT CASE WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location()
THEN 0
ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp())
END AS log_delay;
Calculating logs in seconds
Scaling PostgreSQL
PRIMARY
Server
Standby
Server
WAL
Sender
WAL
Receiver
WAL Record
WRITE
Synchronize
HAProxy /
NGINX / F5 READ
WRITE
READ
pgBouncer
primary_db
standby_db
Application
- Thank You. -
Service Platform Architect
Brandon Kang
sangjinn@gmail.com
https://tech.brandonkang.net

More Related Content

What's hot (20)

PDF
Pgbr 2013 postgres on aws
Emanuel Calvo
 
PPTX
HBase Coprocessor Introduction
Schubert Zhang
 
PDF
ProstgreSQLFailoverConfiguration
Suyog Shirgaonkar
 
PDF
Out of the box replication in postgres 9.4(pg confus)
Denish Patel
 
PDF
Streaming replication in practice
Alexey Lesovsky
 
PDF
PostgreSQL Replication Tutorial
Hans-Jürgen Schönig
 
PDF
Failsafe Mechanism for Yahoo Homepage
Kit Chan
 
PDF
Scaling PostgreSQL with Skytools
Gavin Roy
 
PDF
plProxy, pgBouncer, pgBalancer
elliando dias
 
PPTX
Resources, Providers, and Helpers Oh My!
Brian Stajkowski
 
PPTX
HBaseCon 2013: A Developer’s Guide to Coprocessors
Cloudera, Inc.
 
PDF
Replacing Squid with ATS
Kit Chan
 
PDF
Postgresql database administration volume 1
Federico Campoli
 
PPTX
Kafka Tutorial: Advanced Producers
Jean-Paul Azar
 
PPTX
Kafka: Internals
Knoldus Inc.
 
PDF
GitLab PostgresMortem: Lessons Learned
Alexey Lesovsky
 
PDF
On The Building Of A PostgreSQL Cluster
Srihari Sriraman
 
PDF
PostgreSQL Performance Tuning
elliando dias
 
PDF
Apache lb
Ksd Che
 
PDF
Kafka meetup JP #3 - Engineering Apache Kafka at LINE
kawamuray
 
Pgbr 2013 postgres on aws
Emanuel Calvo
 
HBase Coprocessor Introduction
Schubert Zhang
 
ProstgreSQLFailoverConfiguration
Suyog Shirgaonkar
 
Out of the box replication in postgres 9.4(pg confus)
Denish Patel
 
Streaming replication in practice
Alexey Lesovsky
 
PostgreSQL Replication Tutorial
Hans-Jürgen Schönig
 
Failsafe Mechanism for Yahoo Homepage
Kit Chan
 
Scaling PostgreSQL with Skytools
Gavin Roy
 
plProxy, pgBouncer, pgBalancer
elliando dias
 
Resources, Providers, and Helpers Oh My!
Brian Stajkowski
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
Cloudera, Inc.
 
Replacing Squid with ATS
Kit Chan
 
Postgresql database administration volume 1
Federico Campoli
 
Kafka Tutorial: Advanced Producers
Jean-Paul Azar
 
Kafka: Internals
Knoldus Inc.
 
GitLab PostgresMortem: Lessons Learned
Alexey Lesovsky
 
On The Building Of A PostgreSQL Cluster
Srihari Sriraman
 
PostgreSQL Performance Tuning
elliando dias
 
Apache lb
Ksd Che
 
Kafka meetup JP #3 - Engineering Apache Kafka at LINE
kawamuray
 

Similar to How to Replicate PostgreSQL Database (20)

PDF
Out of the Box Replication in Postgres 9.4(pgconfsf)
Denish Patel
 
PDF
Out of the Box Replication in Postgres 9.4(PgConfUS)
Denish Patel
 
PDF
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
EDB
 
PPTX
StreSd332g_ReplADSSAon_aerasd333333.pptx
anand90rm
 
PDF
PostgreSQL Replication High Availability Methods
Mydbops
 
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
Postgresql 12 streaming replication hol
Vijay Kumar N
 
PPTX
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
nadirpervez2
 
PPTX
PG_Phsycal_logical_study_Replication.pptx
ankitmodidba
 
PDF
The Magic of Hot Streaming Replication, Bruce Momjian
Fuenteovejuna
 
PDF
Streaming replication
Sandino Araico Sánchez
 
PPT
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Command Prompt., Inc
 
PDF
High Availability PostgreSQL with Zalando Patroni
Zalando Technology
 
PDF
Postgres Vienna DB Meetup 2014
Michael Renner
 
PDF
configuring a warm standby, the easy way
Command Prompt., Inc
 
ODP
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Experts, Inc.
 
PDF
PostgreSQL replication
Masao Fujii
 
PPTX
PostgreSQL Hangout Replication Features v9.4
Ashnikbiz
 
PDF
PostgreSQL replication
NTT DATA OSS Professional Services
 
Out of the Box Replication in Postgres 9.4(pgconfsf)
Denish Patel
 
Out of the Box Replication in Postgres 9.4(PgConfUS)
Denish Patel
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
EDB
 
StreSd332g_ReplADSSAon_aerasd333333.pptx
anand90rm
 
PostgreSQL Replication High Availability Methods
Mydbops
 
Out of the Box Replication in Postgres 9.4(PgCon)
Denish Patel
 
Out of the Box Replication in Postgres 9.4(PgCon)
Denish Patel
 
Postgresql 12 streaming replication hol
Vijay Kumar N
 
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
nadirpervez2
 
PG_Phsycal_logical_study_Replication.pptx
ankitmodidba
 
The Magic of Hot Streaming Replication, Bruce Momjian
Fuenteovejuna
 
Streaming replication
Sandino Araico Sánchez
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Command Prompt., Inc
 
High Availability PostgreSQL with Zalando Patroni
Zalando Technology
 
Postgres Vienna DB Meetup 2014
Michael Renner
 
configuring a warm standby, the easy way
Command Prompt., Inc
 
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Experts, Inc.
 
PostgreSQL replication
Masao Fujii
 
PostgreSQL Hangout Replication Features v9.4
Ashnikbiz
 
PostgreSQL replication
NTT DATA OSS Professional Services
 
Ad

More from SangJin Kang (15)

PDF
웹에 빠른 날개를 달아주는 웹 성능 향상 이야기
SangJin Kang
 
PDF
Web Performance Optimization with HTTP/3
SangJin Kang
 
PDF
Scalability strategies for cloud based system architecture
SangJin Kang
 
PDF
HTTP/3 시대의 웹 성능 최적화 기술 이해하기
SangJin Kang
 
PDF
수요자 중심의 클라우드 운영 및 전략 (CIO Summit 2019)
SangJin Kang
 
PDF
How to develop and localize Xbox 360 titles
SangJin Kang
 
PDF
Akamai 서비스 트러블 슈팅 및 테스트 방법과 도구
SangJin Kang
 
PDF
HTTP 프로토콜의 이해와 활용
SangJin Kang
 
PDF
HTTP/2와 웹 성능 최적화 방안
SangJin Kang
 
PDF
Akamai Korea - Tech Day (2015/03/11) DNS
SangJin Kang
 
PDF
Akamai Korea - Tech Day (2015/03/11) HTTP/2
SangJin Kang
 
PPT
HTML5 for web app. development
SangJin Kang
 
PPTX
Agile - SCRUM을 통한 개발관리
SangJin Kang
 
PPT
XNA2.0 Network Programming
SangJin Kang
 
PPT
XNA Introduction
SangJin Kang
 
웹에 빠른 날개를 달아주는 웹 성능 향상 이야기
SangJin Kang
 
Web Performance Optimization with HTTP/3
SangJin Kang
 
Scalability strategies for cloud based system architecture
SangJin Kang
 
HTTP/3 시대의 웹 성능 최적화 기술 이해하기
SangJin Kang
 
수요자 중심의 클라우드 운영 및 전략 (CIO Summit 2019)
SangJin Kang
 
How to develop and localize Xbox 360 titles
SangJin Kang
 
Akamai 서비스 트러블 슈팅 및 테스트 방법과 도구
SangJin Kang
 
HTTP 프로토콜의 이해와 활용
SangJin Kang
 
HTTP/2와 웹 성능 최적화 방안
SangJin Kang
 
Akamai Korea - Tech Day (2015/03/11) DNS
SangJin Kang
 
Akamai Korea - Tech Day (2015/03/11) HTTP/2
SangJin Kang
 
HTML5 for web app. development
SangJin Kang
 
Agile - SCRUM을 통한 개발관리
SangJin Kang
 
XNA2.0 Network Programming
SangJin Kang
 
XNA Introduction
SangJin Kang
 
Ad

Recently uploaded (20)

PDF
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PDF
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
PPTX
What Is Data Integration and Transformation?
subhashenia
 
PDF
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PPTX
big data eco system fundamentals of data science
arivukarasi
 
PDF
Research Methodology Overview Introduction
ayeshagul29594
 
PPTX
Feb 2021 Ransomware Recovery presentation.pptx
enginsayin1
 
PDF
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
PDF
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PDF
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
What Is Data Integration and Transformation?
subhashenia
 
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
big data eco system fundamentals of data science
arivukarasi
 
Research Methodology Overview Introduction
ayeshagul29594
 
Feb 2021 Ransomware Recovery presentation.pptx
enginsayin1
 
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 

How to Replicate PostgreSQL Database

  • 1. Service Platform Architect Brandon Kang [email protected] https://tech.brandonkang.net July 2020 How to Replicate PostgreSQL Database / / 0 2 / . 2 : / 2 . / A @ /: / / /
  • 2. Replication Overall Primary Server • A server for both READ and WRITE Standby Server = Slave server, Backup server, Replica, etc. • A server where the data is kept in sync with the master continuously • A warm standby server can’t be connected until it is promoted to primary • A hot standby server accepts connections and serves read-only queries • Data is written to the master server and propagated to the slave servers • When primary server has an issue, a standby server will take over and continue to take ‘WRITE” process
  • 3. WAL Shipping Replication WAL(Write-Ahead Logging) • A log file where all the modifications to the database • WAL is used for recovery after a database crash, ensuring data integrity • WAL is used in database systems to achieve atomicity and durability WAL based Replication ­ Streaming WAL Records • Write-ahead log records are used to keep the data in sync • WAL record chunks are streamed by database servers to synchronize • Standby server connects to the master to receive the WAL chunks • WAL records are streamed as they are generated • The streaming of WAL records need not wait for the WAL file to be filled
  • 4. Streaming Replication PRIMARY Server Standby Server WAL Sender WAL Receiver WAL Record READ ONLYREAD/WRITE pg_wal directory WAL File pg_wal directory WAL File Synchronize - WAL Record1 - WAL Record2 - WAL Record3 ……
  • 5. Replication Configuration Primary Node ­ pg_hba.conf /PG_HOME/DATA/pg_hba.conf # Allow replication connections from localhost, # by a user with the replication privilege. # TYPE DATABASE USER ADDRESS METHOD host replication repl_user IPaddress(CIDR) md5 Restart PostgreSQL service on the primary node Internal IP ranges Firewall Open for this.
  • 6. Replication Configuration Primary Node ­/PG_HOME/DATA/postgres.conf # Possible values are replica|minimal|logical wal_level = hot_standby archive_mode = on #Syncronize with Primany node using wal archive archive_command = ‘cp %p /PG_TBS/backup/archive/%f’ #psql_superuser archive backup # required for pg_rewind capability when standby goes out of sync with master wal_log_hints = on # sets the maximum number of concurrent connections from the standby servers. max_wal_senders = 2 # The below parameter is used to tell the master to keep the minimum number of # segments of WAL logs so that they are not deleted before standby consumes them. # each segment is 16MB wal_keep_segments = 16
  • 7. Replication Configuration Secondary Node ­/PG_HOME/DATA/postgres.conf hot_standby = on Secondary Node ­/PG_HOME/DATA/recovery.conf standby_mode = ‘on’ restore_command = ‘cp %p /PG_TBS/backup/archive/%f “%p”’ Primary_conninfo = ‘host=… ports=… user=postgres password= application_name=slave1’ # Explaining a few options used for pg_basebackup utility # -X option is used to include the required transaction log files (WAL files) in the # backup. When you specify stream, this will open a second connection to the server # and start streaming the transaction log at the same time as running the backup. # -c is the checkpoint option. Setting it to fast will force the checkpoint to be # created soon. # -W forces pg_basebackup to prompt for a password before connecting # to a database. pg_basebackup -D <data_directory> -h <master_host> -X stream -c fast -U repl_user -W
  • 8. Replication Configuration Secondary Node ­ pg_basebackup utility # Explaining a few options used for pg_basebackup utility # -X option is used to include the required transaction log files (WAL files) in the # backup. When you specify stream, this will open a second connection to the server # and start streaming the transaction log at the same time as running the backup. # -c is the checkpoint option. Setting it to fast will force the checkpoint to be # created soon. # -W forces pg_basebackup to prompt for a password before connecting # to a database. pg_basebackup -D <data_directory> -h <master_host> -X stream -c fast -U repl_user -W Example) $pg_basebackup ­h localhost ­p 5170 -u postgres ­D /PG_TBS/cluster -checkpoint=fast --progress
  • 9. Replication Configuration Secondary Node ­ Replication configuration file # Specifies whether to start the server as a standby. In streaming replication, # this parameter must be set to on. standby_mode = ‘on’ # Specifies a connection string which is used for the standby server to connect # with the primary/master. primary_conninfo = ‘host=<master_host> port=<postgres_port> user=<replication_user> password=<password> application_name=”host_name”’ # Specifies recovering to a particular timeline. The default is to recover along the # same timeline that was current when the base backup was taken. # Setting this to latest recovers to the latest timeline found # in the archive, which is useful in a standby server. recovery_target_timeline = ‘latest’ Start PostgreSQL service on the Standby node
  • 10. Replication Testing postgres=# select * from pg_stat_replication ; -[ RECORD 1 ]----+--------------------------------- pid | 1114 usesysid | 16384 usename | repuser application_name | walreceiver client_addr | 127.0.0.1 client_hostname | client_port | 52444 backend_start | 08-MAR-20 19:54:05.535695 -04:00 state | streaming .. sync_priority | 0 sync_state | async ps ­ef | grep postgres [Master] wal sender process check [Standby] wal receiver & startup process check SELECT * FROM pg_stat_replication; Query execution on the Primary/Standby nodes
  • 11. Replication Testing pg_is_in_recovery(): A function to check if standby server is still in recovery mode or not postgres=# select pg_is_in_recovery(); pg_is_in_recovery ------------------- t (1 row) pg_last_xact_replay_timestamp(): A function shows time stamp of last replica transaction postgres=# select pg_last_xact_replay_timestamp(); pg_last_xact_replay_timestamp ---------------------------------- 08-MAR-20 20:54:27.635591 -04:00 (1 row) SELECT CASE WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) END AS log_delay; Calculating logs in seconds
  • 12. Scaling PostgreSQL PRIMARY Server Standby Server WAL Sender WAL Receiver WAL Record WRITE Synchronize HAProxy / NGINX / F5 READ WRITE READ pgBouncer primary_db standby_db Application
  • 13. - Thank You. - Service Platform Architect Brandon Kang [email protected] https://tech.brandonkang.net