WebTorrent CDN with graceful degradation
Switch branches/tags
Nothing to show
Clone or download
Latest commit 04c4505 Jul 2, 2017
Failed to load latest commit information.
examples Big file example Jul 2, 2017
namespaced/P2pcdn custom trackers May 13, 2017
.gitignore Big file example Jul 2, 2017
LICENSE.txt custom trackers May 13, 2017
P2p-Cdn.js Average download speed test with big file Jul 2, 2017
P2p-Cdn.php Fixed php compatibility Jun 17, 2017
README.md LOL Jun 27, 2017


P2P-CDN — WebTorrent CDN with graceful degradation

How to use it?

See examples folder, you can try here: look that it's an heavy page with images and video (30MB)!


The LAMP hosting is the most popular choice when you want to public on the Web.

It's cheap and it's fast, but if you want to publish heavy contents like high quality photos, audio or videos with many users could become a problem. Maybe you want to reduce your hosting bill.

This is an easy and accessible (lazy load with graceful degradation) fix: you can stream all your heavy files (PDFs included, see examples!) with much less bandwidth, sharing the bandwidth of your users.

Without Javascript or WebRTC all the contents load normally: it's SEO friendly.

Silicon Valley S04E04 - Teambuilding Exercise

Richard: I read Peter's notes, all of them, and he knew that a peer-to-peer Internet was possible in the future, but he was also basing that on, what, old desktop computers. He never, ever foresaw the ubiquity or power of all of our modern-day smartphones. He was also dealing with a completely different Weissman limit. So... uh, yeah. Yeah. Okay.

Gavin: What is that? Is that number correct?

Richard: The delta in mean device efficiency? Yeah, it is. See, eventually, over time, this will render every server that Hooli operates obsolete, which would make Jack Barker shit himself.

Gavin: Holy shit!

alt text

What is WebTorrent?

BitTorrent over WebRTC (data channels) to stream in the browser.

See WebTorrentFAQ and WebTorrent@GitHub.

Generate the torrent with PHP

Torrent.php used in examples by Adrien Gibrat or... ?

Submit your suggestion!

Torrent announce trackers

Default torrent announce/trackers:

udp://tracker.openbittorrent.com:80 udp://tracker.internetwarriors.net:1337 udp://tracker.leechers-paradise.org:6969 udp://tracker.coppersurfer.tk:6969 udp://exodus.desync.com:6969 wss://tracker.btorrent.xyz wss://tracker.openwebtorrent.com wss://tracker.fastcast.nz

You can setup a private tracker with bittorrent-tracker or what you prefer.

Apache notes

Disabled gzip compression for .mp4 files with

SetOutputFilter DEFLATE

SetEnvIfNoCase Request_URI .mp4$ no-gzip dont-vary

in the .htaccess if you see this error

TODO - wish list

Configurable torrent trackers - done

Configurable torrent endpoint - done

WebRTC Peer-to-peer in Safari 11 (iOS 11) Works



check/enforce Drupal 8 / Symfony 2 coding standard https://www.drupal.org/docs/develop/development-tools/configuring-phpstorm https://www.drupal.org/docs/develop/standards/coding-standards https://confluence.jetbrains.com/display/PhpStorm/Drupal+Development+using+PhpStorm#DrupalDevelopmentusingPhpStorm-CoderandPHPCodeSnifferIntegration

Define and expand compatibility

Explore platforms other than LAMP, maybe Node.js? webtorrent-hybrid

Tests (PHPUnit? Karma? Jasmine?)

Integration with popular frameworks and CMS like Laravel, Symfony, Wordpress and Drupal, plugins and modules

A logo maybe? :P


MIT. Copyright (c) Andrea Paiola.