Introduces PgBouncer as a connection pooler between the API service and PostgreSQL in docker-compose.prod.yml, reducing connection overhead and improving concurrency under production load. - Add PgBouncer service (edoburu/pgbouncer:1.23.1-p2) with transaction pool mode, max_client_conn=200, default_pool_size=20 - Route API DATABASE_URL through PgBouncer (port 6432), keep direct connection (DATABASE_URL_DIRECT) for Prisma migrations/introspection - Create infra/pgbouncer/ config: pgbouncer.ini, userlist template, and entrypoint script with runtime env-var substitution - Update prisma.config.ts to prefer DATABASE_URL_DIRECT for migrations - Add K6 load test (e2e/load/pgbouncer-pool-test.js) with ramp-up to 200 VUs, pool exhaustion detection, and p95 < 2s threshold - Add PgBouncer env vars to .env.example Co-Authored-By: Paperclip <noreply@paperclip.ing>
17 lines
498 B
TypeScript
17 lines
498 B
TypeScript
import path from 'node:path';
|
|
import { defineConfig } from 'prisma/config';
|
|
|
|
export default defineConfig({
|
|
earlyAccess: true,
|
|
schema: path.join(__dirname, 'schema.prisma'),
|
|
migrate: {
|
|
async development() {
|
|
// Use DATABASE_URL_DIRECT (bypasses PgBouncer) for migrations/introspection
|
|
// when available; fall back to DATABASE_URL for local dev without PgBouncer.
|
|
return {
|
|
url: process.env.DATABASE_URL_DIRECT || process.env.DATABASE_URL!,
|
|
};
|
|
},
|
|
},
|
|
});
|