TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Writing a Mini-CDN to Learn Nginx/Prometheus/Grafana/Lua

312 pointsby dreampeppers99over 2 years ago

14 comments

jay6282over 2 years ago
The hard part of building a CDN is to know when you need it. 99.9% of all websites with CDN do not need it. Serving static files consumes so little resources that a single server can serve billions of users as long as you dont use script for serving the file. The most cost-effective with also the lowest latency solution is to never use CDN. If your webserver provider charge you a lot for traffic you are better off using another provider.
评论 #34142891 未加载
评论 #34141879 未加载
评论 #34139117 未加载
评论 #34146245 未加载
hardwaresoftonover 2 years ago
It would be nice to discuss the common approaches to global name resolution —- anycast vs geo-routing.
评论 #34139483 未加载
mnuttover 2 years ago
This is nicely written, and a lot of it mirrors my experience using nginx as a pseudo-cdn. Another area worth exploring might be http3, ssl session caching, and general latency/ttfb optimizations.
sandGorgonover 2 years ago
this is very very cool! One thing i would definitely like to see is domain name resolution. Shopify, Dukaan, Vercel all make a big deal out of it ...going all the way to BGP.<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;subhashchy&#x2F;status&#x2F;1536769406801309696" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;subhashchy&#x2F;status&#x2F;1536769406801309696</a>
nnadamsover 2 years ago
Is it possible for CDNs to cache per URL per user? I&#x27;m thinking of something like &#x2F;favorites where one URL would list something different for everyone. When I&#x27;ve setup caching on backend it was keyed off the user.<p>This was a very informative read!
评论 #34139279 未加载
评论 #34139210 未加载
评论 #34138752 未加载
评论 #34141384 未加载
xmorseover 2 years ago
The hard part of building a CDN is scaling it. The best approach imo is to use fly.io to host an anycast IP (with horizontal scaling) and store cache files on disk<p>Fly.io also has a Grafana dashboard built in for your machines
评论 #34139707 未加载
vitorbaptistaaover 2 years ago
Beautifully written! Thanks for sharing, Leandro.
评论 #34137917 未加载
chrsigover 2 years ago
I&#x27;m curious if any HNers have opinions on prometheus vs other time series databases like influxdb?<p>I periodically consider a grafana &amp; backend setup for when datadog becomes cost prohibitive for metrics with several tags.
评论 #34140148 未加载
评论 #34142718 未加载
评论 #34141360 未加载
daniels1006over 2 years ago
Great content, helpful and inspiring.<p>Thanks!
sodez117over 2 years ago
Good read. Is there something similar for building a DDoS protection feature? Like Cloudflare?
zspace2over 2 years ago
Very good project. thanks for sharing
friendlyHornetover 2 years ago
Thanks for this
评论 #34137404 未加载
asjkaehauisaover 2 years ago
Why didn&#x27;t you use varnish for that?
评论 #34141695 未加载
jeackenover 2 years ago
Another example of a project duped into thinking Lua is “powerful”. It is small. That is it. Lua has near zero useful functionality and makes the developer repeatedly reinvent functionality over and over and over again.<p><a href="https:&#x2F;&#x2F;media1.giphy.com&#x2F;media&#x2F;TFO2mwVPIFoOJcuTSC&#x2F;giphy.gif" rel="nofollow">https:&#x2F;&#x2F;media1.giphy.com&#x2F;media&#x2F;TFO2mwVPIFoOJcuTSC&#x2F;giphy.gif</a>
评论 #34140699 未加载
评论 #34140992 未加载
评论 #34143861 未加载