How to implement Peer-to-peer (P2P) in OTT video streaming?

P2P Implementation Guide to improve customer viewing experience

tech@TVB
tech@TVB
5 min readMay 2, 2019

--

by Angus Siu and Ricky Lau

Why Peer-to-Peer?

TVB’s myTVSuper OTT video services have millions of customers and the video traffic is tremendously large. Users are very sensitive to streaming experience. That’s the reason why customer viewing experience is always prioritised to enhance. To ensure a stable service, TVB has built its own content distribution network (CDN) infrastructure with more than a hundred video streaming servers spanning in several data centers, together with CDN services provided by partner Internet Service Provider (ISP), and by other CDN service providers as backup. This arrangement provides enough resources for serving the video demand in normal days. However, there are different scenarios that may cause challenges to the service. For example, many people to stay at home bad weather (e.g. typhoon signal no. 8 or above) and many of them may choose to spend the extra holiday with OTT services, so people switch to use OTT services. Sometimes, special events like breaking news, popular sports events, etc., causing a much higher demand of the OTT video services than normal. While we have CDN service providers providing backup CDN service to handle such cases, the cost of such service is high, and those providers may not be able to provide enough resources in a short time when the need arise.

Quality of Experience (QoE) is the key differentiator on streaming platform. Users enjoys the service with optimal starting time and minimum re-buffering events. Peer-to-peer (P2P) is one of the good options to address this point and this is beneficial to both receiving and sending end. Instead of just investing a large sum of money on more video servers and data centers, and more backup CDN services by CDN service providers, we are attracted by a solution with significantly lower cost, using peer-to-peer (P2P) technology. Basically, P2P make use of the fact that in OTT video services, many people may be watching the same content, so instead of every client download the same content from the CDN, clients with content already downloaded can share some of the downloaded content with other clients, reducing the load to the CDN.

By using the characteristics of P2P, clients can receive the contents from its peer or video servers and enjoy the content smoothly.

Architecture with or without using P2P

Without P2P, the clients simply download all the content from video servers (edge servers or servers from CDN service providers).

How P2P implement?

With P2P, the clients would start streaming purely from the video servers first, so the playback can start quickly. And the clients will also contact a set of P2P Control servers to declare its availability as a peer for content sharing, together with Internet connection status like Internet connection speed, etc., and get a list of available peers for the same content. The P2P Control servers would choose the appropriate peers as members of the list of available peers, based on information like the Internet connection speed of the peers, whether the peers are likely under the same ISP, etc. Based on the list of available peers, the clients can then establish connection with the peers and begin getting and sharing content. And the clients will keep update P2P status (like how much content are obtained from video servers and peers, how much content it has shared with peers, connection healthiness with the peers, etc.) with the P2P Control servers, and get updated list of peers from the P2P Control servers.

What should consider when using P2P?

While there can be tremendous offloads of traffic from the video servers using P2P, there are many factors that may affect the effectiveness, and other considerations on whether to implement and how to implement P2P in OTT video services.

P2P sharing would only work well if there are enough customers watching the same content at the same time. So, whether there can be big offloads of traffic from CDN may depend on the popularity of the contents.

And even if people are watching the “same” content, but in the OTT world, the same content may be offer in different formats (HLS, DASH, Smooth Streaming, with different DRM schemes) to support different playback clients, in different bitrates (either fixed bitrates chosen as different quality by the customers, or adaptive bitrates which change automatically according to network condition and playback clients’ decoding power), some OTT video service provider may do server-side Ad insertion or other content replacements for different customers, and some OTT video service provider may also insert watermarks with customer identification. And since many OTT technologies work by dividing the content into segments, and there may be more than one origin responsible for such segmentation process. Each origin may do slightly different segmentation even for the same format and same bitrate. So technically, these produce many different contents from the same content, all the above needed to be handled properly in P2P implementations.

For segment-based OTT technology, the length of segments may affect the P2P effectiveness also, especially in case of live event streaming, as people are likely to be watching the same segment within a short period of time. If the length of the segments are large, it take a client A longer time to completely download a segment from CDN or peer, so the same segment will be available for sharing later, and it may take too long time for yet another peer B getting the complete segment from A (and other peers of B) so it have to fallback to downloading the segment from CDN. But besides reducing the length of segments, which may not be desirable since this affect the buffering performance of the playback client, another way to solve the problem is to enable Range Request in the P2P implementation in the playback client and in the CDN, which means allowing the playback client to only download part of a segment from CDN, and part of the same segment from peers.

There are other considerations, like whether it is easy to integrate with existing players in the playback clients (or need to change to another player), whether to store the downloaded content in RAM or in disk to later share with peers, and P2P means using the customer’s uploading bandwidth which may cause higher bandwidth consumption bills especially on mobile networks, and may use a high portion of available uploading bandwidth affecting performance of other network activities.

If you are excited about video streaming technology, please come and join us via tech@tvb.com. We are hiring!

--

--