Developing a cloud backend for a streaming service
The Viasat group of companies holds a leading position among commercial (non-state) paid TV holdings in terms of audience share (Source: Mediascope, TV Index+, Total day; Total Ind., December - January 2021, Share%). The majority owner of the joint venture, which distributes and develops the broadcasting of Viasat TV channels, is the National Media Group, which owns 80% of the joint venture. The remaining 20% belongs to the Baring Vostok fund.
Viasat owns 13 popular paid TV channels, including TV1000, TV1000 Action, a package of ViP TV channels (ViP Premiere, ViP Serial, ViP Megahit, ViP Comedy, and others), as well as the streaming service Viju.
The Viju streaming service (launched in 2022) provides users with access to a large number of movies and series of foreign and domestic production, as well as all TV channels of the Viasat group of companies. A considerable number of exclusive film premieres generate wide interest among viewers, but this, in turn, increases the load on the video service. In this regard, it became necessary to develop a cloud-based backend for the streaming platform so that it can work stably, even in periods of high demand.
The Challenge: Service with a twist
Viasat had several basic requirements for the backend of the service:
- Readiness for heavy loads
- Stable work with streaming partners
- Clear admin panel for site editors
A special feature of the project is kinoms — short fragments of films and series. They help the viewer quickly get a better idea of the film and its mood than they would with a trailer or description.
Evrone joined the development team at the start of the project. We focused on proven video content management systems and cloud solutions for video services, and we also tried to automate current administration as much as possible in order to minimize the human factor. In addition, we had to solve the challenge of creating kinoms.
Cloud solution for video streaming
Viju is a cloud-native Kubernetes application. To manage the cluster, we use GitOps, and we declare its desired state through the Git repository. This allows you to automate and simplify its operation. To manage the environment, we chose the Yandex.Cloud platform with a ready-made service for Kubernetes clusters. Their product turned out to be the most convenient, since it provides the Terraform API out of the box. This allows you to avoid spending time and effort on writing separate code to manage the infrastructure, and you can immediately apply the Infrastructure as Code approach.
To facilitate further work on the end-to-end video streaming solution, we have transferred the distribution of the project to Docker images. This allows it to be quickly deployed and scaled in any environment and on any device.
In order for the kinoms to work correctly, we had to come up with a number of solutions. Together with the Viasat Tech development team, we:
- Set up caching on the CDN side to make embedded videos load faster
- Expanded the functionality of the admin panel
- Brought watermark management and transcoding to the backend
The current plan is to switch the service to the CDN API. Rather than cutting a lot of videos from the source and storing them all, this will allow us to get only the necessary piece of video from the source file, in the form of a chunklist by time range, via the API.
Order in the database and clean code
This is a large, long-term project, so we need to think about IT infrastructure optimization to ensure that the streaming service will work and be supported in the future. Therefore, we regularly clean the backlog and refactor the code. We maintain order with the dry-rb stack. And, of course, we test a lot. Now, more than 60% of the code is covered with tests.
The base is highly structured. We made a single model in it, which is divided by data type. We know exactly where the desired film and all additional content for it is located: trailers, posters, photos, stills used to generate thumbnails, etc. All user-generated content is also sorted automatically.
Partner API for streaming service
We also had to address issues involving digital rights management and implement best practices for content security. Viasat owns the rights to high-profile and high-grossing projects, such as the series House of Cards, The Handmaid's Tale, and Chucky. But in addition to being featured on Viasat’s own platform, they are also leased to partner services.
So we needed to increase security and control access to content through encrypted streaming and video security features, while still allowing partners access to leased content. To do this, we implemented a separate API. Now partners can not only receive content but also create users with access to Viju through their platforms. Also, through the API, we receive encrypted data about users of partner services, so Viju recognizes the user who watched its content on a partner service and is able to recommend movies and TV programs in a more targeted way.
Authorization and registration are divided into separate requests. Authorization (via social networks on the web version) works on the server side, so the frontend processes less logic.
In addition, we set up user authorization and authentication using JSON Web Token. It helps the service recognize the user when the primary access token expires. At the same time, the refresh token lifetime is much longer, so the user has to log in less often. Paired tokens also increase the security of the project.
We also did some work on debugging payment services. For example, we made it possible to pay for a subscription with several cards. We also refactored subscriptions through IOS and Android. We have distributed data from the AppStore and PlayMarket and streamlined renewal of subscriptions in each case.
We are grateful for the opportunity to partner with Viasat to build a video streaming app architecture that meets their customers’ needs. After our work, the service has become more convenient and innovative and can compete with other market players. We are looking forward to continuing our work with the Viju team to further improve the content distribution network.
Are you looking for a team to build a live streaming app with Python? Do you need developers who can custom build a server-side video streaming app? Leave us a message using the form below, and we will be in touch soon to see how we can help make your project better.