aws webcast - build mobile apps with a secure, scalable back end on dynamodb

59
Build Mobile Apps with a Secure, Scalable Back End on DynamoDB Matt Wood, General Manager, Data Science October 10, 2013

Upload: amazon-web-services

Post on 26-Jan-2015

106 views

Category:

Technology


3 download

DESCRIPTION

Mobile apps and connected devices require a secure and scalable back end to deliver an excellent user experience. DynamoDB makes it easy to securely store and serve data, with remarkably low latency. Join us to learn how to easily build scalable mobile apps with a powerful back end.

TRANSCRIPT

Page 1: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Build Mobile Apps with a Secure,

Scalable Back End on DynamoDB

Matt Wood, General Manager, Data Science

October 10, 2013

Page 2: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Thank you!

Page 3: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Three things

1. An introduction to DynamoDB

2. Using DynamoDB with a mobile application

3. Next steps, free stuff and getting started

Page 4: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Act One

Under the covers of DynamoDB.

Page 5: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Amazon RDS

Amazon

DynamoDB Amazon Redshift

Amazon

ElastiCache

Compute Storage

AWS Global Infrastructure

Database

Application Services

Deployment & Administration

Networking

AWS Database Services

Page 6: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Amazon’s Path to DynamoDB

RDBMS DynamoDB

Page 7: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

= Key/value store

Page 8: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Fully Managed

Low Cost

Predictable Performance

Massively Scalable

=

Page 9: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

DEVS

OPS

USERS

for

Page 10: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Fast Application

Development

Time to Build New Applications

• Flexible data models • Simple API • High-scale queries • Laptop development

DEVS

OPS

USERS

for

Page 11: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Fast Application

Development

Super Bowl promotion

Millions of interactions over a relatively short period of time

Built the app in 3 days, from design to production-ready

Weatherbug mobile app Lightning detection & alerting for 40M users/month Developed and tested in weeks, at “1/20th of the cost of the traditional DB approach”

Page 12: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Fast Application

Development

Relationship Modeling

1

Simple API 2

High Scale Query Patterns

3

Page 13: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Tables, Items, Attributes

• A Table is a collection of Items

• An Item is a collection of Attributes

• Attributes have a key and a value

Page 14: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Primary keys

• Hash key

• Composite key

• Indexed by primary key, and local secondary indices

• Data is auto-partitioned based primarily on the hash key

Client

Partitions

1 .. N

DynamoDB

Table

Page 15: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Modeling 1:1 Relationships

• Use a table with a hash key

• Examples: – Users

• Hash key = UserID

– Games

• Hash key = GameId

Users table

Hash Key Attributes UserId = bob Email = [email protected], JoinDate = 2011-11-15

UserId = fred Email = [email protected], JoinDate = 2011-12-01, Sex = M

Games table

Hash Key Attributes GameId = Game1 LaunchDate = 2011-10-15, Version = 2, GameId = Game2 LaunchDate = 2010-05-12, Version = 3, GameId = Game3 LaunchDate = 2012-01-20, version = 1

Page 16: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Modeling 1:M Relationships

• Use a table with hash and range key

• Example: – One (1) User can play many (N) Games

• UserGames table

– Hash key = UserId

– Range key = GameId

UserGames table

Hash Key Range Key Attributes

UserId = bob GameId = Game1 HighScore=10500, ScoreDate=2011-10-20, LastPlayed=2013-02-11

UserId = fred GameId = Game2 HIghScore = 12000, ScoreDate = 2012-01-10, LastPlayed=2013-05-19

UserId = bob GameId = Game3 HighScore = 20000, ScoreDate = 2012-02-12, LastPlayed=2012-11-07

multi-tenancy tenant-id = hash

Page 17: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Simple API

CreateTable

UpdateTable

DeleteTable

DescribeTable

ListTables

PutItem

GetItem

UpdateItem

DeleteItem

BatchGetItem

BatchWriteItem

Query

Scan

manage tables

query specific items OR scan the full table

read and write items

bulk get or update

Page 18: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Query Patterns

• Available for hash+range primary key tables

• Retrieve all items by hash key

• Range key conditions:

• ==, <, >, >=, <=, begins with, between

• Sorted results. Counts. Top and bottom n

