Live data from Hacker News

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

news.ycombinator.com

51–60 of 110 posts

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

#51
post #28
post #18

If you want to see an even faster "forum", see http://forum.dlang.org/

This one is crazy. How are they so fast?

No, forum.dlang.org is not crazy-fast. Other sites are crazy-slow.

Write compact and easy-to-render HTML, it's no rocket science. Write some trivial CSS, you don't need Bootstrap. Make something dead-simple and call it flat design. If you have more than one stylesheet, concatenate them into one. Consider minifying. You don't need a 200 kB JS framework in order to fade in some hover menu. If you do need more than one JS file, concatenate them into one. Minify/uglify and move the tag to the bottom of your HTML.

You don't need 2 MB worth of stock photos. Recently, there was a page on HN with an uncompressed 12 MB banner photo. That is insane.

You don't need those heavyweight social plugins, they ruin your day (performance-wise). If your content is great, people will find a way to share. If your boss specifically asks for Facebook and Twitter buttons, just link to https://www.facebook.com/sharer/sharer.php?u=http://www.exam... and https://twitter.com/home?status=This%20is%20great:%20http://.... [1]

Don't just embed YouTube iframes, they are even worse. Use yt-embed.js [2].

Is a web font really necessary? If it is, do you really need Bold Italic? Sure as hell you don't need Ultralight+Light+Semilight+Regular+Bold, just because there is one ubercool Ultralight tagline in the footer.

Make sure Nginx or Apache gzip HTML, CSS and JS and send far-future Expires headers for all your static assets. Make sure that there are no redirects, they add latency.

If you follow these simple rules, your page weighs under 50 kB and needs no more than 10 HTTP requests. You don't even need complicated CMS caching and CloudFlare. But hey, there are some 10,000 cache plugins for WordPress, just install one.

[1] http://www.sharelinkgenerator.com/

[2] https://gist.github.com/do18/09761dfabf60689b2cd8

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

#52
Flat files are very fast. The OS caches the files most of the time in memory. OS caching only becomes a problem when the hot data exceeds the memory.

By the nature of HN, there isn't that much hot data. Only the couple dozens of links in the HN front page are popular. May be couple hundreds or couple thousands people actively voting. All those don't take too much space and can fit in memory comfortably so the entire data set can be operated inside memory essentially.

The front page has 30 articles. Assuming 100k per one yields 3MB. It has about 1000 vote points. Assuming 50 bytes per vote, it's about 50k. So you can fit the entire front page data in under 4MB. That's tiny amount of data to work with.

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

#53
post #45

It's relatively straightforward. Take a look at what Pingdom tells you it does when the site loads: http://tools.pingdom.com/fpt/#!/cnYAuq/https://news.ycombina... 5 requests, Total size 12.6kB, total time 661ms. 1 request for the content, 1 for css, and then 3 gifs, all from a single domain (so just one DNS request). If you look at the profile, 47% of the time was spent doing that one DNS lookup, so subsequent reque…

Might be able to get that down to 5 requests if they use .pngs instead of .gifs and throw them into a sprite sheet.

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

#54
Primarily it's the simplicity of what it sends back and the low number of requests.

Pre-rendered pages fed over the wire with minimal assets are fast, my blog http://benlowery.co.uk/ loads under 70ms on my home connection, it downloads 3 assets (and by far the biggest hit is the webfont).

I think we've grown so used to pages taking a couple of seconds to pull hundreds of assets and then render them that fast pages stand out :).

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

#55

Loading this webpage I downloaded ~12KB. For comparison, I went to the NYT homepage and downloaded ~1.2 MB. For people with shitty downlinks like you and I, the absence of exorbitant quantities of Javascript and images makes a lot of difference - a lot more than time-to-first-byte.

[deleted]

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

#56
post #9

Speed isn't everything. Hacker News has been recently one of the most unreliable website I frequent.

The whole point of this whole thread in a nutshell is that speed is greatly underrated.

Besides this thread we had a bunch of "We discovered that adblockers clean up and speed up browsing experience by x%. Now why is that?" threads in the last month posted here. There's a reason for that.

As for reliability... I don't have complaints, honestly. Maybe I spend less time here than you.

My only gripe with HN is the search stuff they use (Algolia). It's almost unusable on my mobile, broken in Opera Mini, and just crappy on my desktop browser.

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

#57
post #45

It's relatively straightforward. Take a look at what Pingdom tells you it does when the site loads: http://tools.pingdom.com/fpt/#!/cnYAuq/https://news.ycombina... 5 requests, Total size 12.6kB, total time 661ms. 1 request for the content, 1 for css, and then 3 gifs, all from a single domain (so just one DNS request). If you look at the profile, 47% of the time was spent doing that one DNS lookup, so subsequent reque…

"... (so just one DNS request)."

Are you sure?

request #1

1 news.ycombinator.com: 207 bytes, 1+0+4+2 records, response, noerror query: 1 news.ycombinator.com authority: ycombinator.com 172800 NS ns-225.awsdns-28.com

request #2

1 news.ycombinator.com: 225 bytes, 1+1+4+0 records, response, authoritative, noerror query: 1 news.ycombinator.com answer: news.ycombinator.com 300 CNAME news.ycombinator.com.cdn.cloudflare.net authority: ycombinator.com 172800 NS ns-1411.awsdns-48.org

request #3

1 news.ycombinator.com.cdn.cloudflare.net: 367 bytes, 1+0+5+10 records, response, noerror query: 1 news.ycombinator.com.cdn.cloudflare.net authority: cloudflare.net 172800 NS ns1.cloudflare.net

request #4

1 news.ycombinator.com.cdn.cloudflare.net: 89 bytes, 1+2+0+0 records, response, authoritative, noerror query: 1 news.ycombinator.com.cdn.cloudflare.net answer: news.ycombinator.com.cdn.cloudflare.net 300 A 198.41.190.47

A HOSTS file entry for HN will avoid this routine.

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

#58

Earlier quoted context omitted.

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/

I prefer http://bettermotherfuckingwebsite.com/ which was my inspiration for my blog design http://benlowery.co.uk/ :)

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

#59
post #18

If you want to see an even faster "forum", see http://forum.dlang.org/

I have been puzzled by this being said about dlang forever and today about HN. These sites are certainly not noticeably slow, but I don't notice anything remarkably fast about them either. Am I not visiting enough of the slow sites ?

My working hypothesis is that I don't have a good understanding of web-development to appreciate the nuances. Much akin to me listening to Indian classical music, Jazz: I would often encounter trained listeners breaking out into a (silent) applause. At those instances I feel bad because I realize I have missed something but I wish I didn't. So all pointers appreciated.

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

#60

Earlier quoted context omitted.

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.

On the other hand, they do some stupid stuff, disregarding the standard and how useful it is [0].

[0] https://blog.cloudflare.com/deprecating-dns-any-meta-query-t...

Post reply on HN