Live data from Hacker News

Ask HN: Why and how is Hacker News so fast?

news.ycombinator.com

31–40 of 110 posts

Re: Ask HN: Why and how is Hacker News so fast?

#31
post #23

Earlier quoted context omitted.

So every time a new comment is posted, is the CloudFlare cache invalidated and replaced with a new version of the comments page?

Actually for now, HN is not caching their HTML with us. we put a "CF-Cache-Status" header for when we are caching things

So when hitting a comment page, HN's backend is being hit in some way, whether by reading a db or by concatenating flat files or something else? Or are they just using a local cache that isn't pushed out to CloudFlare because there would be so much churn that pushing to CF wouldn't be a benefit?

Re: Ask HN: Why and how is Hacker News so fast?

#32
post #23

In addition to being so small (text-based, minimal JS), HN is cached by CloudFlare, which grabs copies of dynamic pages and pushes those copies out to their CDN edge servers around the globe so they're closer to end users. When your browser asks for the IP to news.ycombinator.com, you get the address of a cloudflare CDN server. Which web server the DNS server will send you is based on a GeoIP lookup of your own IP ad…

So every time a new comment is posted, is the CloudFlare cache invalidated and replaced with a new version of the comments page?

Not sure, but cloudfare supposedly speeds up content delivery even for dynamic content where you need a new db hit each time. The idea is that it leaves open a persistent connection with the webserver, which means A) less work creating and destroying connections B) each new connection isn't starting off as throttled.

Re: Ask HN: Why and how is Hacker News so fast?

#33
I've found that not including Google Analytics, Twitter buttons and that sort of stuff plays a major part in loading time. Despite the fact that those scripts have the 'async' tag, they still impact loading time.

Heck, I get the feeling that they impact loading time more than my own CSS, images and Javascript. I already heavily minify and concatenate everything, as well as use SPDY for improved concurrent requests, but it seems Google and Twitter add 1-2 seconds.

Re: Ask HN: Why and how is Hacker News so fast?

#34

For your need to simulate a 256kbps connection, two things have worked for me. Both require a good few mbps connection to begin with though: 1. Use Chrome's device emulator mode. You can ignore all other settings like screen size, user agent, etc. and just use the speed restriction. 2. Use a specialized WiFi router. I use the ones from TP-Link in which I can restrict speed for a particular device IP. DD WRT based rou…

For OS X and iOS users, Apple has a "Network Link Conditioner" utility in the developer tools that can simulate different throughput as well as packet loss.

Re: Ask HN: Why and how is Hacker News so fast?

#35

In addition to being so small (text-based, minimal JS), HN is cached by CloudFlare, which grabs copies of dynamic pages and pushes those copies out to their CDN edge servers around the globe so they're closer to end users. When your browser asks for the IP to news.ycombinator.com, you get the address of a cloudflare CDN server. Which web server the DNS server will send you is based on a GeoIP lookup of your own IP ad…

Pretty close! We don't actually use GeoIP at the DNS level, we use the routing table of the internet to direct people to the closest location we have to them by announcing the same IP addresses in the routing table in many places (eg, anycast) You can find a blog post primer and general more explanation here: https://blog.cloudflare.com/cloudflares-architecture-elimina... the upshot of this is that TCP and SSL connec…

Awesome, thanks for the additional info. On a related note, I really appreciate how good CloudFlare is about knowledge sharing. Not a lot of companies would be so willing to share information that's so integral to their business.

Re: Ask HN: Why and how is Hacker News so fast?

#36
post #3

Server-side is a different beast than the whole server->client part. HN does not load particularly fast for me, 300-500ms is fairly slow.

Same for me. I don't think HN's particularly fast. Barely faster than rockpapershotgun.com, which has lots of images, but not much. Given that it's all pure html text, I would expect more. RPS might have better caching that's closer to me though.

Re: Ask HN: Why and how is Hacker News so fast?

#37
Wow, really? Has it become such a generational sea change? Have people really failed to understand the nightmare that modern javascript, full-motion animated gifs, web videos, and ultra high-resolution jpegs represent to bandwidth? Nevermind their local CPUs?

Javascript is really the black hole, though. When people defer their client-side libraries to whatever CDN, and then let that library manage whatever it pleases for dependencies, forget it. That's like saying, I don't even care if people's computers catch fire and explode, when they try to watch this awesome star field simulation.

Oh yeah, and all the ads and spyware analytics too, ya know...

Re: Ask HN: Why and how is Hacker News so fast?

#38
post #3

Server-side is a different beast than the whole server->client part. HN does not load particularly fast for me, 300-500ms is fairly slow.

> HN does not load particularly fast for me, 300-500ms is fairly slow

slow Compared to what? Show me a social network/forum that you visit everyday and loads everything under 300ms.

Re: Ask HN: Why and how is Hacker News so fast?

#39

Not pulling in a ton of external javascript, images, and ads is probably the biggest, but one thing that helps is that most comment threads have a relatively low number of comments. This page currently only pulls down down 12KB (compressed to 3.75KB). A thread like https://news.ycombinator.com/item?id=9976298 with ~600 comments pulls down 785KB (compressed to 143KB) In general, looking at the network tab in the devel…

Can someone buy the .text TLD already and make a whole part of the internet where this approach is standard?

Sorry for the offensive domain name (it's not mine), but this is relevant here:

http://motherfuckingwebsite.com/

Re: Ask HN: Why and how is Hacker News so fast?

#40
As many others have mentioned, the secret sauce is probably quite simply this: No ads, no trackers, no js libraries. I use Firefox with the 'disconnect' plugin. On HN, disconnect stays completely inactive, nothing to be blocked, just good old html to be rendered with a sprinkle of css. It's beautiful, it's the way it should be.
Post reply on HN