Skip to content

Commit b1addb1

Browse files
committed
Increase database connection pool size to 20
The postgres.js default pool size is 10, which equals the concurrency of ParallelMessageQueue. Under federation load, all 10 workers can simultaneously hold or wait for database connections, leaving none available for HTTP handlers and KV store queries. This causes the server to stop responding to API requests while still answering OPTIONS (CORS preflight) requests, which need no database access. Increasing the pool size to 20 provides enough headroom for the 10 queue workers plus concurrent HTTP handlers and KV store operations. #388
1 parent db1b361 commit b1addb1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/db.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const databaseUrl = process.env["DATABASE_URL"];
1313
if (databaseUrl == null) throw new Error("DATABASE_URL must be defined");
1414

1515
export const postgres = createPostgres(databaseUrl, {
16+
// The pool size needs to exceed the ParallelMessageQueue concurrency (10)
17+
// to leave headroom for HTTP handlers and KV store queries. The default
18+
// of 10 can cause connection starvation under federation load.
19+
max: 20,
1620
connect_timeout: 5,
1721
connection: { IntervalStyle: "iso_8601" },
1822
});

0 commit comments

Comments
 (0)