Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

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:// udp:// udp:// udp:// udp:// wss:// wss:// wss://

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

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.


WebTorrent CDN with graceful degradation








No releases published


No packages published