Overview
Not only do streamers want to keep a high view count, but they also want to maintain a high-quality stream to ensure the viewing experience is enjoyable for their audience. There are numerous metrics to keep track of when sustaining a stable live stream. One of the most common metrics is how long the stream was frozen. Streamers and viewers do not want a stream frozen for long as it disrupts the experience. In this tutorial, you will learn how to monitor live stream metrics, such as video quality and view count, using RisingWave. We have set up a demo cluster for this tutorial so you can easily try it out.Prerequisites
- Ensure you have Docker and Docker Compose installed in your environment. Note that Docker Compose is included in Docker Desktop for Windows and macOS. If you use Docker Desktop, ensure it is running before launching the demo cluster.
- Ensure that the PostgreSQL interactive terminal,
psql, is installed in your environment. For detailed instructions, see Download PostgreSQL.
Step 1: Launch the demo cluster
In the demo cluster, we packaged RisingWave and a workload generator. The workload generator will start to generate random traffic and feed them into Kafka as soon as the cluster is started. First, clone the risingwave repository to the environment.integration_tests/livestream directory and start the demo cluster from the docker compose file.
Step 2: Connect RisingWave to data streams
Now that we have set up the data stream in Kafka (in JSON) using the demo cluster, we can connect to the streams with the following SQL statement. The data contains information regarding the video streaming metrics as well as the unique viewers of each stream.Step 3: Create materialized views
In this tutorial, we will create different materialized views that keep track of the video streaming performance and the viewer count.Set up materialized view for live stream performance
The first materialized view will summarize the streaming performance for each stream every 10 minutes. To create it, we will use the tumble function to map each event into a 10-minute window and aggregate based on each room to calculate how long the stream was frozen, the average number of packets lost per second, and the average round-trip time.Set up materialized view for view counts
Next, we will set up two materialized views to keep track of view counts. The first materialized view will track the number of unique viewers on the entire streaming site every minute. We will use the tumble function to map each event into a one-minute window and count the number of distinct viewers within each time window.Summary
In this tutorial, we learn:- How to analyze video streaming metrics.
- How to set up a real-time dashboard to keep track of the number of unique viewers.