Video Streaming Queue a Concurrent Writes Example

We'll cover the following

Consider two users A and B, using the same credentials to log-in to a video streaming service such as YouTube. Let’s assume these two users sit in different geographical locations unaware of each other’s actions. We’ll also assume the service has a single replica to make the example simple. Both users try to add movies for various actors in the queue and their interactions with the service are captured below. Instead of a two user scenario, we could also play the sequence of events for a single user who interacts with the service using two different devices.

  1. User A starts first and adds a movie for Tom Cruise in the queue. The browser sends this update to the backend server which notes the state of the queue [Tom] as version number#1. We’ll use first names of actors in the queue to keep the example simple. Furthermore, the server responds to the client request with the current state of the queue as well as its version. Since the queue was empty to begin with, the state returned by the server is [Tom] and version#1.

Get hands-on with 1200+ tech skills courses.