Files
discord-spywatcher/docs/PGBOUNCER_SETUP.md
Copilot 9ef56ada2e Implement PgBouncer connection pooling with monitoring and graceful shutdown (#128)
* Initial plan

* feat: implement PgBouncer connection pooling and monitoring

- Add PgBouncer service with transaction mode pooling
- Configure optimal pool sizes (25 default, 100 max clients)
- Update docker-compose for dev and prod environments
- Enhance Prisma client with connection metrics
- Improve Redis connection lifecycle management
- Add comprehensive connection pool monitoring utilities
- Create monitoring endpoints for health checks and metrics
- Add graceful shutdown handlers for all services
- Update environment configuration with PgBouncer settings

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: add comprehensive documentation and tests for connection pooling

- Create comprehensive CONNECTION_POOLING.md documentation
- Add PgBouncer setup guide in docs/
- Create unit tests for connection pool monitoring
- Add integration tests for monitoring endpoints
- Update .gitignore for pgbouncer credentials

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: finalize connection pooling documentation and README updates

- Add comprehensive pgbouncer/README.md with usage guide
- Update main README with connection pooling section
- Add references to all relevant documentation
- Complete documentation checklist

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback on connection pooling

- Fix PgBouncer Dockerfile permissions by running entrypoint as root with su-exec
- Add PGPASSWORD to health check for proper authentication
- Fix isHealthy check to not treat 0% utilization as unhealthy
- Use proper URL parsing for isPgBouncer detection instead of string matching
- Remove duplicate SIGTERM/SIGINT handlers in redis.ts, coordinate through db.ts
- Add su-exec package for secure user switching in container

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-29 23:42:18 -05:00

728 B

PgBouncer Setup Guide

Quick reference guide for setting up and managing PgBouncer connection pooling.

🚀 Quick Start

See CONNECTION_POOLING.md for full documentation.

Development

docker-compose -f docker-compose.dev.yml up -d

Production

export DB_PASSWORD="your_secure_password"
docker-compose -f docker-compose.prod.yml up -d

📊 Monitoring

# System health
curl http://localhost:3001/api/admin/monitoring/connections/health

# Pool statistics  
curl http://localhost:3001/api/admin/monitoring/connections/pool

🔗 Resources