SlideShare a Scribd company logo
1 of 32
Download to read offline
A Cassandra Data Model for Serving up Cat Videos 
Luke Tillman (@LukeTillman) 
Language Evangelist at DataStax
Who are you?! 
•Evangelist with a focus on the .NET Community 
•Long-time Developer 
•Recently presented at Cassandra Summit 2014 with Microsoft 
•Very Recent Denver Transplant 
2
1 
What is this KillrVideo thing you speak of? 
2 
Know Thy Data and Thy Queries 
3 
Denormalize All the Things 
4 
Building Healthy Relationships 
5 
Knowing Your Limits 
3
What is this KillrVideo thing you speak of? 
4
KillrVideo, a Video Sharing Site 
•Think a YouTube competitor 
–Users add videos, rate them, comment on them, etc. 
–Can search for videos by tag
See the Live Demo, Get the Code 
•Live demo available at http://www.killrvideo.com 
–Written in C# 
–Live Demo running in Azure 
–Open source: https://github.com/luketillman/killrvideo-csharp 
•Interesting use case because of different data modeling challenges and the scale of something like YouTube 
–More than 1 billion unique users visit YouTube each month 
–100 hours of video are uploaded to YouTube every minute 
6
Just How Popular are Cats on the Internet? 
7 
http://mashable.com/2013/07/08/cats-bacon-rule-internet/
Just How Popular are Cats on the Internet? 
8 
http://mashable.com/2013/07/08/cats-bacon-rule-internet/
Know Thy Data and Thy Queries
Getting to Know Your Data 
•What things do I have in the system? 
•What are the relationships between them? 
•This is your conceptual data model 
•You already do this in the RDBMS world
Some of the Entities and Relationships in KillrVideo 
11 
User 
id 
firstname 
lastname 
email 
password 
Video 
id 
name 
description 
location 
preview_image 
tags 
features 
Comment 
comment 
id 
adds 
timestamp 
posts 
timestamp 
1 
n 
n 
1 
1 
n 
n 
m 
rates 
rating
Getting to Know Your Queries 
•What are your application’s workflows? 
•How will I access the data? 
•Knowing your queries in advance is NOT optional 
•Different from RDBMS because I can’t just JOIN or create a new indexes to support new queries 
12
Some Application Workflows in KillrVideo 
13 
User Logs into site 
Show basic information about user 
Show videos added by a user 
Show comments posted by a user 
Search for a video by tag 
Show latest videos added to the site 
Show comments for a video 
Show ratings for a video 
Show video and its details
Some Queries in KillrVideo to Support Workflows 
14 
Users 
User Logs into site 
Find user by email address 
Show basic information about user 
Find user by id 
Comments 
Show comments for a video 
Find comments by video (latest first) 
Show comments posted by a user 
Find comments by user (latest first) 
Ratings 
Show ratings for a video 
Find ratings by video
Some Queries in KillrVideo to Support Workflows 
15 
Videos 
Search for a video by tag 
Find video by tag 
Show latest videos added to the site 
Find videos by date (latest first) 
Show video and its details 
Find video by id 
Show videos added by a user 
Find videos by user (latest first)
Denormalize All the Things
Breaking the Relational Mindset 
•Disk is cheap now 
•Writes in Cassandra are FAST 
•Many times we end up with a “table per query” 
•Take advantage of atomic batches to write to multiple tables 
•Similar to materialized views from the RDBMS world 
17
Users – The Relational Way 
•Single Users table with all user data and an Id Primary Key 
•Add an index on email address to allow queries by email 
User Logs into site 
Find user by email address 
Show basic information about user 
Find user by id
Users – The Cassandra Way 
User Logs into site 
Find user by email address 
Show basic information about user 
Find user by id 
CREATE TABLE user_credentials ( 
email text, 
password text, 
userid uuid, 
PRIMARY KEY (email) 
); 
CREATE TABLE users ( 
userid uuid, 
firstname text, 
lastname text, 
email text, 
created_date timestamp, 
PRIMARY KEY (userid) 
);
Videos Everywhere! 
20 
Show video and its details 
Find video by id 
Show videos added by a user 
Find videos by user (latest first) 
CREATE TABLE videos ( 
videoid uuid, 
userid uuid, 
name text, 
description text, 
location text, 
location_type int, 
preview_image_location text, 
tags set<text>, 
added_date timestamp, 
PRIMARY KEY (videoid) 
); 
CREATE TABLE user_videos ( 
userid uuid, 
added_date timestamp, 
videoid uuid, 
name text, 
preview_image_location text, 
PRIMARY KEY (userid, 
added_date, videoid) 
) 
WITH CLUSTERING ORDER BY ( 
added_date DESC, 
videoid ASC);
Videos Everywhere! 
Considerations When Duplicating Data 
•Can the data change? 
•How likely is it to change or how frequently will it change? 
•Do I have all the information I need to update duplicates and maintain consistency? 
21 
Search for a video by tag 
Find video by tag 
Show latest videos added to the site 
Find videos by date (latest first)
Building Healthy Relationships
Modeling Relationships – Collection Types 
•Cassandra doesn’t support JOINs, but your data will still have relationships (and you can still model that in Cassandra) 
•One tool available is CQL collection types 
CREATE TABLE videos ( 
videoid uuid, 
userid uuid, 
name text, 
description text, 
location text, 
location_type int, 
preview_image_location text, 
tags set<text>, 
added_date timestamp, 
PRIMARY KEY (videoid) 
);
Modeling Relationships – Client Side Joins 
24 
CREATE TABLE videos ( 
videoid uuid, 
userid uuid, 
name text, 
description text, 
location text, 
location_type int, 
preview_image_location text, 
tags set<text>, 
added_date timestamp, 
PRIMARY KEY (videoid) 
); 
CREATE TABLE users ( 
userid uuid, 
firstname text, 
lastname text, 
email text, 
created_date timestamp, 
PRIMARY KEY (userid) 
); 
Currently requires query for video, followed by query for user by id based on results of first query
Modeling Relationships – Client Side Joins 
•What is the cost? Might be OK in small situations 
•Do NOT scale 
•Avoid when possible 
25
Modeling Relationships – Client Side Joins 
26 
CREATE TABLE videos ( 
videoid uuid, 
userid uuid, 
name text, 
description text, 
... 
user_firstname text, 
user_lastname text, 
user_email text, 
PRIMARY KEY (videoid) 
); 
CREATE TABLE users_by_video ( 
videoid uuid, 
userid uuid, 
firstname text, 
lastname text, 
email text, 
PRIMARY KEY (videoid) 
); 
or
Modeling Relationships – Client Side Joins 
•Remember the considerations when you duplicate data 
•What happens if a user changes their name or email address? 
•Can I update the duplicated data? 
27
Knowing Your Limits
Cassandra Rules Can Impact Your Design 
•Video Ratings – use counters to track sum of all ratings and count of ratings 
•Counters are a good example of something with special rules 
CREATE TABLE videos ( 
videoid uuid, 
userid uuid, 
name text, 
description text, 
... 
rating_counter counter, 
rating_total counter, 
PRIMARY KEY (videoid) 
); 
CREATE TABLE video_ratings ( 
videoid uuid, 
rating_counter counter, 
rating_total counter, 
PRIMARY KEY (videoid) 
);
Single Nodes Have Limits Too 
•Latest videos are bucketed by day 
•Means all reads/writes to latest videos are going to same partition (and thus the same nodes) 
•Could create a hotspot 
30 
Show latest videos added to the site 
Find videos by date (latest first) 
CREATE TABLE latest_videos ( yyyymmdd text, added_date timestamp, videoid uuid, name text, preview_image_location text, PRIMARY KEY (yyyymmdd, added_date, videoid) ) WITH CLUSTERING ORDER BY ( added_date DESC, videoid ASC );
Single Nodes Have Limits Too 
•Mitigate by adding data to the Partition Key to spread load 
•Data that’s already naturally a part of the domain 
–Latest videos by category? 
•Arbitrary data, like a bucket number 
–Round robin at the app level 
31 
Show latest videos added to the site 
Find videos by date (latest first) 
CREATE TABLE latest_videos ( 
yyyymmdd text, 
bucket_number int, 
added_date timestamp, 
videoid uuid, 
name text, 
preview_image_location text, 
PRIMARY KEY ( 
(yyyymmdd, bucket_number) 
added_date, videoid) 
) ...
Questions? 
32 
Follow me on Twitter for updates or to ask questions later: @LukeTillman

More Related Content

Recently uploaded

Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Recently uploaded (20)

Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

A Cassandra Data Model for Serving up Cat Videos (from Cassandra Day Denver 2014)

  • 1. A Cassandra Data Model for Serving up Cat Videos Luke Tillman (@LukeTillman) Language Evangelist at DataStax
  • 2. Who are you?! •Evangelist with a focus on the .NET Community •Long-time Developer •Recently presented at Cassandra Summit 2014 with Microsoft •Very Recent Denver Transplant 2
  • 3. 1 What is this KillrVideo thing you speak of? 2 Know Thy Data and Thy Queries 3 Denormalize All the Things 4 Building Healthy Relationships 5 Knowing Your Limits 3
  • 4. What is this KillrVideo thing you speak of? 4
  • 5. KillrVideo, a Video Sharing Site •Think a YouTube competitor –Users add videos, rate them, comment on them, etc. –Can search for videos by tag
  • 6. See the Live Demo, Get the Code •Live demo available at http://www.killrvideo.com –Written in C# –Live Demo running in Azure –Open source: https://github.com/luketillman/killrvideo-csharp •Interesting use case because of different data modeling challenges and the scale of something like YouTube –More than 1 billion unique users visit YouTube each month –100 hours of video are uploaded to YouTube every minute 6
  • 7. Just How Popular are Cats on the Internet? 7 http://mashable.com/2013/07/08/cats-bacon-rule-internet/
  • 8. Just How Popular are Cats on the Internet? 8 http://mashable.com/2013/07/08/cats-bacon-rule-internet/
  • 9. Know Thy Data and Thy Queries
  • 10. Getting to Know Your Data •What things do I have in the system? •What are the relationships between them? •This is your conceptual data model •You already do this in the RDBMS world
  • 11. Some of the Entities and Relationships in KillrVideo 11 User id firstname lastname email password Video id name description location preview_image tags features Comment comment id adds timestamp posts timestamp 1 n n 1 1 n n m rates rating
  • 12. Getting to Know Your Queries •What are your application’s workflows? •How will I access the data? •Knowing your queries in advance is NOT optional •Different from RDBMS because I can’t just JOIN or create a new indexes to support new queries 12
  • 13. Some Application Workflows in KillrVideo 13 User Logs into site Show basic information about user Show videos added by a user Show comments posted by a user Search for a video by tag Show latest videos added to the site Show comments for a video Show ratings for a video Show video and its details
  • 14. Some Queries in KillrVideo to Support Workflows 14 Users User Logs into site Find user by email address Show basic information about user Find user by id Comments Show comments for a video Find comments by video (latest first) Show comments posted by a user Find comments by user (latest first) Ratings Show ratings for a video Find ratings by video
  • 15. Some Queries in KillrVideo to Support Workflows 15 Videos Search for a video by tag Find video by tag Show latest videos added to the site Find videos by date (latest first) Show video and its details Find video by id Show videos added by a user Find videos by user (latest first)
  • 17. Breaking the Relational Mindset •Disk is cheap now •Writes in Cassandra are FAST •Many times we end up with a “table per query” •Take advantage of atomic batches to write to multiple tables •Similar to materialized views from the RDBMS world 17
  • 18. Users – The Relational Way •Single Users table with all user data and an Id Primary Key •Add an index on email address to allow queries by email User Logs into site Find user by email address Show basic information about user Find user by id
  • 19. Users – The Cassandra Way User Logs into site Find user by email address Show basic information about user Find user by id CREATE TABLE user_credentials ( email text, password text, userid uuid, PRIMARY KEY (email) ); CREATE TABLE users ( userid uuid, firstname text, lastname text, email text, created_date timestamp, PRIMARY KEY (userid) );
  • 20. Videos Everywhere! 20 Show video and its details Find video by id Show videos added by a user Find videos by user (latest first) CREATE TABLE videos ( videoid uuid, userid uuid, name text, description text, location text, location_type int, preview_image_location text, tags set<text>, added_date timestamp, PRIMARY KEY (videoid) ); CREATE TABLE user_videos ( userid uuid, added_date timestamp, videoid uuid, name text, preview_image_location text, PRIMARY KEY (userid, added_date, videoid) ) WITH CLUSTERING ORDER BY ( added_date DESC, videoid ASC);
  • 21. Videos Everywhere! Considerations When Duplicating Data •Can the data change? •How likely is it to change or how frequently will it change? •Do I have all the information I need to update duplicates and maintain consistency? 21 Search for a video by tag Find video by tag Show latest videos added to the site Find videos by date (latest first)
  • 23. Modeling Relationships – Collection Types •Cassandra doesn’t support JOINs, but your data will still have relationships (and you can still model that in Cassandra) •One tool available is CQL collection types CREATE TABLE videos ( videoid uuid, userid uuid, name text, description text, location text, location_type int, preview_image_location text, tags set<text>, added_date timestamp, PRIMARY KEY (videoid) );
  • 24. Modeling Relationships – Client Side Joins 24 CREATE TABLE videos ( videoid uuid, userid uuid, name text, description text, location text, location_type int, preview_image_location text, tags set<text>, added_date timestamp, PRIMARY KEY (videoid) ); CREATE TABLE users ( userid uuid, firstname text, lastname text, email text, created_date timestamp, PRIMARY KEY (userid) ); Currently requires query for video, followed by query for user by id based on results of first query
  • 25. Modeling Relationships – Client Side Joins •What is the cost? Might be OK in small situations •Do NOT scale •Avoid when possible 25
  • 26. Modeling Relationships – Client Side Joins 26 CREATE TABLE videos ( videoid uuid, userid uuid, name text, description text, ... user_firstname text, user_lastname text, user_email text, PRIMARY KEY (videoid) ); CREATE TABLE users_by_video ( videoid uuid, userid uuid, firstname text, lastname text, email text, PRIMARY KEY (videoid) ); or
  • 27. Modeling Relationships – Client Side Joins •Remember the considerations when you duplicate data •What happens if a user changes their name or email address? •Can I update the duplicated data? 27
  • 29. Cassandra Rules Can Impact Your Design •Video Ratings – use counters to track sum of all ratings and count of ratings •Counters are a good example of something with special rules CREATE TABLE videos ( videoid uuid, userid uuid, name text, description text, ... rating_counter counter, rating_total counter, PRIMARY KEY (videoid) ); CREATE TABLE video_ratings ( videoid uuid, rating_counter counter, rating_total counter, PRIMARY KEY (videoid) );
  • 30. Single Nodes Have Limits Too •Latest videos are bucketed by day •Means all reads/writes to latest videos are going to same partition (and thus the same nodes) •Could create a hotspot 30 Show latest videos added to the site Find videos by date (latest first) CREATE TABLE latest_videos ( yyyymmdd text, added_date timestamp, videoid uuid, name text, preview_image_location text, PRIMARY KEY (yyyymmdd, added_date, videoid) ) WITH CLUSTERING ORDER BY ( added_date DESC, videoid ASC );
  • 31. Single Nodes Have Limits Too •Mitigate by adding data to the Partition Key to spread load •Data that’s already naturally a part of the domain –Latest videos by category? •Arbitrary data, like a bucket number –Round robin at the app level 31 Show latest videos added to the site Find videos by date (latest first) CREATE TABLE latest_videos ( yyyymmdd text, bucket_number int, added_date timestamp, videoid uuid, name text, preview_image_location text, PRIMARY KEY ( (yyyymmdd, bucket_number) added_date, videoid) ) ...
  • 32. Questions? 32 Follow me on Twitter for updates or to ask questions later: @LukeTillman