Getting Started with Serverless Architectures | AWS Public Sector Summit 2016

Preview:

Citation preview

© 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

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

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

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!)

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

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

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

Continuous scaling

No servers to manage

Never pay for idle—no cold servers

(only happy accountants)

Benefits of AWS Lambda

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

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

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

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

NoSQL database

Fully managed

Single-digit millisecond latency

Massive and seamless scalability

Low costAmazon

DynamoDB

Designed forTier Oneapplications

Predictable, low latency performance

Consistent single-digit millisecond latency even at massive scales

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

Amazon DynamoDB is a schemaless database

AttributesSchemalessSchema is defined per item

Items

TableItem key

Common use cases

Use case: data processing

Example: Amazon S3 bucket triggers

Amazon S3 bucket events

Original object Compressed object1

2

3

AWS Lambda

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

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

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!

Mike JensenDirector of Engineering, DNC

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

Why We Use AWS

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

Application Use

Expected Traffic

Expected Traffic

Unexpected Traffic

Unexpected Traffic

How We Handle This

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

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

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

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

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

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

DynamoDB – Donation Pre-fills

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

DynamoDB – Donation Pre-fills

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

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

Thank you!

Recommended