Scalability

This final chapter of the book will be dedicated to the problem of scalability. This term means the ability of a software system to grow with the growth of the business using it. PostgreSQL does provide some features that help building a scalable solution but, strictly speaking, PostgreSQL itself is not scalable. It can effectively utilize the resources of a single machine:

  • It uses multiple CPU cores to perform a single query faster with parallel query
  • When configured properly, it can use all available memory for caching
  • The size of the database is not limited by PostgreSQL; supporting multiple tablespaces, it can use several hard disks and with partitioning, it can do this quickly and transparently to the users

However, when it comes to spreading a database solution to multiple machines, it can be quite problematic because a standard PostgreSQL server can only run on a single machine. That's why in this chapter, we will talk not only about PostgreSQL itself, but rather about where to go next.

Particularly, the following topics will be covered:

  • The problem of scalability and the CAP theorem
  • Data replication in PostgreSQL, including physical replication and logical replication
  • Different scaling scenarios and their implementation in PostgreSQL

This topic is very large and itself deserves a dedicated book. That's why we will not describe too much about the practical recipes, but rather discuss the concepts so that you can get an understanding of possible options and then learn particular topics yourself.

We can recommend other books offered by Packt Publishing on this topic:

  • PostgreSQL Replication - Second Edition by Hans-Jürgen Schönig, explaining very well how PostgreSQL replication features work internally and providing a lot of practical examples of how to use them.
  • PostgreSQL High Availability Cookbook - Second Edition by Shaun M. Thomas, providing comprehensive hand-on recipes of how to build highly available database solutions based on PostgreSQL using its replication capabilities.

The examples for the chapter require setting up multiple database instances. That's why for this chapter, we are using Docker compositions to set up and implement sample scenarios. If you are not familiar with Docker, refer to the documentation at https://docs.docker.com/get-started/. To run the examples, you will need to install docker engine and docker-compose.

The examples are also based on the car_portal database that we have used in the whole book. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset