Python on AWS Lambda

Preview:

Citation preview

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Markku Lepistö - Principal Technology Evangelist

Python on Lambda

User Application

Application Service

Middleware Service

Language Interpreter

Operating System

Host

Focus on Your Application

Move Up the Stack

Application

Architecture

Adrian Cockcroft, Technology Fellow at Battery Ventures

http://www.slideshare.net/adriancockcroft/goto-berlin

Amazon Web Services

Containers Docker launched in 2013

Cloud EC2 launched in 2006

Virtualization Since late 1990s

Bare Metal Since 1960s

Lambda Launched in 2015

Containers Docker launched in 2013

Cloud EC2 launched in 2006

Virtualization Since late 1990s

Bare Metal Since 1960s

Event driven, fully managed compute

All you need is code™

Fast

events trigger code execution

in milliseconds – at any scale

Cost & Resource Efficient

100ms billing granularity

of compute chunks

Highly Requested by Customers Since Launch

Running Python on Lambda

Where can I use the AWS Python SDK ?

Your dev environment Amazon EC2 VM / Container AWS Lambda(install) (install) (pre-installed)

Programming model

Asynchronous Synchronous

handler_name event context

• Print

• Logger

AWS CloudWatch Logs

New Python lambda function from blueprint

• Lambda console

• Asynchronous – triggered by S3 event

• Debug & logs in Cloudwatch

• Identity and Access Management

• Exceptions handling

New Python ‘Hello World’ Lambda function

• Unit tests in Lambda console

• Synchronous – called by us

• Request ID (useful for troubleshooting)

• Time remaining (before ‘timed out’ function is killed)

• Memory available

• Info on calling client i.e Mobile app

• etc

context

context.log_stream_name

context.log_group_name

context.aws_request_id

context.memory_limit_in_mb

context.get_remaining_time_in_millis()

Let’s run the previous slide Context example

aws lambda create-function

• pip install zip

setup.cfg

[install]

prefix=

aws.amazon.com/lambda

@markkulepisto