AWS Lambda is a simple and inexpensive way to run your code without thinking about the backend. Write your code in the language of your choice (Python, Java, Node.js, and a few others are supported) and upload it and its dependencies to AWS Lambda. Trigger when your code will run, either by an AWS event (e.g. new object in a S3 bucket) or have it timed to run periodically. The first million requests are free and only $0.20 per million requests afterwards.
When your Lambda function is invoked, a Docker container is created. That container may be reused on subsequent Lambda function calls. The container has a user defined limit on how long it can run (max of 5 minutes) and a memory footprint (max of 1.5G). The limits on AWS Lambda can be found at http://docs.aws.amazon.com/lambda/latest/dg/limits.html.
There are a variety of uses for AWS Lambda. It can be used (along with AWS API Gateway) to create a REST API. It can be used to react to published AWS events in S3, Kinesis, DynamoDB, and SNS. It can also be used to schedule events. You can find out the various use cases at http://docs.aws.amazon.com/lambda/latest/dg/use-cases.html.
Below are the steps to prepare your Python code for AWS Lambda.
- Install the dependencies within the source code directory.
$ pip install -r requirements.txt -t .
- Zip up the contents of the source code directory.
$ zip -r ../lambda_bundle.zip *
- Take note of the module where your function resides. You will use it (e.g. your_module.your_function) as the Lambda handler.