Skip to main content

P2P Optimization


The performance results depend on a number of factors including time to live edge, bitrates offered, encoding profiles, ISPs served, audience geographical distribution, end-user device capacities, etc.

The configuration of m3u8(or mpd) 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.
  • segment duration: 3 seconds to 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:

To activate range requests, you should enable OPTIONS requests, and range requests on both origin of your stream and CDN: #### OPTIONS REQUESTS (Required for Web) 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: (only needed for web SDK)

Access-Control-Allow-Methods: GET, OPTIONS


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

Access-Control-Allow-Headers: Range

Example for NGINX

add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Allow-Origin' '*';
add_header Accept-Ranges bytes;
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;

Example for NIMBLE

Open your config file (Usually located at /etc/nimble/nimble.conf), add the following lines at the bottom of the file:

access_control_allow_origin = *
access_control_expose_headers = Content-Length
access_control_allow_headers = Range

Save the file and restart the nimble service using this command: sudo service nimble restart

Web SDK Optimization Tip

Android SDK Optimization Tip

Deploy Super Peer

See here for details