New ScyllaDB sample app: video streaming

We’ve recently published a new ScyllaDB sample app for video streaming. The app uses NextJS (with Blitz.jS) and Material-UI on the frontend with ScyllaDB Cloud serving requests on the backend.

Have a look at the repo, and see how ScyllaDB can be used to build a low-latency video streaming application with modern web tools like NextJS.

Video streaming database schema used in the project:

CREATE KEYSPACE IF NOT EXISTS streaming WITH replication = { 'class': 'NetworkTopologyStrategy', 'replication_factor': '3' };

CREATE TABLE streaming.video (
    id TEXT,
    content_type TEXT,
    title TEXT,
    url TEXT,
    thumbnail TEXT,
    created_at TIMESTAMP,
    PRIMARY KEY (id, created_at)
);

CREATE TABLE streaming.watch_history (
	user_id UUID,
	video_id TEXT,
	progress INT,
	watched_at TIMESTAMP,
	PRIMARY KEY (user_id, video_id)
);

Clone the repo!

Hello, I need a similar scheme, but in the user history there will be 1000 records per day, that is, 350,000 records per year. I saw that in cassandra it is undesirable to have more than 100,000 entries per partition. Can I leave the same scheme in scylladb or do I need to add a “bucket” column, say, by month?

Hi @dobermangood ,

As long as all the nodes have roughly the same amount of data you should be good to go. I’d suggest using some kind of ID as the partitioning key and another ID and/or the timestamp column as the clustering key depending on your queries. I’m happy to give feedback if you provide the schema you’re planning to use.

CREATE TABLE tests (
id timeuuid,
user_id uuid,
status text,
created_at timestamp,
some_info…,
PRIMARY KEY (id)
);

CREATE TABLE user_tests (
user_id uuid,
test_id timeuuid,
status text,
created_at timestamp,
some_info…,
PRIMARY KEY (user_id, created_at)
) WITH CLUSTERING ORDER BY(created_at DESC);

Q1: select * from user_tests where user_id = ? limit 30;
Q2: select * from user_tests where user_id = ? and created_at < ? and created_at > ? limit 30;

And user_tests potentially may be 1000 per day, and need to store it for years.

Yes that schema with those queries should work really well!

1 Like