We may earn an affiliate commission when you visit our partners.
Lucian Oprea

PostgreSQL is one of the most powerful and easy-to-use database management systems. It has strong support from the community and is being actively developed with a new release every year.

PostgreSQL supports the most advanced features included in SQL standards. It also provides NoSQL capabilities and very rich data types and extensions. All of this makes PostgreSQL a very attractive solution in software systems.

Read more

PostgreSQL is one of the most powerful and easy-to-use database management systems. It has strong support from the community and is being actively developed with a new release every year.

PostgreSQL supports the most advanced features included in SQL standards. It also provides NoSQL capabilities and very rich data types and extensions. All of this makes PostgreSQL a very attractive solution in software systems.

In this course, we discussed the problem of building scalable solutions based on PostgreSQL utilizing the resources of several servers. There is a natural limitation for such systems—basically, there is always a compromise between performance, reliability, and consistency. It's possible to improve one aspect, but others will suffer. In this course, we'll see how to find the best match for our use-cases so that we know eactly which aspects need scaling, and avoid the common trade-offs of distributed systems.

Scaling PostgreSQL is a journey. You should come out of this course more prepared to assess your scaling needs and understand how to scale reads and how to scale writes.

Each of this solution presented in this course will improve some aspect of the scalability topic, but each of them will add some complexity, and maybe some limitation or constraint.

We have to ask the right questions to get the system requirements, and this why we dedicated an entire lecture, so that we examine what questions we have to put ourself, before starting the Scaling Journey.

After this course, we should come out more prepared and understand how to scale reads.

We have several options for replication, depending on wether we favor performance or flexibility.

Replication can be used as a backup or a standby solution that would take over in case the main server crashes.

Replication can also be used to improve the performance of a software system by making it possible to distribute the load on several database servers.

Then, if we have one sort of replication in place, we could ask ourself if we want to allow several computers to serve the same data.

To achieve this, we should have a mechanism to distribute the requests. We’ll see here two of the most popular options available.

Next, if the number of database connections is great, then we’ll probably want to use a connection pooler. Again, we’ll cover two options here.

We’ll also see, how to scale writes, and how to make your traffic growth more predictable by adding queuing to your architecture.

Then, we’ll check partitioning for those cases when we have to deal with big tables.

Also, we’ll check sharding to scale writes, and all the complex decisions that come with it.

Finally, we’ll see shortly the multi-master solution, which is a relatively new concept that seems to be promising.

If our goal is to achieve only High availability, or the ability to continue working even in the situation where one part of the cluster fails, we can check out only those solutions.

The pre-requirements for HA is to put in place a replication strategy.

Then, we can use tools to allow a second server to take over quickly, if the primary server fails.

Introduction to Scaling PostgreSQL

  • Why scale PostgreSQL?

  • What is Vertical Scaling?

  • What is Horizontal Scaling?

  • Read Versus Write Bound Workloads

  • Why Statistics are essential?

  • How to enable and make us of Statistics? (Hands-on)

  • How to scale Postgres for Reads?

  • How replication helps to scale out?

  • What are the Load-Balancers?

  • How to scale Postgres for Writes?

  • How to make use of Queues?

  • How could Partitioning and Sharding help in scaling out?

  • What is the Multi-Master solution about?

Understanding the Limitations of Scaling out PostgreSQL

  • CAP Theorem Explained

  • PostgreSQL vs. Cassandra

  • Use case: CA Systems

  • Use case: AP Systems

How to use Streaming Replication?

  • What is Streaming Replication?

  • Asynchronous vs. Synchronous Replication

  • How to Initialise Primary Database? (Hands-on)

  • How to Configuring the Primary for Replication?  (Hands-on)

  • How to Configuring the Replica Instance?  (Hands-on)

  • Testing Replication Setup  (Hands-on)

