Top Banner
AWS Lambda at JUST EAT ANDREW BROWN - Senior Platform Engineer
28

AWS Lambda at JUST EAT

Apr 13, 2017

Download

Internet

Andrew Brown
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: AWS Lambda at JUST EAT

AWS Lambda at JUST EAT

ANDREW BROWN - Senior Platform Engineer

Page 2: AWS Lambda at JUST EAT

Overview

Just Eat

Early Adoption

Use Cases

Serverless

Page 3: AWS Lambda at JUST EAT

• The world’s leading digital marketplace for takeaway food delivery• Founded in 2001• Operate in 13 markets around the globe

JUST EAT

• Platform peak has processed 2,500 orders per minute

• Thats a lot of Food!

Page 4: AWS Lambda at JUST EAT

TECHNOLOGY

• Run hundreds of EC2 Instances at peak / dinner time

• Scheduled Scaling of Resources - EC2, Dynamo Capacity

• Heavily utilise CloudFormation

• Just Eat Migrated to AWS 5 years ago - All In!

Page 5: AWS Lambda at JUST EAT

AWS - Setup

• Multiple AWS Accounts

• QA Daily Launch and Teardown

• On average an instance less than 3 days old

• Approx 150 “features” - Each Feature has a Stack

Page 6: AWS Lambda at JUST EAT

What’s good about our Setup?Developers can concentrate on writing code

• Packer, CodeDeploy, Consul, Cloudformation

• Developers create package and deploy!

• PaaS, IaaS

Page 7: AWS Lambda at JUST EAT

What’s good about our Setup?

Consistency

• Many accounts, environments, countries, features

• All get the same AWS resources - e.g. Security Groups

• Templated Cloudformations

Page 8: AWS Lambda at JUST EAT

AWS - Lambda

• Re:Invent 2014 announcement

• AWS Lambda runs your code in response to events

• “we could use that for x, y, and z!”

Page 9: AWS Lambda at JUST EAT

So Why Use Lambda?

• Lightweight

• Cheaper

• Less to manage

• Quicker to Deploy

Page 10: AWS Lambda at JUST EAT

But Why Should JE Use Lambda?

Let’s review One Feature

• CloudFormation• EC2 Instances x 3 - Multi AZ• EBS Volumes• ELB Endpoint and Health Check• IAM Roles• DNS• Security Groups, Subnets, VPC• ASG settings, LaunchConfiguration

~ 1600 lines of JSON

$0.246 x 3 x 24 x 365 (m4.large)

$0.10 x 30 x 3 x 12 (gp2)

$0.028 x 24 x 365 (classic)

~= $7k

Page 11: AWS Lambda at JUST EAT

So Why Use Lambda?

What does this Feature do?

• Resets Delivery Time every morning

• Publishes a SNS message about an order

• Provision access for an instance

• Tidy up resources

Page 12: AWS Lambda at JUST EAT

Early Lambdas● New Technology!

● Multiple languages and frameworks

● Seen as additional parts of a feature

● Using the Console….

Page 13: AWS Lambda at JUST EAT

Early LambdasLimitations / Problems

● Consistency (that’s Just Eat not AWS!)

● No VPC Support (Added Feb 2016)

● No Cron in Cloudformation

● Cloudformation Network Still Attached

Page 14: AWS Lambda at JUST EAT

Use Cases - PaaSBot

• CloudFormation Stack per Environment

• Windows EC2 Instance

• Ran a bunch of Scheduled Tasks

Page 15: AWS Lambda at JUST EAT

Use Cases - PaaSBotClean up EBS Volumes

• Cron build in Teamcity - one per env• Scheduled Windows Task (one per account, assumed roles)• Lambda?

Report Metrics

• T2 Credit Balances• AWS Limits• Lambda?

Page 16: AWS Lambda at JUST EAT

Use Cases - PaaSBotSecurity Audit

• Check Security Group rules• Check User access

Page 17: AWS Lambda at JUST EAT

Use Cases - PaaSLambdaLambdas

• No Windows Instance(s)• Micro-Scheduled Tasks• Easier to update• Better visibility

Page 18: AWS Lambda at JUST EAT

Use Cases - Instance Access

• Recently started using HashiCorp Consul and Vault

• Concerns : “What can my instance access?”

• Consul ACLS and Vault Tokens - limit what key/values you can access

• ACLs Initially provisioned via Deployment Tool

Page 19: AWS Lambda at JUST EAT

Use Cases - Instance Launch

• Lambdas Created with Consul and Vault Cloudformations - nodejs

• ASG Event -> CloudWatch Events -> Trigger Lambda

• Provisions ACL and AppId login

• Removes Access when Instance terminated

Page 20: AWS Lambda at JUST EAT

Use Cases - Instance LaunchLaunch Stack

i-12345i-12345

i-12345

ASG

CloudWatch Event

{ “acl” : a1a1a1-b2b2b2 }

{ “token” : secrettoken }

Page 21: AWS Lambda at JUST EAT

Use Cases - Instance TerminateDelete Stack / Scale Down

i-12345i-12345

i-12345

ASG

CloudWatch Event

Page 22: AWS Lambda at JUST EAT

Different Approach• Starting to create Lambda Features

• Needed a consistent approach

• Recently Implemented Serverless

Page 23: AWS Lambda at JUST EAT

Serverless• Still in “Beta”

Page 24: AWS Lambda at JUST EAT

ServerlessGood Points

• Brings Back Consistency• Ease to deploy• Defined Dependencies• Being Quickly Adopted

• Track signal strength • Calculate cost• Check capacity• Start Ad-hoc backup / Prune Log files

Page 25: AWS Lambda at JUST EAT

ServerlessNot so Good Points

• Currently each Feature includes their AWS resources - previously templated

• Code repeated

• Monitoring & Logging Immature

Page 26: AWS Lambda at JUST EAT

Lessons Learnt & Future Plans• Difficult to integrate into our Platform - Versatility • Still a few Bugs -

• Serverless - Based on Initial Uptake• AWS Lambda & API Gateway• Will it replace our APIs? - Maybe

Page 27: AWS Lambda at JUST EAT

Any questions?

Page 28: AWS Lambda at JUST EAT

Thank you