overview of postgres utility processes
DESCRIPTION
This technical presentation by EDB Dave Thomas, Systems Engineer provides an overview of: 1) BGWriter/Writer Process 2) Wall Writer Process 3) Stats Collector Process 4) Autovacuum Launch Process 5) Syslogger Process/Logger process 6) Archiver Process 7) WAL Send/Receive ProcessesTRANSCRIPT
© 2013 EnterpriseDB, Corp. All Rights Reserved. 1
Overview of Postgres Utilities Processes
Dave Thomas | 8.22.13
Techie Topic Series
© 2013 EnterpriseDB, Corp. All Rights Reserved. 2
• Overview – What are all these processes? • Logger Process • Checkpointer Process
• Writer Process • WAL Writer Process • Autovacuum Launcher Process
• Stats Collector Process • Streaming Replication Process • Resources
Presentation Agenda
© 2013 EnterpriseDB, Corp. All Rights Reserved. 3
What are all these processes?
• PostgreSQL utilizes separate processes instead of threads, which results in the above ps output for a freshly started cluster
• Each connection to the cluster will cause the postmaster to spawn a process which may look like the following:
• The above shows a connection from 127.0.0.1 to the test database by the user Postgres.
© 2013 EnterpriseDB, Corp. All Rights Reserved. 4
• Logging is an optional process, the default is OFF
• All the utility processes + user backends + postmaster daemon attach to the logger process
• All process information is logged under $PGDATA/pg_log in the file name specified by log_filename − If the data directory is created with INITDB command, then the pg_log
directory will need to be created manually. − You can also log to syslog and CSV formatted files
• Increasing the amount of logging will increase the I/O load on the server.
• http://www.enterprisedb.com/docs/en/9.2/pg/runtime-config-logging.html
Logger Process
© 2013 EnterpriseDB, Corp. All Rights Reserved. 5
• This process is responsible for flushing all dirty data pages to disk (called a checkpoint) − This process can cause a significant I/O load on the server.
• Checkpoints are performed every checkpoint_timeout seconds or when all checkpoint_segments are filled, whichever comes first.
• More frequent checkpoints will provide for faster after-crash recovery, but this must be balanced by the increased I/O load generated.
• http://www.enterprisedb.com/docs/en/9.2/pg/wal-configuration.html
Checkpointer Process
© 2013 EnterpriseDB, Corp. All Rights Reserved. 6
• Also known as BGWRITER process and is a mandatory process.
• Wakes every bgwriter_delay seconds and searches through the shared buffer pool looking for modified pages, writes them to disk, and evicts those pages from the shared buffer pool.
• No more than bgwriter_lru_maxpages buffers will be written by the background writer in a given pass.
• http://www.enterprisedb.com/docs/en/9.2/pg/runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-BACKGROUND-WRITER
Writer Process
© 2013 EnterpriseDB, Corp. All Rights Reserved. 7
• This is a mandatory process
• Writes and syncs Write Ahead Logs(WAL) to disk upon transaction commit
• WALs allow transactions to be recovered in the event of a system crash
• http://www.enterprisedb.com/docs/en/9.2/pg/wal-configuration.html
WAL Writer Process
© 2013 EnterpriseDB, Corp. All Rights Reserved. 8
• Autovacuuming is an optional process, default is ON.
• Automates the execution of VACUUM and ANALYZE commands
• A daemon which spawns autovacuum worker processes for each database − Starts one worker on each database (up to autovacuum_max_workers)
every autovacuum_naptime seconds − Worker processes check each table and index in a database and
executes VACUUM or ANALYZE as needed.
• http://www.enterprisedb.com/docs/en/9.2/pg/runtime-config-autovacuum.html
Autovacuum Launcher Process
© 2013 EnterpriseDB, Corp. All Rights Reserved. 9
• Stats collector process is an optional process, default is ON.
• Collects information about cluster activity. − Number of access to the tables and indexes − Total number of rows in each table − Information about VACUUM and ANALYZE actions for each table.
• Collection of statistics adds some overhead to query execution, but allows the query planner to make better choices.
• http://www.enterprisedb.com/docs/en/9.2/pg/monitoring-stats.html
Stats Collector Process
© 2013 EnterpriseDB, Corp. All Rights Reserved. 10
• WAL Sender
− This process sends WALs the standby server. − One process for each standby server.
• WAL Receiver
− This process receives WALs from the the primary server. − The WALs are then replayed to bring the standby in sync with the primary.
• http://www.enterprisedb.com/docs/en/9.2/pg/warm-standby.html#STREAMING-REPLICATION
Streaming Replication Processes
© 2013 EnterpriseDB, Corp. All Rights Reserved. 11
• Software Downloads & Documentation − EnterpriseDB > Products > Postgres Plus Advanced Server − EnterpriseDB > Products > Postgres Enterprise Manager − EnterpriseDB > Products > Documentation − EnterpriseDB > Products > Subscriptions
• Tutorials, Quick Starts, Webcasts, White Papers & Community − EnterpriseDB > Resources
• Email us! − [email protected] − [email protected] − [email protected]
Additional Resources- on EnterpriseDB.com
© 2013 EnterpriseDB, Corp. All Rights Reserved. 12