News for hackers. Stuff that matters.
Re:My Own Private CDN by 1996 on Thursday August 30, 2018 @06:48PM (#17881487)
The main problem is often geoip, and properly using the results of said GeoIP.

Having a dozen of POPs around the world is a trivial weekeend project.

Routing the client to the faster one and scaling up to local demands while optimizing given bandwith price is not trivial. Because not everything is Digital Ocean, for example what about Japan? Or Brazil?

Re:My Own Private CDN by zrail on Thursday August 30, 2018 @07:28PM (#17881718)
Absolutely. This project leans heavily on AWS route53’s latency-based routing. I don’t do the magic, route53 does.
Re:My Own Private CDN by giancarlostoro on Friday August 31, 2018 @07:16AM (#17884557)
I wonder how long till shared hosting or some sort of similar cloud hosting takes off more that handles a lot of this nuance for you. CDN's can really reduce a lot of the heavy burdens that a single server will face which is downloading static files. Not familiar enough with all the things offered on the cloud, just with the few tools I've used so anyone who might already be aware can let me know. I know the author mentions Amazon's Route53 but I'm on about an all-inclusive solution like one would find in shared hosting that could include:

* SSL - Free tier would bring Let's Encrypt SSL Certs by default, the end-user shouldn't even think about how it works or anything of the sort, it should just work. * CDN - no need to even think about how it works, ServerlessCDN type of stuff. * Host any kind of app (maybe some sort of serverless approach or docker, though the less you have to mess with even more dev tools the better) * Intuitive admin panel for when SHTF with detailed logging.

I'm surprised we're still stuck in the era of CPANEL and L*MP stacks. Imagine if anyone could install and run Discourse as easily as they do Wordpress, same with Ghost. DigitalOcean comes pretty close in this regard, but maybe something more fool proof for the average joe would be great.

Re:My Own Private CDN by extra88 on Saturday September 01, 2018 @01:36PM (#17892952)
Dreamhost shared hosting includes Let's Encrypt and Cloudflare, click a checkbox to enable them.

https://www.dreamhost.com/hosting/ssl-tls-certificates/

https://www.dreamhost.com/partners/cloudflare/

Re:My Own Private CDN by Ayesh on Saturday September 01, 2018 @01:46AM (#17890454)
One of the most painful things to work on would be clearing caches. I have my own setup that I invalidate the _entire_ set of assets just to make sure the end users do not get stale assets, and I just ++ a build ID and all the URLs are uncached at the edges. Not all sites hosted in shared hosts can do this.
Re:My Own Private CDN by zrail on Saturday September 01, 2018 @02:43AM (#17890608)
My plan for this is to just tell the cache nodes to delete the nginx cache folder entirely via their one-minute check in cycle. Each node will get a flag in the database that says "needs clearing" and when they check in next their update script will include an `rm -rf /nginx/cache/directory/*`. Extremely blunt but also easy and effective.
Re:My Own Private CDN by ohhellno on Friday August 31, 2018 @12:19PM (#17886767)
What you describe sounds like now.sh if you are on a JS-based stack.

Edit: also for just plain static if you use a non-JS generator.

Re:My Own Private CDN by oneplane on Thursday August 30, 2018 @10:24PM (#17882424)
I think the N part of the CDN is going to be the real thing here, the CD part is easy, especially with the various FOSS options out there.
Re:My Own Private CDN by fooblat on Friday August 31, 2018 @04:40AM (#17883936)
This. Building a "CDN" on top of an existing network is not building a CDN. Nice project to learn some parts of CDN management software tho.
Re:My Own Private CDN by michaelgv on Thursday August 30, 2018 @07:43PM (#17881802)
As someone who just recently CDN hell, and rebuilt our entire CDN network from the ground up (software and hardware), I was wondering why you picked RoR?
Re:My Own Private CDN by zrail on Thursday August 30, 2018 @07:47PM (#17881820)
It’s what I know best and what I’m most productive in. The project is to get something running and learn a handful of new things, and learning a new framework would be a detriment to that first goal.

The manager app is not in the hot path with this design so performance doesn’t matter all that much.

Re:My Own Private CDN by michaelgv on Thursday August 30, 2018 @08:02PM (#17881886)
Are you designing this CDN to pull from origin, cache temporarily? Or to pull from local file and put strong cache on it?

If you need a hand let me know, I’ve built pretty large CDNs before (10M r/s at peak)

Re:My Own Private CDN by zrail on Thursday August 30, 2018 @08:03PM (#17881902)
The former to start but I want to add push zones and/or “s3sync” zones that proactively sync an s3 bucket to local disk.

Thanks for the offer! I might just take you up on it :)

Re:My Own Private CDN by michaelgv on Thursday August 30, 2018 @08:42PM (#17882073)
Just be careful, understand that if you do a PULL only CDN, you're not going to gain big benefits. If you do want a pull only CDN, have a background task runner to retrieve the files, and update them locally.
Re:My Own Private CDN by tatersolid on Monday September 03, 2018 @12:24AM (#17900304)
> understand that if you do a PULL only CDN, you're not going to gain big benefits.

This statement makes no sense. A CDN edge node is just a cache; its size and your access patterns determine the hit ratio.

At $dayjob we get Nginx cache hit ratios on our edge in excess of 99% for “an origin fetch” setup. That is a very large benefit.

Cloudflare works entirely on origin fetch. They seem to be doing okay.

Re:My Own Private CDN by zrail on Thursday August 30, 2018 @08:46PM (#17882086)
Sure. I have Nginx set to keep files around for s long time and serve stale and refresh in the background, but proactively refreshing periodically is a good idea.
Re:My Own Private CDN by tmh88j on Thursday August 30, 2018 @08:04PM (#17881905)
What would you suggest and why? Not a loaded question for all the people eager to downvote.
Re:My Own Private CDN by skunkworker on Thursday August 30, 2018 @09:11PM (#17882176)
Personally I would build it in something like Go. I've done a lot of work in Rails and I would probably have the signup/profile/interface built in Rails 5.2 but use a high performant go framework for the really intensive stuff.

I've been considering building my own but getting an up and running gossip protocol to have it share data between nodes isn't the easiest thing in the world to code.

Re:My Own Private CDN by michaelgv on Thursday August 30, 2018 @09:23PM (#17882237)
Its a pain to code. I’ve done it, and I hated every second of it. Keeping data in sync with dynamic data in near real-time is terrible.

I wrote the CDN in Go, with Redis and a smaller go-powered daemon to retrieve assets every 20 seconds, sync them to a local storage drive, and after 5 days retrieve again - or, if there is no requests within 48 hours, clear the unused items.

Then I setup a system that if one edge requests an “unpopular” file, it’ll ping a simple REST API and have all the other edges pull that file, this allowing the edges to stay “one step ahead” of the user load

Re:My Own Private CDN by skunkworker on Thursday August 30, 2018 @09:26PM (#17882252)
Yeah, when thinking it through personally it comes down to a hard math problem. Because you have to maintain the state of the local files, whether they should live in memory vs ssd vs another node. Did you use an LRU cache for expunging less utilized resources?
Re:My Own Private CDN by michaelgv on Thursday August 30, 2018 @10:13PM (#17882386)
State is much less important to track. It’s easier to do, the real challenge is garbage collection - you need it, but you don’t want to collect too much in memory. That’s why Redis is a great tool for our edge servers.
Re:My Own Private CDN by skunkworker on Thursday August 30, 2018 @09:31PM (#17882268)
And nothing has made me realize just how slow the speed of light is until I started looking into the CAP theorem and distributed databases like CockroachDB.
Re:My Own Private CDN by zshenker on Friday August 31, 2018 @12:29AM (#17882962)
You could also look at something like Apache Traffic Control, which came out of Comcast, and is used by a number of CDNs. https://trafficcontrol.apache.org/
Re:My Own Private CDN by jsjohnst on Friday August 31, 2018 @11:46AM (#17886492)
> which came out of Comcast

Not that it matters, but some fun history for you. ATC is built on top of Apache Traffic Server. Before being donated over to ASF, ATS was known as YTS (Yahoo! Traffic Server). Of course the story doesn’t stop there, it was originally known as Inktomi Traffic Server, Inktomi having been acquired by Yahoo! in the early 2000s.

Re:My Own Private CDN by xxdesmus on Thursday August 30, 2018 @05:22PM (#17880899)
"NET::ERR_CERT_COMMON_NAME_INVALID"

off to a good start...

Your cert is valid only for corastreetpress{.}com

Re:My Own Private CDN by zrail on Thursday August 30, 2018 @05:24PM (#17880920)
Hmmmmm! Thanks for the bug report!

Edit: fixed. T'was a dumb copy and paste error.

Re:My Own Private CDN by djhworld on Friday August 31, 2018 @05:33AM (#17884155)
> Deploy onto the server in my basement on my ZeroTier network

I've read as much as I can handle of the website of this ZeroTier thing and I still can't fully grok it.

What's the difference between this and your own private VPN?

Re:My Own Private CDN by zimbatm on Friday August 31, 2018 @06:29AM (#17884385)
A VPN is point-to-point. You fire up the client on your laptop and connect to a server. That server is usually also acting as a bridge into a network. It gives your machine a presence into that other well defined network.

ZeroTier is an overlay network. What is does it create a new encrypted network, with it's own address space and everything, on which you can connect through the controller (a default one is provided by ZeroTier). It doesn't matter where the nodes are. If it detects that two nodes are on the same LAN it's going to route the traffic directly. The overlay network is encrypted all the time, even when it goes over your LAN.

Re:My Own Private CDN by jlgaddis on Monday September 03, 2018 @01:02AM (#17900438)
Sounds kinda like DMVPN.
Re:My Own Private CDN by y4mi on Friday August 31, 2018 @06:20AM (#17884347)
Zero Tier is peer to peer.
Re:My Own Private CDN by ksec on Friday August 31, 2018 @02:37PM (#17887830)
I look through the goals, apart from self learning experience, bunnycdn.com seems to fit all the bills without the hassle. And despite its pricing, it is pretty damn fast as well.
Re:My Own Private CDN by zrail on Friday August 31, 2018 @03:31PM (#17888133)
I can get 4TB of transfer from Vultr or Digital Ocean for half that price.

In any case, the cost considerations are somewhat secondary. I wanted to learn some stuff and this is a practical way to do it :)

Re:My Own Private CDN by ksec on Saturday September 01, 2018 @10:45AM (#17892063)
> I wanted to learn some stuff and this is a practical way to do it :)

Fair enough.

>I can get 4TB of transfer from Vultr or Digital Ocean for half that price.

You still need multiple POPS, with each droplet in those region the minimum cost is still going to be higher.

Re:My Own Private CDN by anotherrobot on Thursday August 30, 2018 @11:25PM (#17882691)
Dont see the point if its not distributed across networks.
Re:My Own Private CDN by hegz on Friday August 31, 2018 @03:24AM (#17883598)
Digital ocean has a bunch of locations
Re:My Own Private CDN by jsjohnst on Friday August 31, 2018 @11:41AM (#17886445)
Location is far from the only factor, peering can make as much of a difference too. Not saying DO is bad, but there are more factors at play than just location diversity.
Re:My Own Private CDN by greyman on Friday August 31, 2018 @05:13AM (#17884081)
Good exercise, but I doubt this will be cheaper than a commercial offering like Cloudflare, for example.
Re:My Own Private CDN by powmonk on Friday August 31, 2018 @06:31AM (#17884391)
The skills you pick up from even attempting these things are probably the biggest reason for doing it. And bragging rights maybe?
Re:My Own Private CDN by jgrahamc on Friday August 31, 2018 @06:01AM (#17884272)
Sure, but some things are done just for fun, others to prove it can be done. It's not all about the $

Also, TFA is talking this vs. CloudFront which is $$$