Lambda

  Amazon Web Services (AWS)

Lambda was released in 2015.

AWS Lambda is a compute service where you can upload your code and create a lambda function.  AWS Lambda takes care of provisioning and managing the servers that you use to run the code.  You don’t have to worry about the operating systems, patching, scaling, etc. You can use Lambda in the following ways:

  • As an event-driven compute service where AWS Labda runs your code in response to events.  These events could be changes to data in an S3 bucket or a DynamoDB table.
  • As a compute service to run your code in response to HTTP requests using Amazon API Gateway or API calls made using AWS SDKs.  This is what is used at A Cloud Guru.

Lambda events can trigger other Lambda events.  They can also communicate with other AWS services.

Lambda scale out automatically.  Each request to Lambda invokes a new ‘instance’ of the service.

  • Example: Lambda functions displays ‘Hello, World!”.  If a million users trigger that function at the same time, there will be a million versions of the function running.  No need to provision or scale anything – it just happens.

How is Lambda Priced?

  • Number of requests
    • First 1 million requests are free.  $0.20 per 1 million requests thereafter.
  • Duration
    • Duration is calculated from the time your code begins executing until it returns or otherwise terminates, rounded up to the nearest 100ms.  The price depends on the amount of memory you allocate to your function.  You are charged $0.00001667 for every GB-second used.
    • Functions cannot execute over 5 minutes.  If a function needs to run longer than 5 minutes, you should break it up into smaller functions that call each other.

Why is Lambda Cool?

  • Serverless.  No hardware from the eyes of the developer!
    • Just focus on your code!
  • Continuous Scaling – Automatically scales instantly out as it is accessed.
  • Super Super Super Cheap!

Exam Tips

  • Lambda scale out (not up) automatically
  • Lambda functions are independent. 1 event = 1 function
  • Lambda is serverless
    • Know which AWS services are serverless!
      • API Gateway
      • AWS IoT
      • Alexa Skills Kit
      • Alexa Smart Home
      • CloudFront
      • CloudWatch Events
      • CloudWatch Logs
      • CodeCommit
      • Cognito Sync Trigger
      • DynamoDB
      • Kinesis
      • S3
      • SNS
    • Triggers are based by region, so to see all the available triggers, set US East (N. Virginia) as your Region.
  • Lambda functions can trigger other Lambda functions: 1 event can = x functions if functions trigger other functions.
  • Architectures can get extremely complicated, AWS X-Ray allows you to debug what is happening
  • Lambda can do things globally, you can use it to back up S3 buckets to other S3 buckets, etc.
  • Know your triggers.
  • A Lambda function’s maximum duration time is 5 minutes.
  • Languages supported by Lambda
    • C#
    • Java (8)
    • Node.js (4.3, 6.10)
    • Python (2.7, 3.6)

LEAVE A COMMENT