feat(database): add pgbouncer support and optimize postgres config by guilherme-aguilar · Pull Request #1700 · EvolutionAPI/evolution-api · GitHub
Skip to content

feat(database): add pgbouncer support and optimize postgres config#1700

Merged
DavidsonGomes merged 3 commits intoEvolutionAPI:developfrom
guilherme-aguilar:guilheme_aguilar/develop
Jul 14, 2025
Merged

feat(database): add pgbouncer support and optimize postgres config#1700
DavidsonGomes merged 3 commits intoEvolutionAPI:developfrom
guilherme-aguilar:guilheme_aguilar/develop

Conversation

@guilherme-aguilar
Copy link
Copy Markdown

@guilherme-aguilar guilherme-aguilar commented Jul 8, 2025

  • Add pgbouncer service to handle connection pooling
  • Update database connection URIs to support direct and pooled connections
  • Optimize postgres configuration with better memory settings
  • Update prisma schema to support directUrl connection

Summary by Sourcery

Add PgBouncer for connection pooling, support both pooled and direct PostgreSQL connections in Prisma, and optimize PostgreSQL memory settings

New Features:

  • Introduce a PgBouncer service in Docker Compose for transaction-level connection pooling
  • Support separate directUrl and pooled connection URIs in the Prisma schema

Enhancements:

  • Tune PostgreSQL configuration with reduced max_connections and adjusted memory parameters
  • Rename POSTGRES_DB environment variable to evolution_db in Docker Compose

- Add pgbouncer service to handle connection pooling
- Update database connection URIs to support direct and pooled connections
- Optimize postgres configuration with better memory settings
- Update prisma schema to support directUrl connection
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @guilherme-aguilar - I've reviewed your changes - here's some feedback:

  • Extract database credentials (user, password, and database name) into environment variables or a .env file instead of hard-coding them in docker-compose for better flexibility and security.
  • Add healthcheck definitions for both the postgres and pgbouncer services to ensure dependent services wait for the database to be fully ready before starting.
  • After updating the Prisma schema with the new directUrl, remember to regenerate the Prisma client and verify any related migrations are applied.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract database credentials (user, password, and database name) into environment variables or a .env file instead of hard-coding them in docker-compose for better flexibility and security.
- Add healthcheck definitions for both the postgres and pgbouncer services to ensure dependent services wait for the database to be fully ready before starting.
- After updating the Prisma schema with the new directUrl, remember to regenerate the Prisma client and verify any related migrations are applied.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

guilherme added 2 commits July 8, 2025 18:09
- Add new psql_bouncer database provider option
- Update database scripts to handle psql_bouncer provider
- Comment out pgbouncer service in docker-compose
- Simplify postgresql schema by removing directUrl
- Add new psql_bouncer-schema.prisma file
- Update .env.example with psql_bouncer configuration
- Modify runWithProvider.js to handle psql_bouncer migrations
@mzramna
Copy link
Copy Markdown

mzramna commented Jul 14, 2025

@DavidsonGomes DavidsonGomes changed the base branch from main to develop July 14, 2025 17:43
@DavidsonGomes DavidsonGomes merged commit 1966175 into EvolutionAPI:develop Jul 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants