Join this session to learn about serverless architectures, their benefits, and the basics of the AWS Serverless stack (e.g., AWS Lambda, Amazon API Gateway, and AWS Step Functions). We will discuss how to use serverless architectures for a variety of use cases. Learn practical tips, tricks, and take-home architecture patterns to implement immediately.
20. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
bossDB
• Neuroscience data storage service
• Resilient, multi-tier cloud data storage
& data caching
• Scalable, highly available RESTful
interfaces; load balancing
• User authentication / authorization
through SSO
• API with numerous core services,
supported clients, integrated tools
• Data Annotation (e.g., supervoxel objects)
• Data Visualization
• Data Access Services (e.g., images, objects,
volumetric, metadata)
• Data Ingest (e.g., image stack, volumetric)
21. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
bossDB Sponsors
IARPA MICrONS
Machine Intelligence from
Cortical Networks
• Seeks to revolutionize
machine learning
• Reverse-engineering the
algorithms of the brain
NIH bossDB
Neuroscience Community
Data Ecosystem
• A cloud-based data
ecosystem
• Electron microscopy,
X-ray microtomography
22. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Johns Hopkins University / Applied Physics Laboratory
• Division of Johns Hopkins University
• University Affiliated Research Center
• Founded in 1942
• Laurel, MD Campus
• > 6,000 staff
• Government sponsors:
23. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
bossDB - Blocks
• Block and Object Storage Service (“boss”)
• “Block” is multi-dimensional data (cuboid) created from several image tiles
24. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
bossDB - Objects
• bossDB stores annotation data co-registered to image data
• An annotation is a unique 64-bit identifier applied to a set of voxels, representing
its spatial distribution or “Object”
ID: 1267
ID: 345345
ID: 534534799
26. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
How we use serverless technologies
• Tasks that only run periodically
• Error Reporting
• Managing Servers
Lambda
DynamoDB
Amazon SQS Step Function
Amazon S3
Amazon SNS
27. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Specific examples
• High speed ingest
• Downsample
• Management of HashiCorp’s Vault and Consul Servers
28. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Generic high speed ingest
• 16 Images (tiles) are converted to 3D Blocks of data called cuboids
DynamoDB
Cuboid Index
S3 Cuboid
29. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
High speed ingest by the numbers
• Ingest can be started at any hour by use
• Scale up between 2GB to 2PB of data for an Ingest
• Clients bandwidth should be limiting factor
30. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client Cuboid
Bucket
Cuboid
Index
• Goal - populate cuboids into S3
and DynamoDB
31. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Tile
Index
Tile
Bucket
Cuboid
Bucket
Cuboid
Index
• Use temporary storage / index
• Need 16 consecutive tile images
32. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• At start of ingest job, create SQS
Queues and Step Function
33. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Step Function launches Lambdas
• Populates SQS with all tiles
34. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Client gets message
• Uploads requested tile
35. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Client is multithreaded
• Multiple clients can join
36. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Object
Triggered
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• New S3 Object Triggers Lambda
• If 16 tiles – Create Cuboid Ready
37. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Object
Triggered
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Delete tile message from SQS
38. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Object
Triggered
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
Create
Cuboid
• SQS triggers Lambda to create
cuboid
39. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
1st attempt at high speed ingest
Client
Populate
Images
to Upload
Tile
Index
Tile
Bucket
Step Function
Object
Triggered
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
Create
Cuboid
• Lambda is given list of 16 tiles
• Creates cuboid
40. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Problem with triggered lambda deleting messages in SQS
• Concurrent lambda limit can
be reached
• Lambdas throttle and fail to
delete image message
Images
to upload
Tile
Bucket
Object
Triggered
Client
41. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Problem with triggered lambda deleting messages in SQS
• Concurrent lambda limit can
be reached
• Lambdas throttle and fail to
delete image message
• Message becomes visible
• Client repeats work!
Images
to upload
Tile
Bucket
Object
Triggered
Client
42. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Additional problem
• Created DynamoDB Global Secondary Index of Ingest Job ID
• Caused hot-spot in single partition
• Solution append random number 001-100 to the ID
Client Images
to upload
Tile
Index
Tile
Bucket
Object
Triggered
43. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client
Tile
Index
Tile
Bucket
Cuboid
Bucket
Cuboid
Index
44. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client Images
to Upload
Tile
Index
Tile
Bucket
Tile
Queue
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• New SQS Tile Queue
45. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client Images
to Upload
Tile
Index
Tile
Bucket
Tile
Queue
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Client gets message
• Uploads requested tile
46. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client Images
to Upload
Tile
Index
Tile
Bucket
Tile
Queue
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Client creates corresponding
message in Tile Queue
47. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client Images
to Upload
Tile
Index
Tile
Bucket
Tile
Queue
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Client deletes message
48. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client Message
Triggered
Images
to Upload
Tile
Index
Tile
Bucket
Tile
Queue
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
• Message triggers Lambda
49. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Final solution to high speed ingest
Client Message
Triggered
Images
to Upload
Tile
Index
Tile
Bucket
Tile
Queue
Cuboid
Ready
Cuboid
Bucket
Cuboid
Index
Create
Cuboid
• No other changes
• Works when lambdas throttle
50. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Ingest Speeds
Ingest speeds
over
200 GB / min
51. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Heaviside
Python Library and DSL for working with AWS Step Functions
• The Step Function state machine language, while flexible, is hard to
write and maintain
• Heaviside is a Python package that provides several components to
make Step Functions easier to use
• DSL and Compiler – Greatly simplifies writing and maintaining Step Functions
in AWS
• Framework for running Activities
https://github.com/jhuapl-boss/heaviside
52. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Heaviside Example
"""Delete Cuboid
Removes all of the different data related to a given
cuboid,
removes the actual cuboid data, and then cleans up
the final
bookkeeping for the cuboid
"""
parallel:
Activity('delete_metadata')
"""delete_metadata
deletes metadata"""
retry [] 60 4 2.0
parallel:
Activity('delete_id_count')
"""delete_id_count
deletes from dynamodb table idcount"""
retry [] 60 4 2.0
parallel:
Activity('delete_id_index')
"""delete_id_index
deletes from dyanmodb table idindex"""
retry [] 60 4 2.0
Compiles
48 lines
154 lines
Step Function JSON
53. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Downsampling
54. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Downsampled tiles
~2 PB
~512 TB
~128 TB
~32 TB
~8 TB
~2 TB
~0.5 TB
125 GB
Can have 6 – 10 resolution levels
55. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Downsampling by the numbers
• Only downsample 1% of the time
• For a 2PB image dataset downsample could require
• 37 million S3 and DynamoDB writes
• 148 million S3 and DynamoDB reads
• Users can kick these off at any hour of the day
• Serverless Benefit
• Don’t need to keep servers up when workflow is not running
• Can massively scale processing for short periods of time without administrator in the loop
• Don’t need to worry about high availability
56. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Our solution to downsampling
Cuboid
Bucket
Cuboid
Index
AWS Step Functions workflow
Populate
Activity
Downsample
Sets
Downsample
Lambda DLQ
• Downsample Sets
4 -> 1 Populated
57. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Our solution to downsampling
Downsample
Cuboid
Bucket
Cuboid
Index
AWS Step Functions workflow
Populate
Activity
• Step Function
launches Lambdas in
parallel
Downsample
Sets
Downsample
Lambda DLQ
Lambda checker
Activity
58. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Our solution to downsampling
Downsample
Cuboid
Bucket
Cuboid
Index
AWS Step Functions workflow
Populate
Activity
• Lambda gets message
• Creates new cuboid,
merging 4 together
Downsample
Sets
Downsample
Lambda DLQ
Lambda checker
Activity
59. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Our solution to downsampling
Downsample
Cuboid
Bucket
Cuboid
Index
AWS Step Functions workflow
Populate
Activity
• Uses Lambda DLQ to
find errors
Downsample
Sets
Downsample
Lambda DLQ
Lambda checker
Activity
60. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Our solution to downsampling
Downsample
Cuboid
Bucket
Cuboid
Index
AWS Step Functions workflow
Populate
Activity
• Repeat for every
downsample
resolution level
Downsample
Sets
Downsample
Lambda DLQ
Lambda checker
Activity
61. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
If I were to redesign downsample now
Downsample
Cuboid
Bucket
Cuboid
Index
AWS Step Functions workflow
Populate
Activity
Lambda checker
Activity
• Use Event Source
• Can limit concurrent
Lambdas
Event SourceDownsample
Sets
Downsample
Lambda DLQ
62. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Management of HashiCorp’s Vault and Consul servers
• Use Vault and Consul to manage system
secrets
• Consul distributed database need 3 of
the 5 servers up syncing data to
function
• In memory only database
• Cannot allow servers to terminate as could trash
in memory database
• New Vault Servers need to be manual
unsealed
63. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Solution to manage Vault and Consul
VPC
64. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Serverless architecture takeaways
• Easy to connect and coordinate distributed components
and microservices
• Don’t waste resources for task that only run periodically
• High availability without extra resources
• Massively scale on demand
• Diagnose and debug problems faster
65. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Acknowledgements
• Caitlyn Bishop
• Joe Downs
• Conrad Fernandes
• Tim Gion
• Dean Kleissas
• Jordan Matelsky
• Derek Pryor
• Luis Rodiguez
• Will Gray Roncal
• Brock Wester
• Miller Wilt
66. P U B L I C S E C T O R
S U M M I T
P U B L I C S E C T O R
S U M M I T
Project Links
bossDB: github.com/jhuapl-boss
bossDB.org
Heaviside: github.com/jhuapl-boss/Heaviside