37
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Ben Snively, Senior Solutions Architect, AWS Mike Jensen, Director of Engineering, DNC June 21, 2016 Getting Started with Serverless Architectures

Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Embed Size (px)

Citation preview

Page 1: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

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

Ben Snively, Senior Solutions Architect, AWSMike Jensen, Director of Engineering, DNC

June 21, 2016

Getting Started with Serverless Architectures

Page 2: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Agenda• (20m) AWS serverless architectures

• Microservices and serverless technologies• AWS Lambda• Amazon API Gateway• Amazon DynamoDB

• (25m) Customer Feature—DNC• DNC Goals• Lambda use case—voter registration• Lambda use case—opposition research• DynamoDB use case—donation prefills

Page 3: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Microservices architectureThe microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.

-- James Lewis and Martin Fowler

Page 4: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Benefits of microservices for Amazon

System operation is simple(developers can be on-call )

Agility(new features added quickly)

Innovation as its best(team has time to think big)

Short build/test/release cycles(fix problems soon)

Software architecture is easier to maintain and evolve

Scalable software(horizontal scalability)

Fast development pace(developers fully focused on writing code)

Customers excited(new software releases every day!)

Page 5: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

What is serverless computing?

• VMs• Machine as the unit of scale• Abstracts the hardware

• Containers• Application as the unit of scale• Abstracts the OS

• Serverless• Functions as the unit of scale• Abstracts the language runtime AWS Lambda

Amazon ECS

Amazon EC2

Page 6: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Microservices and AWS Lambda

AWS Lambda + Amazon API Gateway is the easiest way to create microservices

• Event handlers one function per event type• Serverless back ends one function per API / path• Data processing one function per data type

Page 7: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

AWS Lambda: serverless computing

Run code without servers. Pay only for the compute time you consume. Be happy.

Triggered by events or called from APIs:• PUT to an Amazon S3 bucket• Updates to Amazon DynamoDB table• Call to an Amazon API Gateway endpoint• Mobile app back-end call• And many more…

Makes it easy to:• Perform real-time data processing• Build scalable back-end services• Glue and choreograph systems

Page 8: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Continuous scaling

No servers to manage

Never pay for idle—no cold servers

(only happy accountants)

Benefits of AWS Lambda

Page 9: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Pay per requestBuy compute time in • 100 ms increments for

21 microcents• Request charge of 20

microcents• No hourly, daily, or

monthly minimums• No per-device fees

Never pay for idle!

Free Tier1 million requests and 400,000 gigabytes of

compute every month, every customer

Page 10: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Using AWS Lambda

Bring your own code• Node.js, Java, Python• Bring your own libraries

(even native ones)

Simple resource model• Select power rating from

128 MB to 1.5 GB• CPU and network allocated

proportionately• Reports actual usage

Flexible authorization• Securely grant access to

resources, including VPCs• Fine-grained control over

who can call your functions

Flexible use• Call or send events• Integrated with other AWS

services• Build whole serverless

ecosystems

Page 11: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Amazon API Gateway: serverless APIs

Internet

Mobile apps

Websites

Services

AWS Lambda functions

AWS

Amazon API Gateway cache

Endpoints on Amazon EC2

Any other publicly accessible endpointAmazon

CloudWatch

Amazon CloudFront

Amazon API Gateway

Page 12: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Benefits of Amazon API Gateway

Create a unified API front end for

multiple microservices

DDoS protection and throttling for

back-end systems

Authenticate and authorize requests

Page 13: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

NoSQL database

Fully managed

Single-digit millisecond latency

Massive and seamless scalability

Low costAmazon

DynamoDB

Designed forTier Oneapplications

Page 14: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Predictable, low latency performance

Consistent single-digit millisecond latency even at massive scales

Page 15: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

WritesReplicated continuously to 3 AZsPersisted to disk (custom SSD)

ReadsStrongly or eventually consistent

No latency trade-off

Automatic replication for rock-solid durability and availability

Page 16: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Amazon DynamoDB is a schemaless database

AttributesSchemalessSchema is defined per item

Items

TableItem key

Page 17: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Common use cases

Page 18: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Use case: data processing

Example: Amazon S3 bucket triggers

Amazon S3 bucket events

Original object Compressed object1

2

3

AWS Lambda

Page 19: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Use case: automatically scalable back ends

1. AWS Mobile SDK + Amazon Cognito for mobile appOr AWS IoT for devices2. AWS Lambda runs the code3. Amazon API Gateway (if you want your own endpoint)4. Amazon DynamoDB holds the data

AWS Lambda Amazon DynamoDB

Page 20: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Use case: serverless web apps

1. Amazon S3 for serving static content2. AWS Lambda for dynamic content3. Amazon API Gateway for https access4. Amazon DynamoDB for NoSQL data storage

Dynamic content in AWS Lambda

Data stored in Amazon

DynamoDB

Amazon API Gateway

Static content in Amazon S3

Page 21: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

re:Invent 2015• Python• Scheduled functions• Longer running times (5 min.)• Versioning

Recent launches

Since re:Invent• Higher code storage limits (from 5 GB

to 75 GB)• Custom VPC• 1-minute schedules• Regional launch: Frankfurt• Node.js 4.3.2• 1-click CORs setup• Stage variables• Custom (AWS Lambda) authorizers• Built-in Swagger import/export• AWS CloudFormation support for API

Gateway and versions

New!

New!

Page 22: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Mike JensenDirector of Engineering, DNC

Page 23: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

DNC – What We Do

Our goal is to get Democrats elected, up and down the ballot

The Engineering Team provides infrastructure building and campaign support

We meet campaigns at their level of technical expertise

Page 24: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Why We Use AWS

Security, Stability, Scalability No second chances – Only one election day!

Page 25: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Application Use

Expected Traffic

Expected Traffic

Unexpected Traffic

Unexpected Traffic

Page 26: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

How We Handle This

Testing, testing, testing! S3 for static sites/assets ELBs and Auto Scaling groups Microservice Architecture New! - Lambda and DynamoDB

Page 27: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Lambda Use Case 1 – Voter Registration

The most important data for us Old system – monolithic, server intensive Difficult to update, maintain, add feature requests

Registration Service

IwillVote User

Voter Laws API

IwillVote System

Registration Database

VAN

Page 28: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Lambda Use Case 1 – Voter Registration

Split out service functionality Voter registration processing using Lambda SQS backup and Lambda re-trigger

Registration Database

IwillVote User

Voter Laws API

IwillVote Service

VANRegistration ServiceRegistration

API

Registration Function

Registration Queue

Page 29: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Lambda Use Case 2 – Opposition Research

Opposition research is crucial Many systems require manual input Lambda → Ready when the event occurs

Upload User

Processing User

File Uploader

Research System

Research Database

Page 30: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Lambda Use Case 2 – Opposition Research

Lambda triggers on updates - processes and uploads data

Available to research teams immediately Nothing is missed

Research System

Research Database

S3 Triggered

Processing

Upload User

Scraper System

RSS Triggered

Downloads

Research Storage

Page 31: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Not Everything Is Perfect

No native Ruby functions (yet) – possible, but not easy, using Ansible, mruby, or JRuby

Limited error reporting Disk space limits – larger processing jobs have to be

triggered manually on a separate system Refactoring applications is development intensive

Page 32: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

DynamoDB – Donation Pre-fills

Page 33: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

DynamoDB – Donation Pre-fills

Campaigns/committees are funded entirely through donations

Election law requires extensive collection of donor data Our job – make it as easy as possible for people to

support Democratic groups Our solution – pre-fill what we can using hash id’s

Page 34: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

DynamoDB – Donation Pre-fills

Page 35: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

DynamoDB – Donation Pre-fills

DynamoDB makes the easy – key/value store with donor pre-fill data

Fast and secure access to data Event based traffic – EOQ, major media events Scale up without downtime

Page 36: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Takeaways

AWS is great for the operational speed of campaigns Lambda and DynamoDB have very specific use cases Additional stability and scalability for services we

provide We are excited for future integrations

Page 37: Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Thank you!