SlideShare a Scribd company logo
1 of 47
Download to read offline
Dynamo DB
Indexes
Nathan Jones
Principal Engineer @ Centrapay
~15 Years Building Enterprise Software
Oracle, Postgres, Mongo DB, MySQL, Firebase
~16 Months Architecting Centrapay Platform
Dynamo DB
_ncjones
ncjones
nathan-c-jones
We unlock better ways for businesses and
consumers to connect, engage and pay.
Digital Assets & Payments
“Spend anything anywhere”
~70% NZ payment terminals now QR code enabled
centrapay.com
1. Core Concepts
2. Indexes
3. 10 Patterns for Success
Contents
Core Concepts
✔ Launched 2012
✔ Schemaless
✔ Serverless
✔ Atomic Writes
✔ Highly Scalable
✘ Reporting
✘ Search
Dynamo DB
Cassandra Firebase
Developer Experience cf.
Mongo
Dynamo DB
Users
User
Id: 543
Name: Isaac
User
Id: 856
Name: Matthew
Table
Item
Item
Max 400KB
Max 400KB
Unbounded
Items + Tables
Partition Key
ID = PK + SK
(Optional)
Sort Key
“Hash Attribute” “Range Attribute”
Item Identification
Users
User
PK Id: 543
Name: Isaac
User
PK Id: 856
Name: Matthew
Item Identification: PK
Item Identification: PK + SK
User Prefs
User Pref
PK UserId: 543
SK Name: email-alerts
Value: true
User Pref
PK UserId: 543
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 543
SK Name: email-frequency
Value: weekly
Replace or Reject
Item Identification: Collision
User Prefs
User Pref
PK UserId: 543
SK Name: email-alerts
Value: true
User Pref
PK UserId: 543
SK Name: email-frequency
Value: daily
Users
User Pref
PK UserId: 543
SK Type: UserPref#email-alerts
Value: true
User
PK UserId: 543
SK Type: User
Name: Isaac
Heterogeneous Tables
Queries
Find PK = 543
User Prefs
User Pref
PK UserId: 543
SK Name: email-alerts
Value: true
User Pref
PK UserId: 543
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 543
SK Name: session-ttl
Value: true
Queries
User Prefs
User Pref
PK UserId: 543
SK Name: email-alerts
Value: true
User Pref
PK UserId: 543
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 543
SK Name: session-ttl
Value: true
Find PK = 543
and SK = session-ttl
User Prefs
User Pref
PK UserId: 543
SK Name: email-alerts
Value: true
User Pref
PK UserId: 543
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 543
SK Name: session-ttl
Value: true
Find PK = 543
and SK starts with email
Queries
User Prefs Table
Partitions
Partition 2
User Pref
PK UserId: 543
SK Name: email-alerts
Value: true
Partition 1 Partition 3
User Pref
PK UserId: 856
SK Name: email-alerts
Value: true
User Pref
PK UserId: 543
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 856
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 238
SK Name: email-alerts
Value: true
User Pref
PK UserId: 238
SK Name: email-frequency
Value: daily
User Pref
PK UserId: 945
SK Name: email-alerts
Value: true
Request Router
...
hash(PK) → Partition ID
Read / Write Request PK
Partition 2
Partition 1 Partition N
Partitions
Max
Capacity
Partition 1 Partition 2 Partition 3 Partition 4
Write: 1000WCU
Read: 3000RCU
Capacity
Exceeded!
Read/Write Capacity
Partition
Leader
Replica Replica
Partition
Leader
Replica Replica
Partition
Leader
Replica Replica
Write Request
AZ 2 AZ 3
AZ 1
Replication
User Prefs (ap-southeast-1)
User Prefs (us-west-1)
Async Replication
User Pref
PK UserId: 543
SK Name: session-ttl
Value: true
User Pref
PK UserId: 543
SK Name: session-ttl
Value: true
��
��
Global Tables
Indexes
User
Id: 543
Name: Isaac
User
Id: 238
Name: Nathan
User
Id: 945
Name: Raymond
User
Id: 856
Name: Matthew
543
238
945
856
Index Records
Id = 856? Id = 856?
🏎
Indexed Query
O(log n)
🐢
Scan
O(n)
Indexes 101
Partition Key (PK)
Sort Key (SK)
Projected Attributes
🔐 Permissions
🐘 Read/Write Capacity
Dynamo Index Anatomy
+
Type Identifying Consistency
Primary ✔ Strongly Consistent
Global
Secondary
✘ Eventually Consistent
Local
Secondary
✘ Strongly Consistent
Dynamo Index Types
✔ Identifying
✔ Strongly Consistent
Primary Index
User
Device
Session
SessionId 123
UserId 945
DeviceId 1342
Created 2021-07-14
Expires 2021-07-15 Id 1342
Description iPhone X
Id 945
Name Raymond
Primary Index: Example
Session
Index: Get Session by Id
Partition Key Session Id
Sort Key n/a
Projected Attributes All
PK SessionId 123
UserId 945
DeviceId 1342
Created 2021-07-14
Expires 2021-07-15
Primary Index: Example
✔ Non Identifying
✔ Eventually Consistent
Global Secondary Index (GSI)
Session
Index: Get Sessions by Device Id
Partition Key Device Id
Sort Key Created Date
Projected Attributes UserId, SessionId
PK SessionId 123
UserId 945
PK DeviceId 1342
SK Created 2021-07-14
Expires 2021-07-15
Global Secondary Index: Example
Primary Index Partition Global Secondary Index Partition
Session
PK SessionId: 123
UserId: 945
DeviceId: 1342
Created: 2021-07-14
Expires: 2021-07-15
Session
SessionId: 123
UserId: 945
PK DeviceId: 1342
SK Created: 2021-07-14
Async Replication
<1s Normally
GSI Eventual Consistency
✔ Non Identifying
✔ Strongly Consistent
Local Secondary Index
🤔 Share PK with Primary Index
🙁 Max 10GB
😧 No adding to existing table
😧 No partition rebalancing
Local Secondary Index
10 Patterns for Success
User Pref
PK pk User#945
SK sk Pref#email-frequency
value daily
User Pref
PK UserId 945
SK Name email-frequency
value daily
✔
1. Generic Primary PK, SK
Customer
PK pk Customer#10034
SK sk #Customer
orgId 687
Customer
PK pk Org#687
SK sk Customer#10034
orgId 687
✔
2. Immutable Primary PK
Order
PK pk Order#10034
SK sk #Order
PK orgId 687
status waiting
updatedAt 2021-07-28T10:00:00Z
SK
sk.status.
updatedAt
waiting#2021-07-28T10:00:00Z
select * from Order
where
orgId = "687" and
status = "waiting"
order by updatedAt;
✔
3. Computed Secondary Keys
Order
PK pk Order#23043
SK sk #Order
PK orgId 687
status waiting
updatedAt 2021-07-28T10:00:00Z
SK
sk.status.
updatedAt
waiting#2021-07-28T10:00:00Z
Order
PK pk Order#23043
SK sk #Order
PK orgId 687
status processed
updatedAt 2021-07-28T10:01:05Z
SK
sk.status.
updatedAt
✔
(DELETED)
(Sparse Index)
4. Delete Keys to Drop from GSI
Unique User Handle
PK pk UserHandle#rayray
SK sk #Unique
User
PK pk User#945
SK sk #User
handle rayray
✔
5. Unique Constraints
Atomic Transaction
User Version
User
PK pk User#945
SK sk #User
version 2
PK pk User#945
SK sk Version#2
✔
Atomic Transaction
6. Optimistic Locking
Customer
PK pk Customer#f9c82a6b-7b7a-4d6f-bc48-8fffc88fc78b
SK sk #Customer
orgId bb7ecd0f-f856-499b-9fdf-7d4b058a2b3b
✔
7. Random IDs
��
��
��
��
��
��
��
��
��
��
8. Understand Access Patterns
Import Job
PK pk Job#250688
SK sk #ImportJob
PK status pending
SK createdAt 2021-07-23T10:00:01
Import Job
PK pk Job#250688
SK sk #ImportJob
status pending
statusShard 15
PK pk.status pending.15
SK createdAt 2021-07-23T10:00:01
✔
(RANDOM / HASHED)
9. Use “Shard” PK Suffix
10. Scripted Data Migrations
Conclusion
🔑 Choose keys for indexes carefully
💕 Use heterogeneous tables and multi-item transactions
⚖ Distribute partition load evenly
Official Best Practices
https://docs.aws.amazon.com/amazondynamodb/latest/develope
rguide/best-practices.html
Official Blogs
Dynamic Shards:
https://aws.amazon.com/blogs/database/choosing-the-right-num
ber-of-shards-for-your-large-scale-amazon-dynamodb-table
Adaptive Capacity:
https://aws.amazon.com/blogs/database/how-amazon-dynamod
b-adaptive-capacity-accommodates-uneven-data-access-pattern
s-or-why-what-you-know-about-dynamodb-might-be-outdated/
Important Resources
Alex DeBrie
Data Modelling:
https://www.youtube.com/watch?
v=DIQVJqiSUkE
🔥🔥🔥👍👍👍
Partitions:
https://www.alexdebrie.com/post
s/dynamodb-partitions/
Centrapay is Hiring
https://www.linkedin.com/company/centrapay/jobs/
We are always on the lookout for
talented individuals to join our team.
Lead Software Engineer

