Created
October 20, 2025 03:07
-
-
Save yogithesymbian/3e4a0d2628a9f0c2e0a07850b7c4b572 to your computer and use it in GitHub Desktop.
Menghindari bottleneck dari ribuan koneksi langsung ke Postgres.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [databases] | |
| explorer = host=localhost port=5432 dbname=explorer | |
| [pgbouncer] | |
| listen_port = 6432 | |
| listen_addr = 0.0.0.0 | |
| auth_type = md5 | |
| pool_mode = transaction | |
| max_client_conn = 1000 | |
| default_pool_size = 100 |
Author
Author
before
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
export const db = drizzle(pool);after
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL ?? 'postgres://user:pass@localhost:6432/explorer',
// Optional: tambahkan idleTimeoutMillis, max, dll
});
export const db = drizzle(pool);
Author
localhost:5432
Author
localhost:6432
Author
jalankan salah satu query / migrate
bun run migratemonitoring koneksi di PgBouncer:
SHOW POOLS;
SHOW STATS;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
change connection into
instead of
test