How to use Logical Replication?

  • What is Logical Replication in Postgres?

  • Step by step Logical Replication setup

  • How to setup the servers for Logical Replication? (Hands-on)

  • How to make a selective Copy of the Data? (Hands-on)

  • How to Create the Publication? (Hands-on)

  • How to Create the Subscription? (Hands-on)

  • Postgres Limitations of Logical Replication

  • How to Monitoring Logical Replication? (Hands-on)

  • Best use-cases for using Logical Replication

How to make use of PgBouncer?

  • What is PgBouncer?

  • Fundamental concepts of connection pooling

  • How to build a PgBouncer Setup? (Hands-on)

  • How to install and configure PgBouncer? (Hands-on)

  • How to create a basic configuration file for PgBouncer? (Hands-on)

  • How to connect to PgBouncer? (Hands-on)

  • Explaining Advanced Settings for Performance

  • Which are the available Pool Modes?

  • Executing a benchmark with PgBouncer (Hands-on)

How to scale PostgreSQL in Google Cloud?

  • Introduction

  • Key Components on Google Cloud

  • Key Characteristics of the Architecture

  • How to create PostgreSQL Instances on Google Cloud?  (Hands-on)

  • How to create a Google Cloud Engine (GCE) for HAProxy? (Hands-on)

  • How to configure HAProxy for Load-Balancing? (Hands-on)

  • Testing Load-Balancing

How to make use of PostgreSQL Partitioning?

  • What is Partitioning?

  • Which Tables Need Partitioning?

  • How should the Tables be Partitioned? 

  • Declarative vs. Inheritance Partitioning

  • How to create a Partitioned Table? (Hands-on)

  • Partitioning Methods

How to Shard PostgreSQL?

  • What is Sharding?

  • Pain-Points of Sharding?

  • What is Second Level Sharding?

  • What is good Sharding?

  • How to query across multiple Shards?

How to setup High Availability (HA) on PostgreSQL?

  • Why High Availability?

  • Steps to achieve High Availability

  • Essential Questions to ask before setting-up High Availability

  • Log-Shipping Replication

  • Streaming Replication and Logical Replication

  • Cascading Replication

  • Synchronous vs. Asynchronous Replication

  • Automatic Failover and Always-on Strategy

  • Simple HA Solution Example

  • Better HA Solution Example

How to make use of PgPool II?

  • What is PgPool II?

  • Pgpool-II Features

  • How to Configure Pgpool-II with Streaming Replication? (Hands-on)

  • How to setup Streaming Replication? (Hands-on)

  • How to Configuring Pgpool-II for Load Balancing ? (Hands-on)

  • Testing load-balancing & read/write separation (Hands-on)

  • How to Configure Pgpool for PostgreSQL High-Availability? (Hands-on)

  • How to Configure PostgreSQL Primary Server? (Hands-on)

  • How to Configure Pgpool-II Server? (Hands-on)

  • How to Configure PostgreSQL Replica Server? (Hands-on)

  • Testing The Failover (Hands-on)

  • How to restore failed nodes? (Hands-on)

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Assess your scaling needs
  • How to scale reads using replication and load-balancing
  • Which is the best replication solution for a certain use case
  • How to manage database connections with pgbouncer connection pooler
  • How to make use of multiple postgresql instances in the cloud (google cloud)
  • How to achieve high-availability
  • How to perform automatic failover using pgpool ii
  • How to scale writes using partitioning and sharding

Syllabus

Scaling PostgreSQL
Why Scale PostgreSQL?
Quiz Why Scale PostgreSQL?
Vertical Scaling
Read more

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Explores replication, load balancing, and connection pooling, which are essential techniques for managing high-traffic databases
Covers partitioning and sharding, which are advanced strategies for scaling writes in PostgreSQL databases
Discusses the CAP theorem, which is a fundamental concept in distributed systems and helps in understanding trade-offs
Features hands-on labs using Google Cloud, which allows learners to implement and test scaling solutions in a cloud environment
Examines PgBouncer and PgPool II, which are tools that can improve database performance and availability
Requires familiarity with database administration concepts, which may be a barrier for beginners

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Reviews summary

Postgresql scaling, ha, and replication guide

According to learners, this course provides broad coverage of essential topics for scaling PostgreSQL, including various replication strategies, high availability concepts, and using tools like PgBouncer and PgPool II for connection pooling and load balancing. Students report that the course includes helpful hands-on exercises to practice setting up configurations. While the course covers advanced concepts like partitioning and sharding, some learners note that a solid background in PostgreSQL is beneficial or necessary to fully grasp the material. Overall, it is seen as a practical guide for implementing scalable and highly available PostgreSQL solutions.
Explains complex ideas like CAP Theorem
"The explanation of logical vs streaming replication was clear and concise."
"Found the sharding concepts challenging to grasp fully, could use more depth."
"CAP theorem was explained well in the context of database systems."
Covers practical tools like PgBouncer and PgPool II
"Learning about PgBouncer and PgPool II was directly applicable to my work."
"The coverage of specific tools needed for HA and load balancing was a highlight."
"Found the sections on connection poolers particularly useful."
Useful practical exercises included
"The hands-on examples were very helpful for setting up configurations and testing them."
"Liked trying out the different replication and pooling setups myself."
"Putting theory into practice with the labs solidified my understanding."
Comprehensive overview of scaling and HA options
"I appreciated the wide range of scaling topics covered, from replication to sharding."
"The course provides a comprehensive overview of different methods to scale and ensure high availability."
"Good breadth across replication, pooling, sharding, and related concepts."
Best suited for those with some Postgres knowledge
"This course is definitely not for beginners; you need prior PostgreSQL experience."
"Assumes a solid understanding of basic database administration."
"Might be challenging if you don't have existing familiarity with advanced database concepts."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in PostgreSQL Replication, High Availability HA and Scalability with these activities:
Review Database Concepts
Reinforce your understanding of fundamental database concepts like normalization, indexing, and transactions to better grasp PostgreSQL's replication and scaling mechanisms.
Browse courses on Database Concepts
Show steps
  • Review database normalization principles.
  • Study different types of database indexes.
  • Understand ACID properties of transactions.
Read 'PostgreSQL Administration Cookbook'
Supplement your knowledge with practical recipes for managing and maintaining PostgreSQL deployments.
Show steps
  • Obtain a copy of 'PostgreSQL Administration Cookbook'.
  • Review the recipes related to replication and high availability.
  • Experiment with the code examples in your own environment.
Read 'PostgreSQL High Availability'
Deepen your understanding of high availability concepts and practical implementation details by reading a dedicated book on the subject.
Show steps
  • Obtain a copy of 'PostgreSQL High Availability'.
  • Read the chapters on replication and failover.
  • Experiment with the configurations described in the book.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Replication Lag Monitoring
Master the art of monitoring replication lag to ensure data consistency and identify potential issues in your PostgreSQL cluster.
Show steps
  • Learn how to query replication lag using pg_stat_replication.
  • Set up alerts to notify you when replication lag exceeds a threshold.
  • Practice troubleshooting replication lag issues.
Set up a PostgreSQL Cluster
Solidify your knowledge by building a real-world PostgreSQL cluster with replication and failover capabilities.
Show steps
  • Provision multiple PostgreSQL instances on virtual machines or cloud services.
  • Configure streaming replication between the instances.
  • Implement automatic failover using tools like Pacemaker or Patroni.
  • Test the cluster's resilience by simulating failures.
Document Your Cluster Setup
Improve your understanding and share your knowledge by documenting the steps you took to set up your PostgreSQL cluster.
Show steps
  • Describe the architecture of your cluster.
  • Document the configuration settings for each instance.
  • Explain the failover process and how to test it.
  • Publish your documentation on a blog or wiki.
