aws webcast - build mobile apps with a secure, scalable back end on dynamodb
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
Build Mobile Apps with a Secure,
Scalable Back End on DynamoDB
Matt Wood, General Manager, Data Science
October 10, 2013
Thank you!
Three things
1. An introduction to DynamoDB
2. Using DynamoDB with a mobile application
3. Next steps, free stuff and getting started
Act One
Under the covers of DynamoDB.
Amazon RDS
Amazon
DynamoDB Amazon Redshift
Amazon
ElastiCache
Compute Storage
AWS Global Infrastructure
Database
Application Services
Deployment & Administration
Networking
AWS Database Services
Amazon’s Path to DynamoDB
RDBMS DynamoDB
= Key/value store
Fully Managed
Low Cost
Predictable Performance
Massively Scalable
=
DEVS
OPS
USERS
for
Fast Application
Development
Time to Build New Applications
• Flexible data models • Simple API • High-scale queries • Laptop development
DEVS
OPS
USERS
for
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”
Fast Application
Development
Relationship Modeling
1
Simple API 2
High Scale Query Patterns
3
Tables, Items, Attributes
• A Table is a collection of Items
• An Item is a collection of Attributes
• Attributes have a key and a value
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
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
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
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
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
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
Latest News… DynamoDB Local
• Disconnected development
• Full API support
• Download from http://aws.amazon.com/dynamodb/resources/#testing
DEVS
OPS
USERS
Admin-Free (at any scale)
for
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.”
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
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
DEVS
OPS
USERS Durable Low Latency
for
WRITES Replicated continuously to 3 AZ’s
Persisted to disk (custom SSD)
READS Strongly or eventually consistent
No latency trade-off
Average < 3ms TP90 < 4.5ms
server-side latency across all APIs
Act Two
Using DynamoDB with a mobile application.
Location Aware Apps
Easy geospatial queries on DynamoDB, with the Geospatial library.
Small domain specific language for location aware apps.
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
Set Up The Library
Use a table called geo-table:
[GeoPoint] data type
• Create points of Interest
• Store a latitude and a longitude
• Write points to DynamoDB using [putPoint] method
[queryRectangle] method
• Locate all of the items that fall within a pair of GeoPoints
that define a rectangle as projected onto a sphere
[queryRadius] method
Locate all of the items that are within a given radius
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.
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
Push Notifications
High scale, personalized notifications for your apps.
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
Your cloud application directs mobile push notifications to
a specific app on a specific device
Cloud App Mobile Apps
Notifications are delivered via platform-specific push
services, which keep connections with their devices.
Cloud App Mobile Apps
Platform
Service
Developers manage tokens for each device, and must
proactively swap or disable them based on feedback.
Platform
Service
Token Registration
Token
Feedback
Each platform-specific push service works differently.
Apple APNS
Google GCM
Amazon ADM
• Different APIs
• Different Features
• Different Feedback
Push notifications get even more complex as you scale to
support millions of devices.
Cloud App
Platform Services Mobile Apps
Developers use intermediaries to abstract platform-specific
APIs and manage tokens for millions of apps.
Mobile Apps Push Intermediary
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
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
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
Apple
Kindle
Fire
Kindle
Fire
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
Publish
Publish Once, Deliver Anywhere
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
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
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
Act Three
Next steps, free stuff and getting started
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
Free tier
aws.amazon.com/free
Free tier
Free DynamoDB tables!
100Mb of storage
10 units of read capacity
5 units of write capacity
aws.amazon.com/free
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
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
Three things
1. An introduction to DynamoDB
2. Using DynamoDB with a mobile application
3. Next steps, free stuff and getting started
Thank you!