FarbaCDN — a p2p Content Delivery Network

Anton Lakhtikov
5 min readOct 13, 2020

--

A Content Delivery Network (CDN) is a geographically distributed network of proxy servers. The goal is to provide high availability and performance by distributing the service spatially relative to end-users [1].

By Kanoha — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=7868809
Fig.1 (Left) Single server distribution (Right) CDN scheme of distribution

Regular CDN providers own or rent all infrastructure. There are no untrusted parts in their system.

FarbaCDN is a p2p network for website owners in need of CDN service. Anyone can participate in the system. As a result, the site owners can deliver their static web content throughout the distributed network of other peers 5x less expensively than the regular CDN.

A site owner can set up a FarbaCDN peer node. It could be a Virtual Private Server (VPS) or a dedicated server. We provide a software bundle (a Docker container) with all settings in place. The setup process is a one-time activity and doesn’t require subsequent manual interaction. When the peer node serves someone else’s content, the owner of the node “earns” traffic and can “spend” this traffic serving his or her content throughout the distributed network of other peers. We will charge a fraction of the “earned” traffic from each peer and sell this traffic to those who either don’t want to be a peer or who consume more traffic than they are able to “earn”.

How to use

A site owner should do 2 things:

  1. Add the FarbaCDN javascript file [2] to the HTML document:
<script src="https://farbacdn.github.io/farba-public/build/farbacdn.min.js"></script>

2. Change tags for all objects delivered via our Network. Simply add the farba class and replace the src attribute with data-src :

<img class="farba" data-src="/uploads/FullSky_WMAP_2048W.png"/>

There is no need to rewrite your DNS records, and you can easily opt-in and out of the Network. FarbaCDN can work in parallel with existing CDN/AntiDDOS providers, so you don’t have to change your infrastructure.

Backend model

Here is how the participants of this process interact with each other:

Fig.2 Backend model

Our model has 4 different roles: the User, the Original Server, the Balancer, and the Peer.

When the User opens a web page from the Original Server, our FarbaCDN javascript sends a request to a Balancer. The Balancer sends back a JSON reply with vital information:

  • The location of the file within the Farba Network
  • The size of the file
  • The cryptographic digest of the file
Fig.3 JSON reply

Now the FarbaCDN script knows the new location of the requested file and can make an XMLHttpRequest download call. Because the requested file comes from an untrusted source, the next step is to verify the integrity of the file. The script calculates the hash sum and compares it to the digest from the JSON reply. If both sums are equal, the script shows the downloaded file to the User. If the sums are not equal, the script sends a new GET request to the Original Server. This means that the User will receive the file in any case.

In order to download a file from an untrusted source, a W3C standard defines an integrity property of the resource [3]. Unfortunately this property was implemented for the <script> and <link> tags only, for everything else, we have to use JavaScript on the client side.

Demo

You can view a live demo on our website. There, you can open a Developer Console to find out how the FarbaCDN system actually works:

http://farbacdn.com/farbacdn-example.html

Fig.4 Demo page

Beta test

Now we are happy to announce an open beta test. Currently, we don’t accept third-party Peers and emulate the backend part ourselves, but you can run FarbaCDN with your website and see how our technology works. If you are willing to participate, please specify what domain name you are going to use and shoot us an email at betatest@farbacdn.com. We will perform a manual onboarding and send you a confirmation back with API keys for cache invalidation.

FarbaCDN has 8 points of presence in the US (SFO, LAX, Dallas, Atlanta, Miami, New York, Chicago, Seattle), 1 in Europe, and 6 in Russia.

Beta test limits

  • No adult content(!)
  • PNG and JPEG images only
  • The maximum image size is 3 MB
  • The minimum image size is 80x80 pixels
  • 1 TB of bandwidth per account (soft limit)
  • 100 GB of bandwidth per day per account (soft limit)
  • 500 images per account (soft limit)

If you need more than any of the indicated soft limits, please send us an email. We want to be ready for any kind of extra load.

FAQ

Q: How do you validate content?
A: We use cloud AI to detect adult or violent content and do sampling manual checks.

Q: How much “earned” traffic are you going to charge?
A: WIP

Q: I need more traffic. What is the price?
A: WIP

Q: Why does it make sense to be a peer?
A: Regular CDN providers usually charge $10–$120 per TB:

Fig.5 CDN prices overview

When you buy a VPS, 1 TB of bandwidth costs $5 (Vultr, DigitalOcean, Linode). When you buy a dedicated server, 1 TB costs $2 (OVH, Leaseweb, Cogent).

--

--