Avneesh
Avneesh

Reputation: 355

Connection pools on AWS lambda

I have a lambda that is currently deployed on AWS. It is a simple piece of CRUD logic which sits behind a an API gateway.

The problem I am currently facing is that as soon as there is a peak in traffic the connections on my database shoot up.

I understand that this is due to the parallel invocation of many lambdas together, and opening their separate connections, but is there a way I can do some sort of connection pooling here?

The below thread states that I can(If I code a bit intelligently do some sort of a connection pool in a container):

How we can use JDBC connection pooling with AWS Lambda?

But it does not guarantee anything.

Can I do something about this in my lambda or do I have to use an external connection pooler for this(I use Postgres, so that should be pg_bouncer)?

Upvotes: 1

Views: 1680

Answers (1)

Dan
Dan

Reputation: 519

Yeah, no way round it. You need to use pgBouncer.

Upvotes: 1

Related Questions