Showcasing HawkCDN - Affordable P2P CDN technology

Comments 3

Beware This post is more than 3 years old, it may be outdated or incorrect! Please check elsewhere for accurate information!

Distributing video on the web is not easy, especially when you want to control the whole experience. Well, now there is a way to self publish video content without significant infrastructure costs!

What is HawkCDN?

HawkCDN is the name of my implementation of a Peer-to-Peer Content Delivery Network based on WebTorrent and VideoJS, for distributing pseudo-streaming audio-visual content on the web.

Traditionally, when you published content on the Web, you would use a single server that would send content to users, for example a video or audio file. Later, smart people figured out that it’s better to have one source of the content but store it in multiple places and route the user to the closest place that has the file they want – the CDN approach.

Torrents, on the other hand, have no central point where content is hosted, and is instead uploaded by everybody who also downloads the content. In the beginning it starts with an initial seeder, that send the content to users that want it, but as more and more people get the file, they also start sending the content to new users that don’t have the content but want it.

HawkCDN, and similar WebTorrent-based solutions, use a hybrid approach, where the content is initially hosted on a central web server, but as people start downloading it they also upload the content they already have downloaded to other users, similar to BitTorrent technology.

Where can I see a demo?

You can see a live demo here, serving TPB: AFK movie from a single Kimsufi server without any accelerators like Cloudflare.

How much does it cost to run?

To run a Hawk-enabled host, all you need is a dedicated server with a moderate amount of storage and at least 100Mbps upload connection for optimal performance. With OVH/Kimsufi, that would cost you around 15€ per month.

How many users can it handle?

The more the better – take for example a 720p 1.5Mbps video. With the traditional model, you could have up to 65 users simultaneously streaming with a single 100Mbps server. However, with HawkCDN, you could have a few thousand users streaming, because users would be uploading to each other and sharing the load of the server.

It’s hard to say how many users exactly could be handled, but I would say at the very least 50 times as many users as with traditional delivery methods.

What are the disadvantages?

The disadvantages of this technology is that it doesn’t work with Internet Explorer and requires at least Safari 10, and has limited support on iOS and Android.

How do I use this new tech?

It’s simple! Create a torrent from a file, add a web seed to it and link to it from a page.

Step 1: Setup the server

You will need a Linux Ubuntu 16.04 or newer server with installed Apache2 and SSL support (get a free certificate with Let’s Encrypt!).

First, download this file and place it in the webroot named “.htaccess” to allow Cross-Origin requests.

Enable modules rewrite and headers with: a2enmod rewrite headers && service apache2 restart

Install Node and NPM with: apt install nodejs npm && ln -s /usr/bin/nodejs /usr/bin/node

Step 2: Install Create-Torrent

npm install -g create-torrent

Step 3: Obtain a video file

You will need a H.264+AAC MP4 file with MOOV atom moved to the beginning of the file (so-called “-movflags +faststart” in ffmpeg). Place the file in the webroot and name it a name without spaces or special characters (so only A-Z a-z 0-9 - _).

Step 4: Create a torrent

create-torrent --urlList "" video.mp4 -o video.torrent

Replace “” with your site’s URL and video path and “video.mp4” and “video.torrent” with the video name and torrent name.

You should get a torrent file in the current directory, ready for streaming.

Step 5: Create a player web page

<!DOCTYPE html>
	<meta charset="utf-8" />
	<script src=""></script>
	var torrentId = '';
	var client = new WebTorrent();
	client.add(torrentId, function (torrent) {

Replace “” with the URL to the torrent file and save the file in the webroot as video.html.

Step 6: You’re done!

Open video.html ( in the browser and you will see the video begin to stream. If there are multiple users connected, it will stream from the users first and then from the server.

I need help!

If you don’t understand the instructions or need help, you can contact me in the comments below and I will help you set up everything on your server.


Comments (3)

Please be civil when commenting. Think before writing, don't spam, self promote, bully, harass or harm anyone. Please read the Comment Policy before posting. Comments are moderated.

le wen

le wen

torrent can't be played in ios.
How to add a mp4 file player,When the user uses the ios device.

Reply · 4 years ago · #40

Milan Kragujevic

...replying to le wen

Milan Kragujevic Admin

contact me via Skype for a price on the custom package. milankragujevic on Skype.

Reply · 4 years ago · #41

Max Petrov

Max Petrov

Milan is there any way to do this with JW7 player ?

Reply · 4 years ago · #14

Scroll to top