3 Mayıs 2023 Çarşamba

Process Architecture

Giriş
Şeklen şöyle

İki tane temel process var
1. Postmaster Process
2. Backend Process
3. Auxiliary Processes
Bunlar
- Background Writer (bw)
- Checkpointer (cp)
- Startup Process (st)
- Logger (lg)
- Autovacuum Launcher (avl)
- WAL writer (ww)
- WAL receiver (wr)
Other Processes
- Autovaccume workers
- WAL senders

Backend Process
Açıklaması şöyle
The postmaster process creates a new “backend” process for every connection it accepts. The connection is then handed over to the new backend process to perform the reading of the TCP stream, request parsing, SQL query parsing (yes those are different), planning, execution and returning the results. The process uses its local virtual memory for sorting and parsing logic, this memory is controlled by the work_mem parameter.

Connection Pooling
Açıklaması şöyle
.. the number of backend processes is capped by the number of connections, the max_connections parameter defaults to 100

Açıklaması şöyle
For each client on the server, its own servicing process is spawned. A large number of connections can cause problems:
  • Each process requires memory to store the cache of the system catalog, prepared queries, intermediate query results, and other data. The more connections that are open, the more memory needs to be available.
  • If connections are performed frequently and the sessions are short (i.e., the client executes one small query and disconnects), a prohibitive amount of resources will be spent on establishing connections, spawning new processes, and unnecessary filling of local caches.
  • The more processes that are running, the more time is required to scan their list, and this operation is performed very frequently. As a result, performance can decrease as the number of clients increases.
In such cases, connection pooling is used to limit the number of servicing processes. PostgreSQL does not have a built-in connection pool, so third-party solutions have to be used: pool managers built into the application server or external programs (such as PgBouncer or Odyssey).

Hiç yorum yok:

Yorum Gönder