More Related Content

Similar to Dynamo DB Indexes

Netflix - Realtime Impression Store
Netflix - Realtime Impression Store Netflix - Realtime Impression Store
Netflix - Realtime Impression Store Nitin S
 
Google File System
Google File SystemGoogle File System
Google File Systemguest2cb4689
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External AuthenticationJason Terpko
 
Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...
Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...
Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...HostedbyConfluent
 
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...Andrew Liu
 
JDD2015: Make your world event driven - Krzysztof Dębski
JDD2015: Make your world event driven - Krzysztof DębskiJDD2015: Make your world event driven - Krzysztof Dębski
JDD2015: Make your world event driven - Krzysztof DębskiPROIDEA
 
2013 04-29-evolution of backend
2013 04-29-evolution of backend2013 04-29-evolution of backend
2013 04-29-evolution of backendWooga
 
Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...
Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...
Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...ScyllaDB
 
Keeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETLKeeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETLDatabricks
 
Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...
Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...
Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...confluent
 
Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...
Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...
Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...DevOpsDays Tel Aviv
 
What is Apache Kafka and What is an Event Streaming Platform?
What is Apache Kafka and What is an Event Streaming Platform?What is Apache Kafka and What is an Event Streaming Platform?
What is Apache Kafka and What is an Event Streaming Platform?confluent
 
Zeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions ScaleZeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions ScaleScyllaDB
 
Zeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions ScaleZeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions ScaleSaurabh Verma
 
Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...
Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...
Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...Databricks
 
MongoDB World 2019: MongoDB Implementation at T-Mobile
MongoDB World 2019: MongoDB Implementation at T-MobileMongoDB World 2019: MongoDB Implementation at T-Mobile
MongoDB World 2019: MongoDB Implementation at T-MobileMongoDB
 
LendingClub RealTime BigData Platform with Oracle GoldenGate
LendingClub RealTime BigData Platform with Oracle GoldenGateLendingClub RealTime BigData Platform with Oracle GoldenGate
LendingClub RealTime BigData Platform with Oracle GoldenGateRajit Saha
 
Degrading Performance? You Might be Suffering From the Small Files Syndrome
Degrading Performance? You Might be Suffering From the Small Files SyndromeDegrading Performance? You Might be Suffering From the Small Files Syndrome
Degrading Performance? You Might be Suffering From the Small Files SyndromeDatabricks
 

Similar to Dynamo DB Indexes (20)

Netflix - Realtime Impression Store
Netflix - Realtime Impression Store Netflix - Realtime Impression Store
Netflix - Realtime Impression Store
 
Google File System
Google File SystemGoogle File System
Google File System
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External Authentication
 
Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...
Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...
Change Data Capture Pipelines with Debezium and Kafka Streams (Gunnar Morling...
 
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
 
JDD2015: Make your world event driven - Krzysztof Dębski
JDD2015: Make your world event driven - Krzysztof DębskiJDD2015: Make your world event driven - Krzysztof Dębski
JDD2015: Make your world event driven - Krzysztof Dębski
 
Spark on Yarn @ Netflix
Spark on Yarn @ NetflixSpark on Yarn @ Netflix
Spark on Yarn @ Netflix
 
Producing Spark on YARN for ETL
Producing Spark on YARN for ETLProducing Spark on YARN for ETL
Producing Spark on YARN for ETL
 
2013 04-29-evolution of backend
2013 04-29-evolution of backend2013 04-29-evolution of backend
2013 04-29-evolution of backend
 
Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...
Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...
Scylla Summit 2018: Joining Billions of Rows in Seconds with One Database Ins...
 
Keeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETLKeeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETL
 
Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...
Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...
Building Scalable and Extendable Data Pipeline for Call of Duty Games (Yarosl...
 
Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...
Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...
Large Scale NoSql DB Migration Under Fire - Ido Barkan - DevOpsDays Tel Aviv ...
 
What is Apache Kafka and What is an Event Streaming Platform?
What is Apache Kafka and What is an Event Streaming Platform?What is Apache Kafka and What is an Event Streaming Platform?
What is Apache Kafka and What is an Event Streaming Platform?
 
Zeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions ScaleZeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions Scale
 
Zeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions ScaleZeotap: Moving to ScyllaDB - A Graph of Billions Scale
Zeotap: Moving to ScyllaDB - A Graph of Billions Scale
 
Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...
Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...
Building a Versatile Analytics Pipeline on Top of Apache Spark with Mikhail C...
 
MongoDB World 2019: MongoDB Implementation at T-Mobile
MongoDB World 2019: MongoDB Implementation at T-MobileMongoDB World 2019: MongoDB Implementation at T-Mobile
MongoDB World 2019: MongoDB Implementation at T-Mobile
 
LendingClub RealTime BigData Platform with Oracle GoldenGate
LendingClub RealTime BigData Platform with Oracle GoldenGateLendingClub RealTime BigData Platform with Oracle GoldenGate
LendingClub RealTime BigData Platform with Oracle GoldenGate
 
Degrading Performance? You Might be Suffering From the Small Files Syndrome
Degrading Performance? You Might be Suffering From the Small Files SyndromeDegrading Performance? You Might be Suffering From the Small Files Syndrome
Degrading Performance? You Might be Suffering From the Small Files Syndrome
 

Recently uploaded

Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...SUHANI PANDEY
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...nilamkumrai
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...SUHANI PANDEY
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...tanu pandey
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
 

Recently uploaded (20)

Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 

Dynamo DB Indexes

  • 2. Nathan Jones Principal Engineer @ Centrapay ~15 Years Building Enterprise Software Oracle, Postgres, Mongo DB, MySQL, Firebase ~16 Months Architecting Centrapay Platform Dynamo DB _ncjones ncjones nathan-c-jones
  • 3. We unlock better ways for businesses and consumers to connect, engage and pay. Digital Assets & Payments “Spend anything anywhere” ~70% NZ payment terminals now QR code enabled centrapay.com
  • 4. 1. Core Concepts 2. Indexes 3. 10 Patterns for Success Contents
  • 6. ✔ Launched 2012 ✔ Schemaless ✔ Serverless ✔ Atomic Writes ✔ Highly Scalable ✘ Reporting ✘ Search Dynamo DB
  • 8. Users User Id: 543 Name: Isaac User Id: 856 Name: Matthew Table Item Item Max 400KB Max 400KB Unbounded Items + Tables
  • 9. Partition Key ID = PK + SK (Optional) Sort Key “Hash Attribute” “Range Attribute” Item Identification
  • 10. Users User PK Id: 543 Name: Isaac User PK Id: 856 Name: Matthew Item Identification: PK
  • 11. Item Identification: PK + SK User Prefs User Pref PK UserId: 543 SK Name: email-alerts Value: true User Pref PK UserId: 543 SK Name: email-frequency Value: daily
  • 12. User Pref PK UserId: 543 SK Name: email-frequency Value: weekly Replace or Reject Item Identification: Collision User Prefs User Pref PK UserId: 543 SK Name: email-alerts Value: true User Pref PK UserId: 543 SK Name: email-frequency Value: daily
  • 13. Users User Pref PK UserId: 543 SK Type: UserPref#email-alerts Value: true User PK UserId: 543 SK Type: User Name: Isaac Heterogeneous Tables
  • 14. Queries Find PK = 543 User Prefs User Pref PK UserId: 543 SK Name: email-alerts Value: true User Pref PK UserId: 543 SK Name: email-frequency Value: daily User Pref PK UserId: 543 SK Name: session-ttl Value: true
  • 15. Queries User Prefs User Pref PK UserId: 543 SK Name: email-alerts Value: true User Pref PK UserId: 543 SK Name: email-frequency Value: daily User Pref PK UserId: 543 SK Name: session-ttl Value: true Find PK = 543 and SK = session-ttl
  • 16. User Prefs User Pref PK UserId: 543 SK Name: email-alerts Value: true User Pref PK UserId: 543 SK Name: email-frequency Value: daily User Pref PK UserId: 543 SK Name: session-ttl Value: true Find PK = 543 and SK starts with email Queries
  • 17. User Prefs Table Partitions Partition 2 User Pref PK UserId: 543 SK Name: email-alerts Value: true Partition 1 Partition 3 User Pref PK UserId: 856 SK Name: email-alerts Value: true User Pref PK UserId: 543 SK Name: email-frequency Value: daily User Pref PK UserId: 856 SK Name: email-frequency Value: daily User Pref PK UserId: 238 SK Name: email-alerts Value: true User Pref PK UserId: 238 SK Name: email-frequency Value: daily User Pref PK UserId: 945 SK Name: email-alerts Value: true
  • 18. Request Router ... hash(PK) → Partition ID Read / Write Request PK Partition 2 Partition 1 Partition N Partitions
  • 19. Max Capacity Partition 1 Partition 2 Partition 3 Partition 4 Write: 1000WCU Read: 3000RCU Capacity Exceeded! Read/Write Capacity
  • 21. User Prefs (ap-southeast-1) User Prefs (us-west-1) Async Replication User Pref PK UserId: 543 SK Name: session-ttl Value: true User Pref PK UserId: 543 SK Name: session-ttl Value: true �� �� Global Tables
  • 23. User Id: 543 Name: Isaac User Id: 238 Name: Nathan User Id: 945 Name: Raymond User Id: 856 Name: Matthew 543 238 945 856 Index Records Id = 856? Id = 856? 🏎 Indexed Query O(log n) 🐢 Scan O(n) Indexes 101
  • 24. Partition Key (PK) Sort Key (SK) Projected Attributes 🔐 Permissions 🐘 Read/Write Capacity Dynamo Index Anatomy +
  • 25. Type Identifying Consistency Primary ✔ Strongly Consistent Global Secondary ✘ Eventually Consistent Local Secondary ✘ Strongly Consistent Dynamo Index Types
  • 26. ✔ Identifying ✔ Strongly Consistent Primary Index
  • 27. User Device Session SessionId 123 UserId 945 DeviceId 1342 Created 2021-07-14 Expires 2021-07-15 Id 1342 Description iPhone X Id 945 Name Raymond Primary Index: Example
  • 28. Session Index: Get Session by Id Partition Key Session Id Sort Key n/a Projected Attributes All PK SessionId 123 UserId 945 DeviceId 1342 Created 2021-07-14 Expires 2021-07-15 Primary Index: Example
  • 29. ✔ Non Identifying ✔ Eventually Consistent Global Secondary Index (GSI)
  • 30. Session Index: Get Sessions by Device Id Partition Key Device Id Sort Key Created Date Projected Attributes UserId, SessionId PK SessionId 123 UserId 945 PK DeviceId 1342 SK Created 2021-07-14 Expires 2021-07-15 Global Secondary Index: Example
  • 31. Primary Index Partition Global Secondary Index Partition Session PK SessionId: 123 UserId: 945 DeviceId: 1342 Created: 2021-07-14 Expires: 2021-07-15 Session SessionId: 123 UserId: 945 PK DeviceId: 1342 SK Created: 2021-07-14 Async Replication <1s Normally GSI Eventual Consistency
  • 32. ✔ Non Identifying ✔ Strongly Consistent Local Secondary Index
  • 33. 🤔 Share PK with Primary Index 🙁 Max 10GB 😧 No adding to existing table 😧 No partition rebalancing Local Secondary Index
  • 34. 10 Patterns for Success
  • 35. User Pref PK pk User#945 SK sk Pref#email-frequency value daily User Pref PK UserId 945 SK Name email-frequency value daily ✔ 1. Generic Primary PK, SK
  • 36. Customer PK pk Customer#10034 SK sk #Customer orgId 687 Customer PK pk Org#687 SK sk Customer#10034 orgId 687 ✔ 2. Immutable Primary PK
  • 37. Order PK pk Order#10034 SK sk #Order PK orgId 687 status waiting updatedAt 2021-07-28T10:00:00Z SK sk.status. updatedAt waiting#2021-07-28T10:00:00Z select * from Order where orgId = "687" and status = "waiting" order by updatedAt; ✔ 3. Computed Secondary Keys
  • 38. Order PK pk Order#23043 SK sk #Order PK orgId 687 status waiting updatedAt 2021-07-28T10:00:00Z SK sk.status. updatedAt waiting#2021-07-28T10:00:00Z Order PK pk Order#23043 SK sk #Order PK orgId 687 status processed updatedAt 2021-07-28T10:01:05Z SK sk.status. updatedAt ✔ (DELETED) (Sparse Index) 4. Delete Keys to Drop from GSI
  • 39. Unique User Handle PK pk UserHandle#rayray SK sk #Unique User PK pk User#945 SK sk #User handle rayray ✔ 5. Unique Constraints Atomic Transaction
  • 40. User Version User PK pk User#945 SK sk #User version 2 PK pk User#945 SK sk Version#2 ✔ Atomic Transaction 6. Optimistic Locking
  • 41. Customer PK pk Customer#f9c82a6b-7b7a-4d6f-bc48-8fffc88fc78b SK sk #Customer orgId bb7ecd0f-f856-499b-9fdf-7d4b058a2b3b ✔ 7. Random IDs
  • 43. Import Job PK pk Job#250688 SK sk #ImportJob PK status pending SK createdAt 2021-07-23T10:00:01 Import Job PK pk Job#250688 SK sk #ImportJob status pending statusShard 15 PK pk.status pending.15 SK createdAt 2021-07-23T10:00:01 ✔ (RANDOM / HASHED) 9. Use “Shard” PK Suffix
  • 44. 10. Scripted Data Migrations
  • 45. Conclusion 🔑 Choose keys for indexes carefully 💕 Use heterogeneous tables and multi-item transactions ⚖ Distribute partition load evenly
  • 46. Official Best Practices https://docs.aws.amazon.com/amazondynamodb/latest/develope rguide/best-practices.html Official Blogs Dynamic Shards: https://aws.amazon.com/blogs/database/choosing-the-right-num ber-of-shards-for-your-large-scale-amazon-dynamodb-table Adaptive Capacity: https://aws.amazon.com/blogs/database/how-amazon-dynamod b-adaptive-capacity-accommodates-uneven-data-access-pattern s-or-why-what-you-know-about-dynamodb-might-be-outdated/ Important Resources Alex DeBrie Data Modelling: https://www.youtube.com/watch? v=DIQVJqiSUkE 🔥🔥🔥👍👍👍 Partitions: https://www.alexdebrie.com/post s/dynamodb-partitions/
  • 47. Centrapay is Hiring https://www.linkedin.com/company/centrapay/jobs/ We are always on the lookout for talented individuals to join our team. Lead Software Engineer