Slide 1

Slide 1 text

Think Big, Start Small, Scale Fast Develop a Marketplace app using AWS Lambda SEBASTIAN HESSE | SOFTWARE ENGINEER | K15T SOFTWARE | @SEEEBIII

Slide 2

Slide 2 text

Start Setup Develop Scale Goal

Slide 3

Slide 3 text

Start Setup Develop Scale Goal

Slide 4

Slide 4 text

Start Setup Develop Scale Goal

Slide 5

Slide 5 text

Backbone Issue Sync for Jira Sync issue data across company borders

Slide 6

Slide 6 text

After Implemented native cloud to cloud sync. Before Sync initiated from on-prem to another on-prem or cloud.

Slide 7

Slide 7 text

TYPICAL CLOUD ARCHITECTURE SERVERLESS Lambda Function Lambda Function Lambda Function

Slide 8

Slide 8 text

Our Cloud Setup + Amazon Web Services AWS Lambda

Slide 9

Slide 9 text

module.exports = function(event, context, cb) { cb(null, "Hello World."); }

Slide 10

Slide 10 text

Long Running Tasks Perform bigger tasks, e.g. to initialize data. Our Use Cases For Serverless Scheduled Tasks Schedule functions for cleaning up data or other tasks. Webhooks Receive webhooks from Jira, Confluence, etc. and process them.

Slide 11

Slide 11 text

Start Setup Develop Scale Goal

Slide 12

Slide 12 text

Start Setup Develop Scale Goal DEVELOPMENT

Slide 13

Slide 13 text

Local Machine Execute and debug + test your code on your local machine. Cloud Upload your code to the cloud and test it there. Testing & Debugging

Slide 14

Slide 14 text

No pain, no gain Log as much as necessary and test it in the cloud.

Slide 15

Slide 15 text

Quick code updates Wrote our own library lambda-updater to quickly update the Lambda code. Write tests Writing unit and integration tests can already identify lots of problems. Real environment No service mocks, latencies don't explode and a better feeling about the execution. Why?!

Slide 16

Slide 16 text

Quick code updates Wrote our own library lambda-updater to quickly update the Lambda code. Write tests Writing unit and integration tests can already identify lots of problems. Real environment No service mocks, latencies don't explode and a better feeling about the execution. Why?!

Slide 17

Slide 17 text

Quick code updates Wrote our own library lambda-updater to quickly update the Lambda code. Write tests Writing unit and integration tests can already identify lots of problems. Real environment No service mocks, latencies don't explode and a better feeling about the execution. Why?!

Slide 18

Slide 18 text

Start Setup Develop Scale Goal DEPLOYMENT

Slide 19

Slide 19 text

CloudFormation Infrastructure as Code

Slide 20

Slide 20 text

"webhooks": [ { "event": "jira:issue_updated", "url": "/webhooks?appVersion={{version}}" } ] Different Versions atlassian-connect.json:

Slide 21

Slide 21 text

+ DevOps

Slide 22

Slide 22 text

Start Setup Develop Scale Goal

Slide 23

Slide 23 text

Start Setup Develop Scale Goal FUNCTION SCOPE

Slide 24

Slide 24 text

Task #2 Check content. Function Scope Task #3 Do something with it. Task #1 Receive webhook.

Slide 25

Slide 25 text

Task #2 Check content. Function Scope Task #3 Do something with it. Task #1 Receive webhook.

Slide 26

Slide 26 text

Keep it simple, stupid. KELLY JOHNSON

Slide 27

Slide 27 text

Reusability Reuse your functions from multiple contexts. Performance Single purpose functions execute faster. Multiple Scopes

Slide 28

Slide 28 text

Lambda Response Times 0 500 1000 1500 2000 1 2 3 4 5

Slide 29

Slide 29 text

Lambda Response Times 0 500 1000 1500 2000 1 2 3 4 5

Slide 30

Slide 30 text

