Fork me on GitHub
#sql
<
2020-11-20
>
frankitox17:11:11

I'm looking to hook up AWS Lambdas with postgres, and I was wondering if it makes any sense to use connection pooling (e.g: hikariCP) in this context? Lambda has only one thread, so I don't see how having more than one connection can make a difference. The best approach I can think of now is just having one connection open for the duration of the Lambda (with jdbc/get-connection).

jsyrjala17:11:20

Lambdas can have several threads. So connection pooling might be useful in some cases. But in most cases having a single thread with a single connection is probably good enough.

jsyrjala17:11:01

There is also this: https://aws.amazon.com/rds/proxy/ A connection that can be shared by several lambda instances.

frankitox18:11:26

Thanks for the confirmation! Oh, what I meant is CPUs, not threads. Running code in parallel. I read somewhere that CPU usage is bound to the amount of memory you assign to the lambda, but I don't know about the specifics. Like, maybe you get 2 CPUs if you set 2GB+ of RAM, or something like that.

frankitox18:11:07

I'll give RDS Proxy a spin! Looks like a helpful solution if I start seeing memory starvation on postgres.

jsyrjala20:11:51

Some discussion indicating that lambda may have 1-2 cpus available