python in the serverless era (pycon il 2016)

35
Python In The Serverless Era Benny Bauer Software Architect, Autodesk [email protected] @benikbauer

Upload: benny-bauer

Post on 23-Jan-2018

633 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Python in the Serverless Era (PyCon IL 2016)

Python In The Serverless Era

Benny BauerSoftware Architect, Autodesk

[email protected]

@benikbauer

Page 2: Python in the Serverless Era (PyCon IL 2016)

▪ Hello

▪ Cloud Evolution

▪ Serverless Architecture

▪ Ecosystem

Agenda

Page 3: Python in the Serverless Era (PyCon IL 2016)

Hello

Page 4: Python in the Serverless Era (PyCon IL 2016)

Hello

Page 5: Python in the Serverless Era (PyCon IL 2016)

AutoCAD 360

Page 6: Python in the Serverless Era (PyCon IL 2016)

AutoCAD 360 Backend

Page 7: Python in the Serverless Era (PyCon IL 2016)

Cloud Evolution

Page 8: Python in the Serverless Era (PyCon IL 2016)

It’s Evolution Baby!

Icons made by freepik from www.flaticon.com

Page 9: Python in the Serverless Era (PyCon IL 2016)

▪ Hosting▪ Data access▪ Authentication▪ Notifications▪ Monitoring▪ Analytics

Backend as a Service

Page 10: Python in the Serverless Era (PyCon IL 2016)

Serverless Architecture

Page 11: Python in the Serverless Era (PyCon IL 2016)

Introducing Serverless

Page 12: Python in the Serverless Era (PyCon IL 2016)

▪ Fully managed compute▪ Provisioning, patching▪ Scalability▪ Monitoring▪ Logging▪ No ops

▪ Just deploy your code▪ Pay only for actual usage ==

Full utilisation!

Serverless Architecture

Page 13: Python in the Serverless Era (PyCon IL 2016)

AWS Lambda - How it works

origin: https://aws.amazon.com/lambda/

Page 14: Python in the Serverless Era (PyCon IL 2016)

▪ REST API▪ Stateless services

▪ Suitable for Slack apps (though not bots)

▪ Events▪ File processing (S3 event) & Data ingestion (Kinesis event)

▪ Incidents handling (CloudWatch event)

▪ IoT

▪ Scheduled tasks▪ Monitoring, sanity tests, load testing

▪ Periodical jobs

Use cases

Page 15: Python in the Serverless Era (PyCon IL 2016)

▪ Stateless

▪ Autoscaled according to demand (events or requests)

AWS Lambda Characteristics

Page 16: Python in the Serverless Era (PyCon IL 2016)

▪ Need to keep it warm

▪ Convenience can lead to vendor lock-in

▪ Languages: Python 2.7, Node.js, Java 8

▪ Execution time is limited to 5 min

▪ Concurrent execution is limited to 100*

▪ Various payload and disk size limits

▪ Not in all AWS regions

▪ No SSH (which is good!)

AWS Lambda Limitations

Page 17: Python in the Serverless Era (PyCon IL 2016)

Code should be:

▪ Small

▪ Short-lived

▪ Stateless

The Required Mindset

Page 18: Python in the Serverless Era (PyCon IL 2016)

Ecosystem

Page 19: Python in the Serverless Era (PyCon IL 2016)

AWS Lambda & API Gateway are nice, but...

▪ Configuration headache▪ IAM roles

▪ API Gateway

▪ Deployment headache▪ Packaging

▪ Uploading

▪ Rollback

Page 20: Python in the Serverless Era (PyCon IL 2016)

Serverless Framework

Application framework for building applications exclusively on AWS Lambda and API Gateway

Serverless

origin: https://github.com/serverless/serverless

Page 21: Python in the Serverless Era (PyCon IL 2016)

Serverless Framework

▪ Wraps AWS Lambda, API Gateway and IAM

▪ Manages deployments

▪ CLI

▪ Modular, functions can be easily shared

▪ Extensible via plugins

▪ Thriving community

▪ Node.js - posterboy, Python - foster child

Page 22: Python in the Serverless Era (PyCon IL 2016)

$ sls project create

Page 23: Python in the Serverless Era (PyCon IL 2016)

$ sls function create

Page 24: Python in the Serverless Era (PyCon IL 2016)

▪ handler.py▪ Entry point to your implementation

▪ s-function.json▪ Endpoints configuration▪ Events configuration▪ Env vars definition▪ Lambda configuration (runtime, timeout, size, etc.)

# implement

functions

|__function1

|__event.json

|__handler.py

|__s-function.json

Page 25: Python in the Serverless Era (PyCon IL 2016)

$ sls dash deploy

Page 26: Python in the Serverless Era (PyCon IL 2016)

Zappa

Python WSGI applications deployment on AWS Lambda + API Gateway.

Rich JonesMiserlou

origin: https://github.com/Miserlou/Zappa

Page 27: Python in the Serverless Era (PyCon IL 2016)

Zappa Architecture

Page 28: Python in the Serverless Era (PyCon IL 2016)

Zappa example

Page 29: Python in the Serverless Era (PyCon IL 2016)

Zappa example

Page 30: Python in the Serverless Era (PyCon IL 2016)

Zappa - How it works

$ zappa deploy <env>

1. Zips code and dependencies

2. Create AWS Lambda and deploys the zip

3. Creates endpoint on API Gateway and ties to AWS Lambda

Page 31: Python in the Serverless Era (PyCon IL 2016)

Serverless architecture is the next generationof cloud evolution

Takeaways

Page 32: Python in the Serverless Era (PyCon IL 2016)

The Serverless ecosystem is on the rise,many interesting opportunities for

the Python community to contribute!

Takeaways

Page 33: Python in the Serverless Era (PyCon IL 2016)

▪ awesome-serverless▪ https://github.com/Miserlou/Zappa▪ Serverless Framework talk (aka JAWS) on AWS re:invent

https://youtu.be/D_U6luQ6I90

References

Page 34: Python in the Serverless Era (PyCon IL 2016)

Questions?

Page 35: Python in the Serverless Era (PyCon IL 2016)

Thank You!