values. Paged responses

Page 19: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Local Secondary Indexes

• Designed for high scale multi-tenant applications

• Index local to the hash key (= partition)

• Up to 5 indexes with no performance degradation

UserGames table

Hash Key Range Key Attributes

UserId = bob GameId = Game1 HighScore=10500, ScoreDate=2011-10-20, LastPlayed=2013-02-11

UserId = fred GameId = Game2 HIghScore = 12000, ScoreDate = 2012-01-10, LastPlayed=2013-05-19

UserId = bob GameId = Game3 HighScore = 20000, ScoreDate = 2012-02-12, LastPlayed=2012-11-07

UserGamesIdx index Hash Key Range Key Projected Attributes UserId = bob LastPlayed=2013-02-11 GameId = Game1 UserId = fred LastPlayed=2013-05-19 GameId = Game2 UserId = bob LastPlayed=2012-11-07 GameId = Game3

Page 20: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Latest News… DynamoDB Local

• Disconnected development

• Full API support

• Download from http://aws.amazon.com/dynamodb/resources/#testing

Page 21: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

DEVS

OPS

USERS

Admin-Free (at any scale)

for

Page 22: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Admin-Free (at any scale)

“Our previous NoSQL database required

almost an full time administrator to run.

Now AWS takes care of it.”

“Even though we have years of experience with large, complex NoSQL architectures, we are happy to be finally out of the business of

managing it ourselves.”

Page 23: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Admin-Free (at any scale)

Provision / Configure

Servers and Storage

Repartition Data

and Balance

Clusters

Manage Cross-

Availability

Zone Replication

Update

Hardware and

Software

Monitor and

Handle Hardware

Failures

Page 24: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

request-based capacity provisioning model

Provisioned Throughput

Throughput is declared and updated via the API or the console

CreateTable (foo, reads/sec = 100, writes/sec = 150)

UpdateTable (foo, reads/sec=10000, writes/sec=4500)

DynamoDB handles the rest

Capacity is reserved and available when needed

Scaling-up triggers repartitioning and reallocation

No impact to performance or availability

Page 25: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

DEVS

OPS

USERS Durable Low Latency

for

Page 26: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

WRITES Replicated continuously to 3 AZ’s

Persisted to disk (custom SSD)

READS Strongly or eventually consistent

No latency trade-off

Page 27: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Average < 3ms TP90 < 4.5ms

server-side latency across all APIs

Page 28: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Act Two

Using DynamoDB with a mobile application.

Page 29: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Location Aware Apps

Easy geospatial queries on DynamoDB, with the Geospatial library.

Small domain specific language for location aware apps.

Page 30: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Geo Library for DynamoDB

• Available as a Java JAR file

• Create geospatial data items in DynamoDB – latitude and a longitude

– attribute-value pairs maintained by the application

• The library takes care of creating and maintaining the hash keys, range keys, and indexes that allow for fast and efficient execution of location-based queries

Page 31: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Set Up The Library

Use a table called geo-table:

Page 32: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

[GeoPoint] data type

• Create points of Interest

• Store a latitude and a longitude

• Write points to DynamoDB using [putPoint] method

Page 33: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

[queryRectangle] method

• Locate all of the items that fall within a pair of GeoPoints

that define a rectangle as projected onto a sphere

Page 34: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

[queryRadius] method

Locate all of the items that are within a given radius

Page 35: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Behind The Scenes?

• Creates a virtual grid that overlays the planet

• Each grid cell has an address that is derived from the location of the cell.

• When GeoPoints are inserted into DynamoDB, a geohash is computed and

used to map the data record to the correct grid cell.

• The library stores each item's geohash as an item attribute.

• The hash preserves the proximity of nearby points and makes for efficient

retrieval; it is stored as a local secondary index on the items.

• When you issue a radial or rectangular query via the library, a list of

candidate cells is constructed and used to form the DynamoDB query.

• The library post-processes the resulting items and returns those which are

within the specified bounding box or radius.

Page 36: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

iOS Sample Code

Find Yourself example application.

Documentation, library and sample

source code, and more are available

on GitHub:

https://github.com/awslabs/dynamodb-geo

Page 37: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Push Notifications

