Overview of AWS Lambda

AWS Lambda is a compute service that runs code without the developer having to manage the infrastructure which it runs on. The compute resources are automatically managed by AWS. The code is triggered to execute based on events, in other words the code runs on demand. AWS charges only for code execution time.

 

Evolution of Server-side Computing

These are some of the major evolution steps in server-side computing:

  • Mainframes (1950s – 1970s )
  • Minicomputers / Personal Computers (1970s)
  • Virtualization / Hypervisors (mid-2000s)
  • Cloud Servers (2006+)
  • Serverless Computing (2015+)

Server-less has a cost benefit over previous managed infrastructure in that only execution time is paid for. It removes maintenance and management cost of the infrastructure/platform. This also elevates complexities related to infrastructure and keeps focus on the execution process only. It creates a separation of concern and as such, it is much easier to integrate server-less programs with other services and infrastructure.

The major server-less providers are (as of 2016)

  • AWS Lambda
  • Azure Functions
  • Google Cloud Functions
  • Iron.io *one of the first server-less computing providers
  • IBM Open Whisk

It’s important to note that server-less computing requires an event to start the execution. Some of these event types are:

  • File Upload
  • Scheduled Time
  • API Request

 

Requirements and Limitations

Being that AWS Lambda is one of the newest services provided and only a few years old, there are some limitations to take note of.

  • Lambda functions must be less than 250MB uncompressed
  • Lambda functions must be less than 50MB compressed
  • The total number of functions in a single region must be less than 75GB
  • Must use less than 1000MB of memory
  • Must execute under 300 seconds
  • Cannot run more than 100 concurrent functions
  • Any other service lambda interacts with must be in the same region

There are some workarounds for the above limitations. Also, these limitations are as of 2017. It is expected to change over time.

 

AWS Lambda Console

The Lambda console has two main parts:

  • configuration
  • monitoring

 

Lambda Configuration

 

 

Lambda Monitoring

 

 

Programming Model for Lambda Functions

The following notes come from here:
https://docs.aws.amazon.com/lambda/latest/dg/programming-model-v2.html

The following core concepts are common patterns for any Lambda function:

  • Handler
    • This is what starts the function execution
    • In the project examples, this is the index.handler method
  • Context Object
    • Lambda passes the context object for all function calls (2nd parameter after the event parameter)
    • This object is used to interact with AWS Lambda service
    • Optionally, for node.js functions, there is the callback parameter, which can be seen in the example
  • Logging
    • Logging to CloudWatch
  • Exceptions
    • Function invoked during exceptions/errors

 

References

AWS Developer Guide
https://docs.aws.amazon.com/lambda/latest/dg/lambda-introduction-function.html

Scalable AWS API Gateway (pluralsight)
William Button; 2016
https://app.pluralsight.com/player?course=scalable-aws-api-gateway

AWS Developer Introduction (pluralsight)
Fernando Corey; 2017
https://app.pluralsight.com/player?course=aws-developer-introduction-aws-lambda

AWS Serverless with NodeJS
https://app.pluralsight.com/player?course=aws-nodejs-serverless-framework-using