Workarounds for scaling lambda functions

The following are the best practices while building out a Lambda function that scales well:

  • Avoid cold starts by leveraging the freeze and thaw cycle of Lambda.
  • Declare reusable variables outside of the handler function. We have seen this in the previous exercise, where we initialized the database connection. RDBMS connection-establishment is an expensive activity; connection pooling is a way to shave some cost off it. Freezing and Thawing RDBMS connections is a way of doing connection pooling in Lambda. Please bear in mind that this might lead to database connections being swamped if the number of warm executions equals the number of database connections available. So, there has to be a way of keeping ...

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.