Better distribute db connection pool amongst workers
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { CreateTableBuilder, Kysely, PostgresDialect, sql } from 'kysely';
|
||||
import { type DB } from "./out/db";
|
||||
import { Pool } from "pg";
|
||||
import { env } from '../util';
|
||||
import { env, WORKER_COUNT } from '../util';
|
||||
|
||||
export const db = new Kysely<DB>({
|
||||
dialect: new PostgresDialect({
|
||||
pool: new Pool({
|
||||
connectionString: env.DATABASE_URL,
|
||||
max: Math.max(1, Math.floor(+env.DATABASE_POOL_MAX / WORKER_COUNT))
|
||||
}),
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user