Process Architecture:
Postgresql is a relational database management system with a multi-process architecture that runs on a single host. A PostgreSQL server consis__ts opf a parent process, backend processes to handle client queries, background processes for database management features, replication processes for streaming replication, and background worker processes for user-defined tasks.
- Postgres Server Process: When the pg_ctl utility is used with the start option, a postgres server process is started in PostgreSQL. It allocates a shared memory area in memory, starts various background processes, replication associated processes, and background worker processes if needed, and waits for connection requests from clients. Each connection request from a client results in the start of a backend process, which handles all queries issued by the connected client.
- Backend Processes: PostgreSQL's backend process handles queries from a single connected client, with the maximum number of clients determined by max_connections (default 100). However, frequent connections and disconnections can negatively impact performance as PostgreSQL lacks a native connection pooling feature. To address this, a pooling middleware like pgbouncer or pgpool-II is often used.
- Background Processes:* Background processes in PostgreSQL perform various tasks related to database management, running continuously to ensure the system's efficiency and smooth operation. These processes include autovacuum, checkpoint, writer, WAL sender and receiver, and archiver, among others. They are essential for maintaining the stability and reliability of PostgreSQL databases.
Memory Architecture:
Memory architecture in PostgreSQL can be classified into two broad categories: Local memory area and Shared memory area:
- Local Memory Area: In PostgreSQL, each backend process allocates a local memory area for processing queries. This memory area is divided into several sub-areas, with sizes that are either fixed or variable. The backend process uses these sub-areas to perform query processing like work_mem and temp_buffers.
- A shared memory area is allocated by a PostgreSQL server when it starts up. This area is also divided into several fix sized sub-areas like shared buffer pool and WAL buffer.
Top comments (0)