High scale, personalized notifications for your apps.

Page 38: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Mobile push notifications engage customers when your app

is not currently active.

• Users opt-in to receive them

• Delivered to a specific app

on a specific device

• Short messages: read, ignore, or

acknowledge to launch the app

Page 39: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Your cloud application directs mobile push notifications to

a specific app on a specific device

Cloud App Mobile Apps

Page 40: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Notifications are delivered via platform-specific push

services, which keep connections with their devices.

Cloud App Mobile Apps

Platform

Service

Page 41: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Developers manage tokens for each device, and must

proactively swap or disable them based on feedback.

Platform

Service

Token Registration

Token

Feedback

Page 42: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Each platform-specific push service works differently.

Apple APNS

Google GCM

Amazon ADM

• Different APIs

• Different Features

• Different Feedback

Page 43: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Push notifications get even more complex as you scale to

support millions of devices.

Cloud App

Platform Services Mobile Apps

Page 44: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Developers use intermediaries to abstract platform-specific

APIs and manage tokens for millions of apps.

Mobile Apps Push Intermediary

Page 45: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Developers use intermediaries to abstract platform-specific

APIs and manage tokens for millions of apps.

Abstraction so your app

can engage users on

any platform

Manage tokens to

ensure messages are

delivered reliably

Operational complexity

Scalability takes work

Cost – even though the

platform services

themselves are free

Page 46: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Amazon SNS Mobile Push is a managed, scalable, cross-

platform push intermediary service.

Amazon SNS

Mobile Push

Apple Devices

Google Devices

Amazon Kindle Fire Devices

Page 47: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Amazon SNS Mobile Push is a managed, scalable, cross-

platform push intermediary service.

Amazon SNS

Mobile Push

Apple Devices

Google Devices

Amazon Kindle Fire Devices

DynamoDB for

device ARNs

Page 48: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Apple

Kindle

Fire

Kindle

Fire

Google

Publish

You can send a distinct payload for each platform, or

publish one common message for all platforms.

Specify Platform-Specific Payloads

Apple

Kindle

Fire

Kindle

Fire

Google

Publish

Publish Once, Deliver Anywhere

Page 49: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

You can publish unique messages to individual devices, or

broadcast identical messages to many devices at once.

Publish

Publish

Publish

Publish

Direct Publishing Broadcast with SNS Topics

Page 50: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

SNS consumes feedback from each platform and manages

swapping and disabling tokens on your behalf.

Amazon SNS

Mobile Push Token

Registration

Token

Feedback

Cloud App

+

DynamoDB

• Write to one

stable endpoint

per device

• You can access

the feedback, but

you don’t have to

do so in order to

use SNS

Page 51: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

SNS offers easy scalability, so you can just start sending

more messages as your app achieves scale.

• Go from a few messages to hundreds of millions

• Go from a few devices to hundreds of millions

...without provisioning, configuring or managing

...without sacrificing reliable, durable delivery

Page 52: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Act Three

Next steps, free stuff and getting started

Page 53: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Extensive set of SDK and IDE support enables you to build

applications tailored to your language or platform.

SDKs for your preferred platform and language…

…integrated into your preferred IDE

Eclipse Visual Studio CLI Powershell

Android iOS Java nodeJS .NET PHP Python Ruby

Page 54: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Free tier

aws.amazon.com/free

Page 55: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Free tier

Free DynamoDB tables!

100Mb of storage

10 units of read capacity

5 units of write capacity

aws.amazon.com/free

Page 56: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

SNS Mobile Push

1 Million Free per Month • 1 million publishes + 1 million mobile push notifications

$1.00 per Million Thereafter • $0.50 per million publishes + $0.50 per million mobile push deliveries

• When you broadcast with SNS Topics, your effective price can be lower

Page 57: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

The console makes it easy to get started with

SNS Mobile Push, and easy to migrate existing apps.

• One simple workflow to create apps on any platform

• Upload or paste in exactly the credentials you receive from each platform

• Easily migrate an existing application by batch-uploading existing tokens

Page 58: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Three things

1. An introduction to DynamoDB

2. Using DynamoDB with a mobile application

3. Next steps, free stuff and getting started

Page 59: AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB

Thank you!

[email protected]