Hacker News new | ask | show | jobs
by nym 3278 days ago
Would throw in there "Use CDNs as much as possible"
4 comments

Nah. With http2 you're seriously better off having everything in one place. Avoids overhead of multiple TCP connections and (more importantly) overhead of TLS handshakes.

Might not always be true but in tests I've done on my company's sites the http2 load is always faster with no CDN, even from far away locations.

With plain CDNs, sure. With reverse-proxy caches like Cloudflare, the CDN can be the HTTP2 endpoint.
I would bet it still adds latency unless your site is completely static. For anything that needs to hit your servers you->cloudflare->server is still slower than you->server. On the round trip that's added two extra hops so maybe 100ms.

The golden age of CDN's is over. Their primary advantage was being able to open up many parallel connections using multiple subdomains and the ability to cache across domains.

With http2 multiple connections have become a bad thing and https is mandatory so CDN caching is irrelevant.

On http2 and a tiny AWS instance I can get sub 200ms page loads from anywhere in the US if I host in the midwest. The gain from avoiding multiple HTTP connections, TCP slow starts, and TLS negotiations negates all the speed advantages of using a CDN. Cloudflare might be worthwhile if you get massive traffic but a small Nginx instance can handle hundreds of megabytes per second of traffic.

I just don't feel comfortable using them in certain situations, like SaaS web apps. What if they go down, for any reason, and since I depended on the CDN for a core framework (say, React), now my entire site isn't going to load. Queue customer e-mails.

That being said, for less mission-critical projects, they do have their place.

CDNs aren't an either-or thing. It's common to fall back to a copy on your server if the CDN version doesn't load.

CDNs involve a big set of tradeoff choices you have to make, they don't make sense for every circumstance. I don't think I'd ever throw in "Use CDNs as much as possible" into an optimization advice list.

Yeah, keep the dynamic stuff on your webserver, static stuff on the CDN. Part of the reason I say "as much as possible" is because I've seen significant conversion improvements by enabling a CDN.
Typically the CDN is used for all static assets does not include the HTML. In the event that your CDN is not working, you can always fallback on your own static.example.server.

CDNs are one of those cases where the cloud vastly outperforms whatever kind of server you have.

I would add to this, use a dumb but performant CDN. Cloudflare's Rocket Loader has rewritten working Javascript into broken Javascript for me. If I use Cloudflare I turn off all the gizmos to be sure.
Ah sure, but that'll depend a lot more on the type of website. For small websites I normally include the main library through a CDN and just include it into the <style> tags if the total HTML+CSS size is under 14kb. For medium-large websites totally agree.