P2P Streaming Engine

vuePress-theme-reco    2018 - 2021
P2P Streaming Engine P2P Streaming Engine

Choose mode

  • dark
  • auto
  • light
Documents
  • Introduction
  • Web SDK

    • Hls.js
    • Dash.js
    • Shaka-Player
    • MP4
    • Downloader
  • Android SDK
  • iOS SDK
  • Flutter SDK
Pricing
Contact Us
Partnership
Console
GitHub
语言
  • English
  • 简体中文

Documents
  • Introduction
  • Web SDK

    • Hls.js
    • Dash.js
    • Shaka-Player
    • MP4
    • Downloader
  • Android SDK
  • iOS SDK
  • Flutter SDK
Pricing
Contact Us
Partnership
Console
GitHub
语言
  • English
  • 简体中文
  • Introduction
  • FAQ
  • Tracking Service
  • Signaling Service
  • P2P Optimization
    • Introduction
    • Recommended m3u8 Config for live
    • Allow Http Range Request
  • Console

    • Domain/AppId Binding
    • Data Analysis
    • P2P Control
    • Restful API
  • Hls.js SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • CDN
    • Change Log
  • Android SDK

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • iOS SDK

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • Flutter SDK

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • Shaka-Player SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • Change Log
  • Web MP4 SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • Change Log
  • Dash.js SDK

    • Introduction
    • Usage
    • Player Integration
    • API & Config
    • Change Log
  • Web Downloader

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • Android SDK 1.x

    • Introduction
    • Usage
    • API & Config
    • Change Log
  • More

    • Design

P2P Optimization

vuePress-theme-reco    2018 - 2021

P2P Optimization


# Introduction

The configuration of m3u8 and hls.js(mpd and dash.js) will have a great impact on the P2P streaming. The proper configuration can significantly increase the P2P ratio. It is not recommended to use multi-bitrate m3u8/mpd.

# Recommended m3u8 Config for live

  • segment duration: <= 4 seconds
  • number of segment in playlist: >= 10

Example for NGINX:

rtmp {
    server {
        ...
        
        application show {
            ...
            
            hls_fragment 4;                # 4 seconds fragments
            hls_playlist_length 60;        # 60 seconds playlist
            
        }
    }
}

# Allow Http Range Request

Range requests are used to get only a part of a file from the server (for instance, if part of the segment has been downloaded from peer, we retrieve the other part from the CDN). By using range requests you maximize the potential of our P2P technology. Without range requests, it is not possible to take advantage of chunks of media coming from P2P and if the segment is not downloaded as a whole, this data would be considered useless. If range request is activated, we are able to get chunks of data from peer and then complete the segments by getting other chunks from the CDN, thus, reducing your CDN bandwidth. Below is an example that shows how much CDN bandwidth is saved when range requests were activated:
http-range
To activate range requests, you should enable OPTIONS requests, and range requests on both origin of your stream and CDN:

# OPTIONS REQUESTS

OPTIONS requests are mandatory to be able to perform RANGE requests in a cross-domain environment.

Your server/CDN must be able to handle OPTIONS requests. Most web-servers handle it natively.

The general idea is to add the following header to the HTTP response:

Access-Control-Allow-Methods: GET, OPTIONS

# RANGE REQUESTS

The general idea is to add the following header to the HTTP response:

Access-Control-Allow-Headers: Range