The Personalization Service is a key-value storage service for frontend applications for end-user-specific data. It can be thought of as a browser local storage but shared between clients across multiple devices

Personalization Service

Overview

The Personalization Service is a key-value storage service for frontend applications for end-user-specific data. It can be thought of as a browser local storage but shared between clients across multiple devices. Some supported use-cases:

  • User preferences

  • User profile data

  • Favorites

  • Usage history

  • Playback progress

Personalization Service is a managed multi-tenant service. Personalization Service works together with the User Service and extends its capabilities.

Personalization Service C4 Container Diagram
Figure 1. Personalization Service C4 Container Diagram

Data Model

Personalization Service stores key-value pairs. Keys have one of the three scopes:

  • User

  • Profile (one user can have multiple profiles)

  • Application (multiple frontend applications can store their settings for the same users and profiles)

The key is a string. The value can be a primitive type (string, number, boolean), a JSON, or an array.

Internally, MongoDB is used to store the data.

Interfaces

Personalization Service exposes two APIs:

  • Data API - generic set/get/delete kind of interface

  • Progress API - special asynchronous interface to support the playback progress use case

Both APIs are based on GraphQL.

Data API

Data API provides the general methods for manipulating the key-value pairs:

  • Set key

  • Get key

  • Delete key

For arrays there are additional methods to avoid overwriting the whole array to add/remove a single element:

  • Array push

  • Array get

  • Array remove

Progress API

Progress API provides an efficient solution to a specific use case - playback progress.

This use case is relevant for any video playback solution. We would like to store end-users’s playback progress for each video they started to watch. To achieve this, they frontend (player) periodically sends its current playback position. The server stores the latest reported position and provides upon request.

The main issue with this use case is - numerous requests to the service, because the player may want to send the progress frequently (e.g. every second). With a high number of clients, the service faces serious load.

Progress API provides these specialized methods to track the playback progress:

  • Set progress

  • Get progress

  • Delete progress

Progress API does not write directly to the database, but uses an intermediate Redis cache and a sophisticated queueing algorithm. Progress API takes advantage of a last-value queue, which only retains the last value (indeed, only the last value for the playback progress is relevant).

Authentication & Authorization

All API methods expect a JWT bearer token issued by the User Service.

Personalization Service shall be enabled on a specific environment before it can be used.

Billing

The service fee follows the tiered model depending on the number of end-users whose data is stored. See Mosaic Pricing for more details.