Programming Language Java for background functions, NodeJS for functions which are performance relevant. Function Scope One scope per function. For example, one webhook receiver function, one email sending function, etc. Consider

Slide 31

Slide 31 text

Can we use AWS Lambda as a REST API? SOME DEVELOPERS

Slide 32

Slide 32 text

Lambda Response Times 0 500 1000 1500 2000 1 2 3 4 5

Slide 33

Slide 33 text

Start Setup Develop Scale Goal COMMUNICATION

Slide 34

Slide 34 text

Function Payload Communicate Function 1 Function 2

Slide 35

Slide 35 text

Function Payload Communicate Function 1 Function 2

Slide 36

Slide 36 text

Solution #1 Function 1 Function 2 Function 2

Slide 37

Slide 37 text

Solution #2 KEY Function 1 Function 2 Function Payload S3

Slide 38

Slide 38 text

Start Setup Develop Scale Goal

Slide 39

Slide 39 text

Start Setup Develop Scale Goal WEBHOOKS

Slide 40

Slide 40 text

1000 webhooks at the same time

Slide 41

Slide 41 text

Scaling for AWS Lambda is done automatically... right? MANY DEVELOPERS

Slide 42

Slide 42 text

Other services are not necessarily scaled. Lambda functions are scaled by AWS. YES NO

Slide 43

Slide 43 text

DynamoDB S3

Slide 44

Slide 44 text

DynamoDB S3

Slide 45

Slide 45 text

Buffer Webhooks Function 1 AWS Kinesis Webhook

Slide 46

Slide 46 text

Buffer Webhooks Function 1 Function 2 AWS Kinesis Webhook

Slide 47

Slide 47 text

Start Setup Develop Scale Goal LONG RUNNING TASKS

Slide 48

Slide 48 text

5 minute execution time limit

Slide 49

Slide 49 text

5 minutes are enough for the task my function is performing. A FEW DEVELOPERS

Slide 50

Slide 50 text

Collect tenant information from database. < 1 sec 350ms / 100 issues Retrieve all issues from a project in Jira. Find issues matching your configuration. < 1 sec Example: Retrieve 800 Issues For Sync Perform further steps and update issue data. 350ms / 1 issue 10 sec Store relevant information in database.

Slide 51

Slide 51 text

Solution #1 Call yourself before function reaches execution limit.

Slide 52

Slide 52 text

Solution #2 Use other services like an EC2 server to execute your tasks.

Slide 53

Slide 53 text

Solution #3 Use AWS Step Functions to define an execution order of your functions. AWS Step Functions

Slide 54

Slide 54 text

Example Step Function "Retrieve issues": { "Type": "Task", "Resource": "arn:aws:lambda:...", "Next": "All issues?", "Retry": [ { ... } ] } Retrieve issues All issues? Process issues Failed START END

Slide 55

Slide 55 text

Start Setup Develop Scale Goal SCHEDULED TASKS

Slide 56

Slide 56 text

Examples Webhooks Webhooks are not 100% reliable. Catch up missed webhooks every day. Weekly Updates Send a status update every week and let your customers know about some numbers. Clean Up Clean up data in your environment, e.g. in your database.

Slide 57

Slide 57 text

Trigger Function AWS CloudWatch Lambda Function

Slide 58

Slide 58 text

Monitoring Enable monitoring and notification about failures. Learn from it and adapt your architecture. Failures Functions can fail quite easily and you might never know, because you don't check the logs or any metrics.

Slide 59

Slide 59 text

Start Setup Develop Scale Goal

Slide 60

Slide 60 text

Trade Offs Potentially less operational costs, but more complex architecture. Please Remember Scalability Consider scalability for all of your services. Function Scope Focus on one scope per function. Think about the use case of a function.

Slide 61

Slide 61 text

Start Setup Develop Scale Goal

Slide 62

Slide 62 text

Start Setup Develop Scale Goal

Slide 63

Slide 63 text

Start now! SEBASTIAN HESSE | SOFTWARE ENGINEER | K15T SOFTWARE | @SEEEBIII