📌 GitHub Issue
제목
[FIX] Postgres 커넥션 풀 수정으로 트래픽 과부하 대응
🐞 문제 상황
로드밸런싱(haproxy-nginx)과 트래픽 과부하 상황에서
Postgres 컨테이너가 커넥션 부족으로 다운되는 현상이 발생.
🔄 원인
- 기본 Postgres 설정의
max_connections 값이 낮아
Swarm 환경에서 다중 요청 처리 시 커넥션 풀 부족 발생
- HAProxy-Nginx ↔ Swarm 서비스 간 네트워크 통신 부하로 DB 연결 불안정
✅ 해결 방법
- Postgres 컨테이너 실행 시
max_connections=150 옵션 추가
command: postgres -c max_connections=150
- Swarm overlay 네트워크를 attachable 옵션으로 생성
docker network create --driver overlay --attachable ecommerce
- Compose 컨테이너(Nginx)와 Swarm 서비스(Spring Boot)를 동일한
ecommerce 네트워크에 연결
⚙️ 환경 정보
- Docker Engine: 24.x
- Swarm 모드 활성화
- Compose v2.x
- OS: Ubuntu 22.04
📸 참고 로그
FATAL: remaining connection slots are reserved for non-replication superuser connections
Error response from daemon: Could not attach to network ecommerce: rpc error: code = PermissionDenied desc = network ecommerce not manually attachable
📌 GitHub Issue
제목
[FIX] Postgres 커넥션 풀 수정으로 트래픽 과부하 대응
🐞 문제 상황
로드밸런싱(haproxy-nginx)과 트래픽 과부하 상황에서
Postgres 컨테이너가 커넥션 부족으로 다운되는 현상이 발생.
🔄 원인
max_connections값이 낮아Swarm 환경에서 다중 요청 처리 시 커넥션 풀 부족 발생
✅ 해결 방법
max_connections=150옵션 추가ecommerce네트워크에 연결⚙️ 환경 정보
📸 참고 로그