Database connection issues with 3-4k users
michaelmontero
PROOP

10 months 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 an estres test with k6 browser, i get this error with around 3-4k users calling 3 endpoint, 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.

Solved

2 Replies

michaelmontero
PROOP

10 months ago

guys, any update on this?


ray-chen
EMPLOYEE

10 months ago

You'll want to use an actual connection pooler like pgbouncer.


Status changed to Awaiting User Response Railway 10 months ago


Railway
BOT

6 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 6 months ago


Loading...