Database connection issues with 3-4k users
michaelmontero
PROOP

a year ago

I have two apps connected to the Postgres database, each with a connection pool size of 20.

const db: any = {

type: 'postgres',

url: DATABASE_URL,

entities: [${__dirname}/entity/*.entity{.ts,.js}],

migrations: [${__dirname}/migrations/*{.ts,.js}],

logging: 'all',

extra: {

max: 20,

min: 5,

idleTimeoutMillis: 30000,

connectionTimeoutMillis: 10000

}

};

But running a stress test with k6 browser, I get this error with around 3-4k users calling 3 endpoints, 1 of them being cache 95% of the time:

Timeout exceeded when trying to connect [

Apr 06 23:23:03

'Error: timeout exceeded when trying to connect\n' +

Apr 06 23:23:03

' at Timeout._onTimeout (/app/node_modules/pg-pool/index.js:205:27)\n' +

Apr 06 23:23:03

' at listOnTimeout (node:internal/timers:594:17)\n' +

Apr 06 23:23:03

' at process.processTimers (node:internal/timers:529:7)',

Apr 06 23:23:03

'ExceptionsHandler'

Apr 06 23:23:03

]

Apr 06 23:23:03

2025-04-07T03:22:55.583Z [error] - timeout exceeded when trying to connect

That makes the API and database unresponsive.

1 Replies

michaelmontero
PROOP

a year ago

Project ID: fa2cdbda-509c-443f-83f3-72e7a3375764


Welcome!

Sign in to your Railway account to join the conversation.

Loading...