Contribute to PostgreSQL Documentation
Deepen your understanding and give back to the community by contributing to the PostgreSQL documentation.
Show steps
  • Identify areas in the documentation that need improvement.
  • Submit patches to fix errors or add new information.
  • Review patches submitted by other contributors.

Career center

Learners who complete PostgreSQL Replication, High Availability HA and Scalability will develop knowledge and skills that may be useful to these careers:
Database Administrator
A database administrator is responsible for the performance, integrity, and security of a database. This role requires a deep understanding of database systems, including replication, high availability, and scalability – all topics covered in this course. This course can help a database administrator understand how to scale PostgreSQL databases using various techniques such as replication, load balancing, and connection pooling. In addition, the course explores high availability solutions, which is critical for minimizing database downtime. A database administrator who understands the material in this course can effectively implement and manage a scalable and reliable PostgreSQL database system.
Data Architect
A data architect designs and manages the data infrastructure, including databases, data warehouses, and data lakes. This course is useful for a data architect by providing a foundation for designing scalable database solutions using PostgreSQL. A data architect often guides how databases are configured and structured, making understanding replication, partitioning and sharding very useful. Understanding how to scale reads and writes using the techniques covered in this course significantly aids a data architect in building reliable and performant data systems. Further topics such as high availability solutions and connection pooling are critical for designing robust systems.
Site Reliability Engineer
A site reliability engineer focuses on the reliability and performance of software systems, including the databases that support them. This course will be helpful for a site reliability engineer by offering practical knowledge on scaling PostgreSQL solutions, especially through replication, load balancing, and connection pooling. A site reliability engineer also benefits from the coverage of high availability (HA) and automatic failover strategies, enabling them to build resilient database infrastructure. The course's exploration of partitioning and sharding provides valuable insights into scaling writes, which is crucial for maintaining application performance and uptime.
Cloud Database Engineer
A cloud database engineer specializes in managing databases in cloud environments. This course directly addresses crucial aspects of this role: how to manage PostgreSQL in the cloud, specifically on the Google Cloud Platform. This course covers scaling strategies such as replication and load balancing, which are essential skills for operating databases in a cloud environment. The course also covers high availability solutions, and how to use connection poolers to manage database connections, which will be useful for a cloud database engineer managing systems on a cloud platform. A cloud database engineer who understands these concepts can ensure optimal performance and reliability in a cloud-based infrastructure.
Backend Engineer
A backend engineer builds the server-side logic of applications, often working directly with databases. This course will be helpful for a backend engineer since it provides a deep dive into optimizing PostgreSQL databases, especially focusing on scalability. This course provides insights into scaling reads using replication and load balancing, and how to manage connections effectively. A backend engineer who is familiar with the topics covered here can design and implement systems that can handle heavy loads and ensure the application's overall performance. Also, high availability techniques taught in the course will ensure that the database is resilient.
Data Engineer
A data engineer builds and maintains the data pipelines that feed data to various parts of an organization. This course will be useful for a data engineer as it covers scaling techniques that are crucial for handling large volumes of data in PostgreSQL. This course offers practical knowledge of replication, partitioning, and sharding, all necessary for building high-throughput data systems. The course's focus on high availability and load balancing are also critical for a data engineer to reliably manage data ingestion and processing. A data engineer who understands the topics covered in this course will have a strong foundation for building robust data pipelines.
Systems Engineer
A systems engineer designs and manages the overall IT infrastructure of an organization. This course may be useful a systems engineer given its focus on database scalability and high availability in PostgreSQL. This course discusses how to scale reads and writes, which are essential components for designing robust systems. Systems engineers will find the course materials on high availability and failover techniques especially useful as they build reliable solutions. The course also covers practical tools and techniques useful for managing databases, which systems engineers should find very useful for optimizing overall system performance.
Solutions Architect
A solutions architect designs and oversees the implementation of complex technical solutions, including database architectures. This course may be helpful for a solutions architect as it provides an understanding of how to build scalable and reliable PostgreSQL solutions. The content of the course covers replication, load balancing, and connection pooling, all critical for designing performant systems. Understanding aspects such as high availability and automated failover strategies, as taught by this course, helps a solutions architect create more resilient and robust architectures. The course also introduces sharding and partitioning, which are important concepts to consider when dealing with very large datasets.
Database Reliability Engineer
A database reliability engineer ensures the reliability and performance of database systems. This role focuses on optimizing database infrastructure for maximum uptime and efficiency. This course may be useful to a database reliability engineer since it offers critical knowledge on scaling PostgreSQL databases using replication, load balancing, and connection pooling. This course covers strategies for high availability and automatic failover, essential for a database reliability engineer's work. Understanding the core concepts covered here will empower a database reliability engineer to design, implement, and operate highly reliable database systems.
Technical Lead
A technical lead guides technical teams, making critical decisions about the architecture and implementation of software systems. This course may be useful for a technical lead as it provides a deeper understanding of PostgreSQL scalability, which is crucial for making informed choices about database architecture. This course gives a basis for discussing and understanding performance optimization techniques. The course also offers insights into high availability and automatic failover strategies, which guides a technical lead in designing reliable systems. Understanding the material covered in this course will allow a technical lead to help their team make better decisions in their work.
Software Architect
A software architect designs the high-level structure of software applications, often making decisions about databases. This course may be useful for a software architect by offering detailed knowledge of PostgreSQL scalability and high availability. This course covers various methods of scaling reads and writes, which are crucial for designing performant software. A software architect gains knowledge of replication, partitioning and sharding, which help them make better decisions when building complex application systems. The content here, specifically around high availability and failover, can help ensure that the application is reliable.
System Administrator
A system administrator manages and maintains computer systems, including databases. This course may be useful for a system administrator looking to specialize in database administration, by offering practical knowledge on PostgreSQL scalability and high availability. This course provides insights into scaling reads and writes using replication and load balancing. The course also includes knowledge on connection pooling which should be helpful for efficiently managing database connections. The coverage of high availability and failover strategies is very useful for a system administrator wanting to manage databases.
DevOps Engineer
A DevOps engineer works to streamline software development and deployment processes. This role benefits from understanding database infrastructure, making this course potentially useful. This course offers practical insights on scaling PostgreSQL using replication, load balancing, and connection pooling, which are valuable for managing database deployments. DevOps engineers should be familiar with how to manage the systems they deploy, making the high availability solutions taught in the course very useful. The course's coverage of partitioning and sharding also helps ensure a DevOps engineer who understands the course material can implement highly efficient systems.
IT Consultant
An IT consultant advises organizations on technology solutions, including database systems. This course might be useful to an IT consultant, providing them with an understanding of PostgreSQL scaling and high availability. The consultant will be able to offer advice after understanding how to scale reads and writes using the techniques discussed in this course. IT consultants can utilize the concepts around replication, load balancing, and connection pooling to propose better database architectures to their clients. The high availability and failover strategies discussed in this course might be useful for a consultant suggesting more robust IT infrastructures.
Database Analyst
A database analyst focuses on analyzing data stored in databases, often working with database administrators. This course may be useful to a database analyst as it provides them with a better understanding of how databases are structured and optimized for performance. Understanding replication, connection pooling, and sharding can help a database analyst have a better idea of how the database is configured. This allows for more efficient access to data. The course also covers topics like high availability which is important for making sure that data is always accessible for analysis. All of this makes the analyst more productive. While this job focuses on the data, the topics in this course are still relevant.

Reading list

We've selected one books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in PostgreSQL Replication, High Availability HA and Scalability.
Provides a comprehensive guide to setting up and managing high availability PostgreSQL clusters. It covers various replication methods, failover strategies, and monitoring techniques. It valuable resource for understanding the practical aspects of building robust and resilient PostgreSQL deployments. This book expands on the HA concepts introduced in the course.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser