AWS Lambda Summary, as I Known

AWS Lambda runs immediately based on events. You can execute Lambda directly, or you can subscribe to the event and execute the Lambda asynchronously.

AWS Lambda Example Image

  • CloudWatch + Lambda
    • Respond to log events (and even register specific patterns) in AWS CloudWatch
  • S3 + Lambda
    • Responds to specific events in AWS S3 (image upload, etc.)
  • API Gateway + Lambda
    • Responds to HTTP requests coming from AWS API Gateway using lambda functions
  • SQS + Lambda
    • Check events from AWS SQS, etc. and process them asynchronously using lambda functions

Pros

  • You only pay for what you use (cost savings)
    • Compared to servers that run continuously, AWS Lambda that run only when used are charged proportionally to the number of executions.
    • Very cheap at $0.2 per million executions
  • Auto-scale-up, high availability
    • Dynamically allocates resources and handles scaling as requests come in
    • You may be charged more for more requests
  • Rapid product launch
    • You can focus on your code without having to worry about server management

Cons

  • Cold start (time it takes for lambda to wake up)
    • Lambda is normally sleeping and wakes up to do its job when you run it.
    • This can cause a delay of up to 1 second
    • Not suitable for services where latency is unacceptable (real-time services)
  • Dependent on server provider (AWS, GOOGLE, etc.)
    • Not easy to move platforms because it’s platform dependent.
  • Bad for long time consuming tasks (uploading videos)
    • Limited memory and time available for lambda function calls.
    • Large features need to be implemented in small pieces
  • Difficult to reuse code
    • Because each function is independent, you end up duplicating logic that you use in common

Lambda Layer

Among the disadvantages listed above is the difficulty of reusing code. This is a technique to solve this problem.
You can create layers of common parts and let lambda functions share them.
They can be shared not only between the same account, but also between different accounts.

Explore Lambda Layers

Provisioning Concurrency

This is a technique to solve the problem of cold start of AWS Lambda.
It can be used when concurrency and latency are important, as it prepares lambda functions for execution in advance.