PostgreSQL is a free open-source relational database management system. Some even consider it the most advanced open source database system. This management system has earned a strong reputation for its proven architecture, reliability, data integrity, robust feature set, extensibility, and the dedication of the open source community behind the software to consistently deliver performant and innovative solutions.
PostgreSQL runs on all operating systems and is ACID compliant. It is designed to handle a range of workloads, from single machines to data warehouses and web services with a high number of simultaneous users. It supports text, images, sounds, and video, and includes programming interfaces for C / C++, Java, Perl, Python, Ruby, Tcl and Open Database Connectivity (ODBC).
PostgreSQL is highly extensible because its operation is catalog-driven and stores much more information in its catalogs: not only information about tables and columns, but also information about data types, functions and access methods. The system allows the user to define custom data types, build out custom functions and even write code from different programming languages.
PostgreSQL Architecture –PostgreSQL architecture uses a simple “process per-user” client/server model. This consists of the following cooperating processes (programs):
- A server process, which manages the database files, accepts connections to the database from client applications, and performs database actions on behalf of the clients. The database server program is called postgres.
- The user’s client (frontend) application performs database operations. The client (“psql” or “web-server driver”) makes a call through the psql libraries to an established TCP/IP port (5432 default), to a database from the database system. Client applications can be very diverse: a client could be a text-oriented tool, a graphical application, a web server that accesses the database to display web pages, or a specialized database maintenance tool.
A single postmaster (process which manages every incoming connection to the database system) manages a given collection of databases on a single host. This collection of databases is called a cluster. A frontend application that wishes to access a given database within a cluster makes calls to an interface library that is linked into the application.
The library sends user requests over the network to the postmaster which in turn starts a new backend server process and connects the frontend process to the new server. the frontend process and the backend server communicate without intervention by the postmaster. The postmaster is always running, waiting for connection requests, and the frontend and backend processes come and go.
High Availability and Cluster Solutions:
REPMGR (Replication Manager) is an open-source tool for managing replication and failover in a cluster of PostgreSQL servers. It enhances PostgreSQL’s built-in hot-standby capabilities with tools to setup and promote standby servers, monitor replication, and configure, manage, and monitor replication of PostgreSQL. It also enables you to perform manual switchover and monitor the status of your PostgreSQL cluster. REPMGR has a command-line interface utility which enables you to perform various administrative tasks such as failover or manual switchover operations.
It is the most popular tool for PostgreSQL replication and failover management. Repmgr simplifies administration and daily management, enhances productivity and complements built-in replication capabilities in PostgreSQL and also has capabilities for setting up the standby servers for replication. Replication Manager makes use of the PostgreSQL extensions feature and creates its own schema on the cluster database to store the cluster-related information.
PGPOOL-II is a middleware that works between PostgreSQL servers and a PostgreSQL database proxy. Pgpool-II maintains established connections to the PostgreSQL servers, and reuses them whenever a new connection with the same properties comes in. It is a PostgreSQL cluster that uses native streaming replication. Its main features include connection pooling, load balancing, replication, and limiting exceeding connections.
PgPool-II operates in two modes: Single-Node and Cluster Mode. In Pgpool-II cluster mode, only one node will be accepting connections at a time (the master node). The watchdog of each node will perform heartbeat checking to the master node. In case of failure to detect the master node, the slave/standby node assumes the master is down and takes over the master role.
In order to take over the role of the master node, each node must first be assigned two scripts: escalation and de-escalation script. Escalation script is run when promotion to master is being initiated. De-escalation script is run when the node is being shutdown or restarted.
Pgpool-II can manage multiple PostgreSQL servers. Activating the replication feature makes it possible to create a real time backup on two or more PostgreSQL clusters, so that the service can continue without interruption if one of those clusters fails.