SlideShare a Scribd company logo
Clustering in PostgreSQL
Because one database server is never enough (and
neither is two)
PGConf Nepal
May 11-12, 2023
-[ RECORD 1 ]--------------------------------------------
name | Umair Shahid
description | 20 year veteran of the PostgreSQL community
company | Stormatics
designation | Founder
location | Islamabad, Pakistan
family | Mom, Wife & 2 kids
kid1 | Son, 16 year old
kid2 | Daughter, 13 year old
postgres=# select * from umair;
PostgreSQL Solutions for the Enterprise
Clustering & Analytics, backed by 24/7 Support and Professional Services
10 years of
popularity
As measured by
PostgreSQL Oracle
MySQL SQL Server
https://db-engines.com/en/ranking_trend
Loved by Developers
2022 Developer Survey
Most
Loved
Most Used
(Professional Developers)
Most
Wanted
On to the topic now!
What is High Availability?
● Remain operational even in the face of hardware or software failure
● Minimize downtime
● Essential for mission-critical applications that require 24/7 availability
● Measured in ‘Nines of Availability’
Nines of Availability
Availability Downtime per year
90% (one nine) 36.53 days
99% (two nines) 3.65 days
99.9% (three nines) 8.77 hours
99.99% (four nines) 52.60 minutes
99.999% (five nines) 5.26 minutes
But my database resides
in the cloud, and the
cloud is always available
Right?
Wrong!
Amazon RDS Service Level Agreement
Multi-AZ configurations for MySQL, MariaDB, Oracle, and PostgreSQL are covered by the
Amazon RDS Service Level Agreement ("SLA"). The RDS SLA affirms that AWS will use
commercially reasonable efforts to make Multi-AZ instances of Amazon RDS available
with a Monthly Uptime Percentage of at least 99.95% during any monthly billing cycle. In
the event Amazon RDS does not meet the Monthly Uptime Percentage commitment,
affected customers will be eligible to receive a service credit.*
99.95% = three and a half nines = 4.38 hours of downtime per year!!!
*
https://aws.amazon.com/rds/ha/
So - what do I do if I want
better reliability for my
mission-critical data?
Clustering!
● Multiple database servers work
together to provide redundancy
● Gives the appearance of a single
database server
● Application communicates with
the primary PostgreSQL instance
● Data is replicated to standby
instances
● Auto failover in case the primary
node goes down
What is clustering?
Primary
Standby 1 Standby 2
Application
Write
Read
Replicate
What is auto failover?
Primary
Standby 1 Standby 2
Application
Standby 1
Primary
Standby 2 New Standby
Application
Primary
Standby 1 Standby 2
Application
1 2 3
- Primary node goes down - Standby 1 gets promoted to Primary
- Standby 2 becomes subscriber to
Standby 1
- New Standby is added to the cluster
- Application talks to the new Primary
● Write to the primary
PostgreSQL instance and
read from standbys
● Data redundancy through
replication to two standbys
● Auto failover in case the
primary node goes down
Clusters with load balancing
Primary
Standby 1 Standby 2
Application
Write
Read
Replicate
● Incremental backups
● Redundancy introduced
from primary as well
standbys
● RTO and RPO balance
achieved per organizational
requirements
● Point-in-time recovery
Clusters with backups and disaster recovery
Primary
Standby 1 Standby 2
Application
Write
Read
Replicate
Incremental
Backup
Incremental
Backup
Incremental
Backup
Backup
● Shared-Everything architecture
● Load balancing for read as well as
write operations
● Database redundancy to achieve
high availability
● Asynchronous replication between
nodes for better efficiency
*with conflict resolution at the application layer
Multi-node clusters with Active-Active configuration*
Active 2
Application
Write Read Replicate
Active 1 Active 3
● Shared-Nothing architecture
● Automatic data sharding
based on defined criteria
● Read and write operations
are auto directed to the
relevant node
● Each node can have its own
standbys for high availability
Node 2
Application
Node 1 Node 3
Multi-node clusters with data sharding and horizontal scaling
Coordinator
Write Read
Globally distributed clusters
● Spin up clusters on the public
cloud, private cloud, on-prem,
bare metal, VMs, or a hybrid of
all the above
● Geo fencing for regulatory
compliance
● High availability across data
centers and geographies
Replication - synchronous vs asynchronous
Synchronous
● Data is transferred immediately
● Transaction waits for confirmation from
replica before it commits
● Ensures data consistency across all nodes
● Performance overhead caused by latency
● Used where data accuracy is critical, even
at the expense of performance
Asynchronous
● Data may not be transferred immediately
● Transaction commits without waiting for
confirmation from replica
● Data may be inconsistent across nodes
● Faster and more scalable
● Used where performance matters more
than data accuracy
Challenges in
Clustering
● Split brain
● Network Latency
● False alarms
● Data inconsistency
#AI
● Split brain
● Network Latency
● False alarms
● Data inconsistency
Challenges in
Clustering
● Defined: Node in a highly available cluster lose connectivity
with each other but continue to function independently
● Challenge: More than one node believes that it is the primary
leading to inconsistencies and possible data loss
Split Brain
● Quorum based voting
○ Majority nodes must agree on
primary
○ Cluster stops if quorum is not
achieved
● Redundancy and failover
○ Prevents a single point of
failure
● Proper configuration
● Split brain resolver
○ Software based detection &
resolution
○ Can shut down nodes in case
of scenario
● Network segmentation
○ Physical network separation
○ Avoid congestion
Split Brain - Prevention
Split Brain - Resolution
● Witness node
○ Third node that acts as a tie-breaker
○ The winner acts as primary, the loser is shut down
● Consensus algorithm
○ Paxos and Raft protocols are popular
● Manual resolution
○ DBA observes which nodes are competing to be the primary
○ Takes action based on best practices learnt from experience
● Split brain
● Network Latency
● False alarms
● Data inconsistency
Challenges in
Clustering
● Defined: Time delay when data is transmitted from one point to another
● Challenge: Delayed replication can result in data loss. Delayed signals
can trigger a false positive.
Network Latency
● Deploy nodes in proximity
○ Reduces time delay and network
hops
● Implement quorum-based system
○ If quorum isn’t achieved failover
won’t occur
● High speed, low latency
networking
○ High quality hardware and
associated software
● Optimize database configuration
○ Parameter tuning based on
workloads
○ max_connections,
tcp_keealive_idle, …
● Alerting system
○ Detect and alert admins of
possible issues to preempt false
positives
Network Latency - Preventing False Positives
● Split brain
● Network Latency
● False alarms
● Data inconsistency
Challenges in
Clustering
● Defined: A problem is reported, but in reality, there is no issue
● Challenge: Can trigger a failover when one isn’t required, leading to
unnecessary disruptions and impacting performance
False Alarms
False Alarms - Prevention
● Proper configuration
○ Best practices, past experience, and some hit & trial is required to ensure that the
thresholds are configured appropriately
● Regular maintenance
○ Latest version of software and firmware to be used in order to avoid known bugs
and exploits
● Regular testing
○ Testing of various use cases can help identify bottlenecks and possible
misconfigurations
● Multiple monitoring tools
○ Multiple tools can help cross-reference alerts and confirm if failover is required
False Alarms - Resolution
In case a false alarm is triggered …
● Check logs
○ Check the logs of cluster nodes, network devices, and other infrastructure
components to identify any anomalies
● Notify stakeholders
○ Notify all stakeholders involved in the cluster’s operations to prevent any
unnecessary action
● Monitor cluster health
○ Monitor to cluster’s health closely to ensure that it is functioning correctly
and no further false alarms are triggered
● Split brain
● Network Latency
● False alarms
● Data inconsistency
Challenges in
Clustering
● Defined: Situations where data in different nodes of a cluster becomes out of
sync, leading to inconsistent results and potential data corruption
● Challenge: Inaccurate query results that vary based on which node is queried.
Such issues are very hard to debug.
Data Inconsistency
● Synchronous replication
○ Ensures data is synchronized
across all nodes before it is
committed
○ Induces a performance overhead
● Load balancer
○ Ensure that all queries from a
specific application are sent to
the same node
○ Relies on eventual consistency of
the cluster
Data Inconsistency - Prevention
● Monitoring tools
○ Help with early identification of
possible issues so you can take
preventive measures
● Maintenance windows
○ Minimize data disruption with
planned downtime
● Regular testing
○ Test production use cases
regularly to ensure the cluster is
behaving as expected
Data Inconsistency - Resolution
● Resynchronization
○ Manual sync between nodes to correct data inconsistencies
● Rollback
○ Point-in-time recovery using tools like pg_rewind and pg_backrest
● Monitoring
○ Diligent monitoring to ensure that the issue doesn’t recur
This all sounds really hard
Open source clustering tools for PostgreSQL
● repmgr
○ https://repmgr.org/
○ GPL v3
○ Provides automatic failover
○ Manage and monitor replication
● pgpool-II
○ https://pgpool.net/
○ Similar to BSD & MIT
○ Middleware between PostgreSQL and client applications
○ Connection pooling, load balancing, caching, and automatic failover
● Patroni
○ https://patroni.readthedocs.io/en/latest/
○ MIT
○ Template for PostgreSQL high availability clusters
○ Automatic failover, configuration management, & cluster management
Questions?
pg_umair

More Related Content

What's hot

Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksJignesh Shah
 
Vacuum徹底解説
Vacuum徹底解説Vacuum徹底解説
Vacuum徹底解説
Masahiko Sawada
 
CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...
CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...
CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...
NTT DATA Technology & Innovation
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
Frederic Descamps
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
がっつりMongoDB事例紹介
がっつりMongoDB事例紹介がっつりMongoDB事例紹介
がっつりMongoDB事例紹介
Tetsutaro Watanabe
 
Vectors are the new JSON in PostgreSQL
Vectors are the new JSON in PostgreSQLVectors are the new JSON in PostgreSQL
Vectors are the new JSON in PostgreSQL
Jonathan Katz
 
TypeScript & 関数型講座 第2回 TypeScript という言語
TypeScript & 関数型講座 第2回 TypeScript という言語TypeScript & 関数型講座 第2回 TypeScript という言語
TypeScript & 関数型講座 第2回 TypeScript という言語
gypsygypsy
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
NeoClova
 
VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)
VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)
VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)
NTT DATA Technology & Innovation
 
さいきんの InnoDB Adaptive Flushing (仮)
さいきんの InnoDB Adaptive Flushing (仮)さいきんの InnoDB Adaptive Flushing (仮)
さいきんの InnoDB Adaptive Flushing (仮)
Takanori Sejima
 
Where狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキーWhere狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキー
yoku0825
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
Mydbops
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuningelliando dias
 
システム高速化フォーラム向け プッシュ通知基盤のアーキテクチャ
システム高速化フォーラム向け プッシュ通知基盤のアーキテクチャシステム高速化フォーラム向け プッシュ通知基盤のアーキテクチャ
システム高速化フォーラム向け プッシュ通知基盤のアーキテクチャ
Recruit Technologies
 
PostgreSQL HA
PostgreSQL   HAPostgreSQL   HA
PostgreSQL HA
haroonm
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyYusuke Yamamoto
 
PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)
PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)
PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)
NTT DATA Technology & Innovation
 
Apache Avro vs Protocol Buffers
Apache Avro vs Protocol BuffersApache Avro vs Protocol Buffers
Apache Avro vs Protocol Buffers
Seiya Mizuno
 
MySQL 5.7とレプリケーションにおける改良
MySQL 5.7とレプリケーションにおける改良MySQL 5.7とレプリケーションにおける改良
MySQL 5.7とレプリケーションにおける改良
Shinya Sugiyama
 

What's hot (20)

Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
 
Vacuum徹底解説
Vacuum徹底解説Vacuum徹底解説
Vacuum徹底解説
 
CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...
CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...
CloudNativePGを動かしてみた! ~PostgreSQL on Kubernetes~(第34回PostgreSQLアンカンファレンス@オンライ...
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
がっつりMongoDB事例紹介
がっつりMongoDB事例紹介がっつりMongoDB事例紹介
がっつりMongoDB事例紹介
 
Vectors are the new JSON in PostgreSQL
Vectors are the new JSON in PostgreSQLVectors are the new JSON in PostgreSQL
Vectors are the new JSON in PostgreSQL
 
TypeScript & 関数型講座 第2回 TypeScript という言語
TypeScript & 関数型講座 第2回 TypeScript という言語TypeScript & 関数型講座 第2回 TypeScript という言語
TypeScript & 関数型講座 第2回 TypeScript という言語
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)
VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)
VSCodeで作るPostgreSQL開発環境(第25回 PostgreSQLアンカンファレンス@オンライン 発表資料)
 
さいきんの InnoDB Adaptive Flushing (仮)
さいきんの InnoDB Adaptive Flushing (仮)さいきんの InnoDB Adaptive Flushing (仮)
さいきんの InnoDB Adaptive Flushing (仮)
 
Where狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキーWhere狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキー
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
 
システム高速化フォーラム向け プッシュ通知基盤のアーキテクチャ
システム高速化フォーラム向け プッシュ通知基盤のアーキテクチャシステム高速化フォーラム向け プッシュ通知基盤のアーキテクチャ
システム高速化フォーラム向け プッシュ通知基盤のアーキテクチャ
 
PostgreSQL HA
PostgreSQL   HAPostgreSQL   HA
PostgreSQL HA
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
 
PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)
PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)
PGOを用いたPostgreSQL on Kubernetes入門(PostgreSQL Conference Japan 2022 発表資料)
 
Apache Avro vs Protocol Buffers
Apache Avro vs Protocol BuffersApache Avro vs Protocol Buffers
Apache Avro vs Protocol Buffers
 
MySQL 5.7とレプリケーションにおける改良
MySQL 5.7とレプリケーションにおける改良MySQL 5.7とレプリケーションにおける改良
MySQL 5.7とレプリケーションにおける改良
 

Similar to 20230511 - PGConf Nepal - Clustering in PostgreSQL_ Because one database server is never enough (and neither is two).pdf

20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...
20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...
20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...
Umair Shahid
 
