3 ms·
Could you expand on this? I’m trying to learn more about using Lambda as a serverless REST API recently and one of my projects has a SQL DB.
by rwol 9y ago
Could you expand on this? I’m trying to learn more about using Lambda as a serverless REST API recently and one of my projects has a SQL DB.
- drb91 9y agoI am not sure to what the op was referring, but I’d make sure to plex your connections through a configured connection pool to ensure the highly liquid lambda compute doesn’t suffocate the database.
- alexnewman 9y agoYea can i do 10k requests/second . The example was 80 connections per second. What happens when lambda has tens of thousands of workers?
- alexnewman 9y agoWhat happens if you get 1M requests. How many dB connections is this?
- bdcravens 9y agoWhat would you do in a traditional architecture?
- alexnewman 9y agopgpool
- rmrfrmrf 9y agoTraditionally, a web application creates a group of always-on reusable connections (a pool) to a database server since setting up the connection takes time and each connection uses up resources on the database server that could otherwise be used for computation. If there are more connections to your API that require the database than there are connections in the pool, those requests are queued and handled when the next connection is freed. These connections are then closed when the app shuts down. The problem on Lambda is that you can’t persist any application state beyond the function call itself, so you can’t take advantage of connection pooling the way you normally would in a self-contained webapp. Without some kind of middleman, each database call will require you to open a new connection to the database and close it when the function ends. This becomes catastrophic for the database server as the number of requests scales up.
- mrep 9y agoYes you can. You are supposed to instantiate those connections outside the function call as per the docs. Example: https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds-deployment-pkg.html https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds-deploym...
- alexnewman 9y agoTried and failed
- jdchernofsky 9y agohttp://blog.spotinst.com/2017/11/19/best-practices-serverless-connection-pooling-database/ http://blog.spotinst.com/2017/11/19/best-practices-serverles...