Postmaster , Backend , Background 프로세스

2025. 6. 1. 08:48DB/Postgres

반응형

✅ 1.1 Postmaster 프로세스

Postmaster 프로세스는 PostgreSQL 인스턴스가 기동될 때 가장 먼저 시작되는 핵심 프로세스이다. 

  • 백그라운드 프로세스 및 Backend 프로세스 생성
  • 클라이언트 접속 대기
  • 클라이언트가 접속 요청 시 → Backend 프로세스 생성
  • 연결이 끊길 때까지 Backend 프로세스는 유지됨

▶ 관련 프로세스 예 

postgres  921     1  0 5320 01:47:18 /usr/lib/postgresql/14/bin/postgres -D /var/lib/postgresql/14/main -c config_file=/etc/postgresql/14/main/postgresql.conf
postgres 1022   921  0 5월20 00:02:25 postgres: 14/main: logger
postgres 1162   921  0 5월20 00:00:17 postgres: 14/main: checkpointer
postgres 1163   921  0 5월20 00:02:03 postgres: 14/main: background writer
postgres 1164   921  0 5월20 00:01:49 postgres: 14/main: walwriter
postgres 1165   921  0 5월20 00:32:26 postgres: 14/main: autovacuum launcher
postgres 1166   921  0 5월20 00:00:13 postgres: 14/main: archiver last was 00000001000000070000007B
postgres 1167   921  0 5월20 00:22:26 postgres: 14/main: stats collector
postgres 1168   921  0 5월20 00:00:07 postgres: 14/main: logical replication launcher

 


✅ 1.2 Backend 프로세스

Backend 프로세스는 클라이언트 접속 시 Postmaster가 생성하는 프로세스이다. 특징은 다음과 같다:

  • 클라이언트와 1:1 관계
  • SQL 쿼리 수행 및 결과 반환
  • max_connections 파라미터로 최대 동시 접속 수 조정 가능 (기본값: 100)

▶ Backend 프로세스가 사용하는 주요 메모리 파라미터

파라미터 설명

work_mem 정렬(ORDER BY), 그룹화(GROUP BY), DISTINCT, 조인 등 연산에 사용하는 메모리
maintenance_work_mem VACUUM, 인덱스 생성 작업 시 사용
temp_buffers 세션 단위로 임시 테이블 접근 시 사용
catalog_cache 스키마 내부 메타데이터 접근 시 사용

✅ 1.3 Background 프로세스

PostgreSQL의 운영 유지 및 관리는 다양한 Background 프로세스가 담당한다.

  • 일부는 상시 실행
  • 일부는 작업 완료 후 종료

▶ 필수 프로세스

이름 설명

Background writer Shared Buffer의 dirty 페이지를 디스크에 주기적으로 기록
Checkpointer 일정 간격마다 dirty 페이지 + 트랜잭션 로그를 디스크에 기록
WAL writer WAL (Write-Ahead Log)를 디스크에 기록

▶ 선택적 프로세스

이름 설명

Autovacuum launcher Autovacuum이 필요한 시점에 수행 및 관리
Statistics collector 세션 정보, 통계 수집 후 pg_catalog에 반영
Archiver WAL 파일이 가득 차면 다른 디스크나 스토리지에 백업
Logger 오류 메시지를 로그 파일에 기록

 

반응형