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
).
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.
There is also this: https://aws.amazon.com/rds/proxy/ A connection that can be shared by several lambda instances.
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.
I'll give RDS Proxy a spin! Looks like a helpful solution if I start seeing memory starvation on postgres.
Some discussion indicating that lambda may have 1-2 cpus available
https://gist.github.com/saidsef/882647c6589e868b81f0cced4041b132