Clustering in PostgreSQL - Because one database server is never enough (and n...
Clustering in PostgreSQL - Because one database server is never enough (and n...Clustering in PostgreSQL - Because one database server is never enough (and n...
Clustering in PostgreSQL - Because one database server is never enough (and n...
Umair Shahid
 
Building real time Data Pipeline using Spark Streaming
Building real time Data Pipeline using Spark StreamingBuilding real time Data Pipeline using Spark Streaming
Building real time Data Pipeline using Spark Streaming
datamantra
 
OSMC 2019 | How to improve database Observability by Charles Judith
OSMC 2019 | How to improve database Observability by Charles JudithOSMC 2019 | How to improve database Observability by Charles Judith
OSMC 2019 | How to improve database Observability by Charles Judith
NETWAYS
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
Alexander Penev
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadKrivoy Rog IT Community
 
Big Data on Cloud Native Platform
Big Data on Cloud Native PlatformBig Data on Cloud Native Platform
Big Data on Cloud Native Platform
Sunil Govindan
 
Big Data on Cloud Native Platform
Big Data on Cloud Native PlatformBig Data on Cloud Native Platform
Big Data on Cloud Native Platform
Sunil Govindan
 
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflowsBeyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
DataWorks Summit
 
Distruted applications
Distruted applicationsDistruted applications
Distruted applications
Gabriele Santomaggio
 
Design patterns for scaling web applications
Design patterns for scaling web applicationsDesign patterns for scaling web applications
Design patterns for scaling web applications
Ivan Dimitrov
 
Lookout on Scaling Security to 100 Million Devices
Lookout on Scaling Security to 100 Million DevicesLookout on Scaling Security to 100 Million Devices
Lookout on Scaling Security to 100 Million Devices
ScyllaDB
 
Megastore by Google
Megastore by GoogleMegastore by Google
Megastore by Google
Ankita Kapratwar
 
Scalabe MySQL Infrastructure
Scalabe MySQL InfrastructureScalabe MySQL Infrastructure
Scalabe MySQL Infrastructure
Balazs Pocze
 
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & PythonCassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
DataStax Academy
 
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB AtlasMongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB
 
Our Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent CloudOur Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent Cloud
HostedbyConfluent
 
[@IndeedEng] Redundant Array of Inexpensive Datacenters
[@IndeedEng] Redundant Array of Inexpensive Datacenters[@IndeedEng] Redundant Array of Inexpensive Datacenters
[@IndeedEng] Redundant Array of Inexpensive Datacenters
indeedeng
 
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big DataVoxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens
 

Similar to 20230511 - PGConf Nepal - Clustering in PostgreSQL_ Because one database server is never enough (and neither is two).pdf (20)

20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...
20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...
20240515 - Chicago PUG - Clustering in PostgreSQL: Because one database serve...
 
Clustering in PostgreSQL - Because one database server is never enough (and n...
Clustering in PostgreSQL - Because one database server is never enough (and n...Clustering in PostgreSQL - Because one database server is never enough (and n...
Clustering in PostgreSQL - Because one database server is never enough (and n...
 
Building real time Data Pipeline using Spark Streaming
Building real time Data Pipeline using Spark StreamingBuilding real time Data Pipeline using Spark Streaming
Building real time Data Pipeline using Spark Streaming
 
OSMC 2019 | How to improve database Observability by Charles Judith
OSMC 2019 | How to improve database Observability by Charles JudithOSMC 2019 | How to improve database Observability by Charles Judith
OSMC 2019 | How to improve database Observability by Charles Judith
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
Big Data on Cloud Native Platform
Big Data on Cloud Native PlatformBig Data on Cloud Native Platform
Big Data on Cloud Native Platform
 
Big Data on Cloud Native Platform
Big Data on Cloud Native PlatformBig Data on Cloud Native Platform
Big Data on Cloud Native Platform
 
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflowsBeyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
 
Distruted applications
Distruted applicationsDistruted applications
Distruted applications
 
Design patterns for scaling web applications
Design patterns for scaling web applicationsDesign patterns for scaling web applications
Design patterns for scaling web applications
 
Lookout on Scaling Security to 100 Million Devices
Lookout on Scaling Security to 100 Million DevicesLookout on Scaling Security to 100 Million Devices
Lookout on Scaling Security to 100 Million Devices
 
Megastore by Google
Megastore by GoogleMegastore by Google
Megastore by Google
 
Performance Whackamole (short version)
Performance Whackamole (short version)Performance Whackamole (short version)
Performance Whackamole (short version)
 
Scalabe MySQL Infrastructure
Scalabe MySQL InfrastructureScalabe MySQL Infrastructure
Scalabe MySQL Infrastructure
 
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & PythonCassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
 
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB AtlasMongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
MongoDB World 2019: Packing Up Your Data and Moving to MongoDB Atlas
 
Our Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent CloudOur Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent Cloud
 
[@IndeedEng] Redundant Array of Inexpensive Datacenters
[@IndeedEng] Redundant Array of Inexpensive Datacenters[@IndeedEng] Redundant Array of Inexpensive Datacenters
[@IndeedEng] Redundant Array of Inexpensive Datacenters
 
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big DataVoxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
Voxxed Athens 2018 - Methods and Practices for Guaranteed Failure in Big Data
 

More from Umair Shahid

20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
Umair Shahid
 
20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...
20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...
20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...
Umair Shahid
 
Driving the future of PostgreSQL adoption
Driving the future of PostgreSQL adoptionDriving the future of PostgreSQL adoption
Driving the future of PostgreSQL adoption
Umair Shahid
 
Islamabad PUG - 7th Meetup - performance tuning
Islamabad PUG - 7th Meetup - performance tuningIslamabad PUG - 7th Meetup - performance tuning
Islamabad PUG - 7th Meetup - performance tuning
Umair Shahid
 
Islamabad PUG - 7th meetup - performance tuning
Islamabad PUG - 7th meetup - performance tuningIslamabad PUG - 7th meetup - performance tuning
Islamabad PUG - 7th meetup - performance tuning
Umair Shahid
 
Logical replication with pglogical
Logical replication with pglogicalLogical replication with pglogical
Logical replication with pglogical
Umair Shahid
 

More from Umair Shahid (6)

20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
 
20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...
20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...
20221019 - Singapore Roadshow - Open source licenses, the impact on PostgreSQ...
 
Driving the future of PostgreSQL adoption
Driving the future of PostgreSQL adoptionDriving the future of PostgreSQL adoption
Driving the future of PostgreSQL adoption
 
Islamabad PUG - 7th Meetup - performance tuning
Islamabad PUG - 7th Meetup - performance tuningIslamabad PUG - 7th Meetup - performance tuning
Islamabad PUG - 7th Meetup - performance tuning
 
Islamabad PUG - 7th meetup - performance tuning
Islamabad PUG - 7th meetup - performance tuningIslamabad PUG - 7th meetup - performance tuning
Islamabad PUG - 7th meetup - performance tuning
 
Logical replication with pglogical
Logical replication with pglogicalLogical replication with pglogical
Logical replication with pglogical
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

20230511 - PGConf Nepal - Clustering in PostgreSQL_ Because one database server is never enough (and neither is two).pdf

  • 1. Clustering in PostgreSQL Because one database server is never enough (and neither is two) PGConf Nepal May 11-12, 2023
  • 2. -[ RECORD 1 ]-------------------------------------------- name | Umair Shahid description | 20 year veteran of the PostgreSQL community company | Stormatics designation | Founder location | Islamabad, Pakistan family | Mom, Wife & 2 kids kid1 | Son, 16 year old kid2 | Daughter, 13 year old postgres=# select * from umair;
  • 3. PostgreSQL Solutions for the Enterprise Clustering & Analytics, backed by 24/7 Support and Professional Services
  • 4. 10 years of popularity As measured by PostgreSQL Oracle MySQL SQL Server https://db-engines.com/en/ranking_trend
  • 5. Loved by Developers 2022 Developer Survey Most Loved Most Used (Professional Developers) Most Wanted
  • 6. On to the topic now!
  • 7. What is High Availability? ● Remain operational even in the face of hardware or software failure ● Minimize downtime ● Essential for mission-critical applications that require 24/7 availability ● Measured in ‘Nines of Availability’
  • 8. Nines of Availability Availability Downtime per year 90% (one nine) 36.53 days 99% (two nines) 3.65 days 99.9% (three nines) 8.77 hours 99.99% (four nines) 52.60 minutes 99.999% (five nines) 5.26 minutes
  • 9. But my database resides in the cloud, and the cloud is always available Right?
  • 11. Amazon RDS Service Level Agreement Multi-AZ configurations for MySQL, MariaDB, Oracle, and PostgreSQL are covered by the Amazon RDS Service Level Agreement ("SLA"). The RDS SLA affirms that AWS will use commercially reasonable efforts to make Multi-AZ instances of Amazon RDS available with a Monthly Uptime Percentage of at least 99.95% during any monthly billing cycle. In the event Amazon RDS does not meet the Monthly Uptime Percentage commitment, affected customers will be eligible to receive a service credit.* 99.95% = three and a half nines = 4.38 hours of downtime per year!!! * https://aws.amazon.com/rds/ha/
  • 12. So - what do I do if I want better reliability for my mission-critical data? Clustering!
  • 13. ● Multiple database servers work together to provide redundancy ● Gives the appearance of a single database server ● Application communicates with the primary PostgreSQL instance ● Data is replicated to standby instances ● Auto failover in case the primary node goes down What is clustering? Primary Standby 1 Standby 2 Application Write Read Replicate
  • 14. What is auto failover? Primary Standby 1 Standby 2 Application Standby 1 Primary Standby 2 New Standby Application Primary Standby 1 Standby 2 Application 1 2 3 - Primary node goes down - Standby 1 gets promoted to Primary - Standby 2 becomes subscriber to Standby 1 - New Standby is added to the cluster - Application talks to the new Primary
  • 15. ● Write to the primary PostgreSQL instance and read from standbys ● Data redundancy through replication to two standbys ● Auto failover in case the primary node goes down Clusters with load balancing Primary Standby 1 Standby 2 Application Write Read Replicate
  • 16. ● Incremental backups ● Redundancy introduced from primary as well standbys ● RTO and RPO balance achieved per organizational requirements ● Point-in-time recovery Clusters with backups and disaster recovery Primary Standby 1 Standby 2 Application Write Read Replicate Incremental Backup Incremental Backup Incremental Backup Backup
  • 17. ● Shared-Everything architecture ● Load balancing for read as well as write operations ● Database redundancy to achieve high availability ● Asynchronous replication between nodes for better efficiency *with conflict resolution at the application layer Multi-node clusters with Active-Active configuration* Active 2 Application Write Read Replicate Active 1 Active 3
  • 18. ● Shared-Nothing architecture ● Automatic data sharding based on defined criteria ● Read and write operations are auto directed to the relevant node ● Each node can have its own standbys for high availability Node 2 Application Node 1 Node 3 Multi-node clusters with data sharding and horizontal scaling Coordinator Write Read
  • 19. Globally distributed clusters ● Spin up clusters on the public cloud, private cloud, on-prem, bare metal, VMs, or a hybrid of all the above ● Geo fencing for regulatory compliance ● High availability across data centers and geographies
  • 20. Replication - synchronous vs asynchronous Synchronous ● Data is transferred immediately ● Transaction waits for confirmation from replica before it commits ● Ensures data consistency across all nodes ● Performance overhead caused by latency ● Used where data accuracy is critical, even at the expense of performance Asynchronous ● Data may not be transferred immediately ● Transaction commits without waiting for confirmation from replica ● Data may be inconsistent across nodes ● Faster and more scalable ● Used where performance matters more than data accuracy
  • 21. Challenges in Clustering ● Split brain ● Network Latency ● False alarms ● Data inconsistency
  • 22. #AI
  • 23. ● Split brain ● Network Latency ● False alarms ● Data inconsistency Challenges in Clustering
  • 24. ● Defined: Node in a highly available cluster lose connectivity with each other but continue to function independently ● Challenge: More than one node believes that it is the primary leading to inconsistencies and possible data loss Split Brain
  • 25. ● Quorum based voting ○ Majority nodes must agree on primary ○ Cluster stops if quorum is not achieved ● Redundancy and failover ○ Prevents a single point of failure ● Proper configuration ● Split brain resolver ○ Software based detection & resolution ○ Can shut down nodes in case of scenario ● Network segmentation ○ Physical network separation ○ Avoid congestion Split Brain - Prevention
  • 26. Split Brain - Resolution ● Witness node ○ Third node that acts as a tie-breaker ○ The winner acts as primary, the loser is shut down ● Consensus algorithm ○ Paxos and Raft protocols are popular ● Manual resolution ○ DBA observes which nodes are competing to be the primary ○ Takes action based on best practices learnt from experience
  • 27. ● Split brain ● Network Latency ● False alarms ● Data inconsistency Challenges in Clustering
  • 28. ● Defined: Time delay when data is transmitted from one point to another ● Challenge: Delayed replication can result in data loss. Delayed signals can trigger a false positive. Network Latency
  • 29. ● Deploy nodes in proximity ○ Reduces time delay and network hops ● Implement quorum-based system ○ If quorum isn’t achieved failover won’t occur ● High speed, low latency networking ○ High quality hardware and associated software ● Optimize database configuration ○ Parameter tuning based on workloads ○ max_connections, tcp_keealive_idle, … ● Alerting system ○ Detect and alert admins of possible issues to preempt false positives Network Latency - Preventing False Positives
  • 30. ● Split brain ● Network Latency ● False alarms ● Data inconsistency Challenges in Clustering
  • 31. ● Defined: A problem is reported, but in reality, there is no issue ● Challenge: Can trigger a failover when one isn’t required, leading to unnecessary disruptions and impacting performance False Alarms
  • 32. False Alarms - Prevention ● Proper configuration ○ Best practices, past experience, and some hit & trial is required to ensure that the thresholds are configured appropriately ● Regular maintenance ○ Latest version of software and firmware to be used in order to avoid known bugs and exploits ● Regular testing ○ Testing of various use cases can help identify bottlenecks and possible misconfigurations ● Multiple monitoring tools ○ Multiple tools can help cross-reference alerts and confirm if failover is required
  • 33. False Alarms - Resolution In case a false alarm is triggered … ● Check logs ○ Check the logs of cluster nodes, network devices, and other infrastructure components to identify any anomalies ● Notify stakeholders ○ Notify all stakeholders involved in the cluster’s operations to prevent any unnecessary action ● Monitor cluster health ○ Monitor to cluster’s health closely to ensure that it is functioning correctly and no further false alarms are triggered
  • 34. ● Split brain ● Network Latency ● False alarms ● Data inconsistency Challenges in Clustering
  • 35. ● Defined: Situations where data in different nodes of a cluster becomes out of sync, leading to inconsistent results and potential data corruption ● Challenge: Inaccurate query results that vary based on which node is queried. Such issues are very hard to debug. Data Inconsistency
  • 36. ● Synchronous replication ○ Ensures data is synchronized across all nodes before it is committed ○ Induces a performance overhead ● Load balancer ○ Ensure that all queries from a specific application are sent to the same node ○ Relies on eventual consistency of the cluster Data Inconsistency - Prevention ● Monitoring tools ○ Help with early identification of possible issues so you can take preventive measures ● Maintenance windows ○ Minimize data disruption with planned downtime ● Regular testing ○ Test production use cases regularly to ensure the cluster is behaving as expected
  • 37. Data Inconsistency - Resolution ● Resynchronization ○ Manual sync between nodes to correct data inconsistencies ● Rollback ○ Point-in-time recovery using tools like pg_rewind and pg_backrest ● Monitoring ○ Diligent monitoring to ensure that the issue doesn’t recur
  • 38. This all sounds really hard
  • 39. Open source clustering tools for PostgreSQL ● repmgr ○ https://repmgr.org/ ○ GPL v3 ○ Provides automatic failover ○ Manage and monitor replication ● pgpool-II ○ https://pgpool.net/ ○ Similar to BSD & MIT ○ Middleware between PostgreSQL and client applications ○ Connection pooling, load balancing, caching, and automatic failover ● Patroni ○ https://patroni.readthedocs.io/en/latest/ ○ MIT ○ Template for PostgreSQL high availability clusters ○ Automatic failover, configuration management, & cluster management