joystream
joystream copied to clipboard
[DWG] Consider using Cloudflare proxy
One thing I have experimented with is using Cloudflare proxy for my distribution node. In the past I have used gateway.joyutils.org
which was a Cloudflare Worker function that would just proxy the request to my node. Using that has shown big bandwidth gains, but at the same time has increased latency quite a bit. You can find those results in the CDN performance report - https://joystream.notion.site/Joystream-CDN-performance-part-1-c8aff72f95ca4e86866079f81784aacb?pvs=4
Recently I've tried a simpler approach - just enabling Cloudflare proxy at the DNS level. Whenever you add a DNS record through Cloudflare, you have an option of enabling their proxy for that record. As I understand it, when enabled, all the requests are not routed directly to the backend server but rather to the closest Cloudflare data centre and then they use Cloudflare private network for the rest of their travel. This is how the enabled proxy looks like in DNS settings:
You can read more about it in Cloudflare docs: https://developers.cloudflare.com/dns/manage-dns-records/reference/proxied-dns-records/
Here you can see the difference in performance from our synthethic test. Without proxy:
With proxy:
As you can see, the difference in latency is pretty massive. I think we should consider enabling this kind of proxy for some of our distribution nodes.
Things to keep in mind:
- We cannot be over-reliant on Cloudflare - disruption in their services shouldn't be critical to our CDN.
- Requests proxied through Cloudflare would most likely come from their IP addresses which can disrupt our dashboards that gives us an idea of where our users are. We should look into whether we can somehow extract original user IP from the requests.
- Cloudflare can block some users, for example those using Tor network.