News for hackers. Stuff that matters.
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.