https://kotlinlang.org logo
#http4k
Title
# http4k
m

Manas Marthi

11/07/2023, 11:06 AM
Is AWS Lambda supposed to use single connection per lambda?
j

James Richardson

11/07/2023, 1:06 PM
is this a question about http4k? - in general a connection pool of multiple connections doesn't make sense for a lambda (unless your code needs multiple simultaneous connections) - as there will only be a single request running through the runtime at any one time. if the lambda will have a long enough lifetime to service multiple connections, then a connection pool (of 1 connection) can make sense. of course there will be one connection to the back end db per concurrently-running lambda... hence RDS Proxy or pgbouncer or whatever.
a

Andrew O'Hara

11/07/2023, 6:56 PM
Http4k isn't an application framework, so it doesn't provide non-http integrations like SQL databases. I think people who are used to Spring tend to not really know how to integrate these things themselves, so if we want people to migrate, the least we can do is to help! I support James' answer, but here's some additional information. A single JDBC connection is usually enough for a Lambda, but if you know you need a connection pool per Lambda container, HikariCP is the defacto connection pool for JVM applications. You should look into its documentation for guidance. However, Amazon has a service called RDS Proxy that is specifically designed to pool connections for all your Lambda containers. I'm not an expert on it, but I believe it's incredibly useful even if your Lambdas only need a single connection, as it will make it faster for newly started lambdas to obtain their connection (someone can correct me if I'm wrong on this). Personally, I prefer connectionless databases for AWS Lambda, like DynamoDB.
👍 1
👍🏾 1
j

James Richardson

11/08/2023, 8:47 AM
Apologies - i wasn't trying to be unhelpful - i just wasn't sure the question was in the context of http4k, or just generally...
☮️ 2
m

Manas Marthi

11/12/2023, 2:01 PM
I asked about AWS lambda as I was trying the examples given. I am actually looking to find out how to package an app as a standalone AOT executable running on graal vm and deploy on a bare metal server "Http4k isn't an application framework, so it doesn't provide non-http integrations like SQL databases." This was not immediately clear to me when I read the documentation So how do I configure connection-pool? Do I need to use closures? I want to connect to PostgreSQL, Redis, RabbitMQ and keep the app sit behind a NGINX server
3 Views