#lambda
3 posts

Cold start/warm start with AWS Lambda

Programming language can impact the duration of a cold start in Lambda: Java and C# are typically slower to initialize than Go, Python or Node but they perform better on warm calls.
Read more

Cold start/warm start with AWS Lambda

  • Programming language can impact the duration of a cold start in Lambda: Java and C# are typically slower to initialize than Go, Python or Node but they perform better on warm calls.
  • Adding a framework to structure the code deployed in Lambda increases execution time with cold calls, which can be minimized by using a serverless-oriented framework as opposed to a web framework. Typically, frameworks don’t impact warm calls.
  • In serverless applications, one way to avoid cold starts is to keep Lambda warm beyond its fixed 5-minute life by preventing it from being unloaded. You can do this by setting up a cron to invoke Lambda at regular intervals. However, AWS Lambda will still reset every 4 hours and autoscaling must be taken into account.
  • To avoid cold starts in case of concurrent calls from automatic autoscaling, make pools of Lambda instances kept warm as above; but you will need to determine an optimal number to avoid wasting resources.

Full post here, 11 mins read

5 tips for building apps with the Serverless framework and AWS Lambda

Serverless works well with a microservice-style architecture. You should limit the scope of services and functions you use. Lambda functions shouldn’t persist any data or session information in the environment beyond the lifetime of a single request.
Read more

5 tips for building apps with the Serverless framework and AWS Lambda

  • Serverless works well with a microservice-style architecture. You should limit the scope of services and functions you use.
  • Lambda functions shouldn’t persist any data or session information in the environment beyond the lifetime of a single request.
  • However, Lambda might reuse your function instances to make performance optimizations. So, you should optimise for your functions for reuse.
  • Cold starts are a problem with AWS Lambda. Reduce latency by keeping containers warm.
  • Use dependency injection to make your functions easily testable. Write integration tests, both locally and on deployments.

Full post here, 6 mins read

Lambdas are Not Functional Programming

Rather than spending time trying tricks with Lambdas, you should: Make good use of Generic Types. Declare type parameters & enforce them everywhere. Minimize casting and if instanceOfing.
Read more

Lambdas are Not Functional Programming

Rather than spending time trying tricks with Lambdas, you should:

  • Make good use of Generic Types. Declare type parameters & enforce them everywhere. Minimize casting and if instanceOfing.
  • Make illegal states unrepresentible in code.
  • Make your own data classes immutable and final where possible, use proper immutable collections.
  • Use libraries that avoid runtime magic and reflection where pragmatically possible.

Full post here, 9 mins read