/ hacker-news

How I got featured on Hacker News - case study

My article about JSON Web Tokens recently got featured on Hacker News. The article received over 300 points and there was a good discussion under the story as well, with over 150 comments. It stayed on the first page for a bit longer than a day. Excited as a child on Christmas morning, I was watching the traffic go through the roof and then slowly die away over the following week. Now I'm going to share with you what I learned and sprinkle it with very intimate charts from Google Analytics, New Relic and friends.

Oh, the thrill of the traffic

After about an hour since I had posted my story, I realised that it was still holding on to the first page of Hacker News. On the fourth position! The upvotes were going constantly up and the comments were growing in number. Filled with excitement, I jumped onto Google Analytics to see what sort of traffic my post was actually attracting.

Traffic over time distribution

Retrospectively, that's nearly the best I got, but it's still something to be really happy about. While I'm writing these words, it's been a week since and I've been watching the traffic slowly die away. It didn't diminish completely, though. The chart showing number of sessions over time resembles typical normal distribution with positive skew:

Top 10 traffic sources

As you can probably see, there was a minor lift in the number of session on Friday the 24th. That was because of the hackernewsletter sent that day, which was a nice bonus and one more source of traffic. Speaking of which, it is quite interesting to see how the word spread, either automagically through aggregators or through genuine shares people made. You won't find Twitter or LinkedIn in the top 10, although they were there as well, in the long tail.

Top 10 countries

We know what sites people came from, let's see what countries dominated the traffic. I believe it does not come as a surprise that over 34% of all sessions came from the U.S. alone, followed not so closely by the U.K. with 7% and Germany with 5%. Here's the list of the top ten:

Devices

In terms of the devices used, nearly as many people came to my blog on a mobile as on a desktop. Good job my blog has a responsive template, I daresay. Tablets where there as well, although not as strongly represented with just over 6%. :

Traffic quality

Not all the traffic was relevant. Out of nearly 29k sessions, around 27.5k lasted less than a minute. That would give us about 5% of relevant traffic. Of course this might be down to poor quality of the article introduction which should capture the user within first few seconds. Some other factors could be at play as well. Hard to tell without A/B testing, which is not very likely to happen :)

SEO benefits

One of the benefits of having my article featured on HN is that I got plenty of referrals. The day after I posted my story search for "JWT" was showing my article on the sixth position. That's pretty good for a article with a title of "JSON Web Tokens (JWT) vs sessions" and from a blog with laughable page rank. This did not stick, though. While I'm writing these words the article is nowhere to be found in the first 5 pages of search results.

Luckily, not all is lost. Searching for a phrase from the title, like "json web tokens vs sessions" or "jwt vs Sessions", shows my article in the first place:

Server performance

I am running my blog on Ghost in a Docker container with Nginx in front of it as reverse proxy. Nginx lives in a Docker container as well. The server is a relatively small VPS with 2 core Intel Atom and 2GB RAM. On a side note it's quite a good deal from Scalaway for €2.99 a month. The whole thing is behind Cloudflare CDN.

The response time

I was expecting the sudden surge in traffic to put some load on the server, which in turn would increase page load and the response time. Luckily, I have StatusCake set to monitor my blog, so I could easily verify my theory. You can imagine my surprise when the stats did not show anything out of the ordinary. I have posted my story on Hacker News on 18th of June:

The load

Similarly, I was expecting the load on the server to raise somewhat, and again I was in for a (nice) surprise. I have New Relic set to monitor my server performance, so I could see what was going on in near-real time. The load was maxing at around 7%, which could be as good for a pretty much idle server.

The memory

Looking at the memory consumption was even more heartwarming. The chart was flat as a table. Neither Ghost nor nginx were memory hungry. Good job I didn't go for Apache while setting it all up. Apache likes memory, as it needs one worker per each request. Nginx didn't even notice.

The network

And finally I saw some confirmation of the incoming traffic in the network chart. There was a spike in line with what Google Analtytics was reporting.

The CDN requests

Obviously the good performance of the server was partially a compliment to Cloudflare, which took some of hit and provided expected off-load. The CDN caches only the assets (images, CSS, JS, and so on) and none of the HTML, but that's a big help anyway. For each request hitting the server directly there were two (well, and a bit) which were served by Cloudflare:

The CDN bandwidth

The bandwidth chart tells even more heartwarming story. For each byte served by the server there were 3 served directly by Cloudflare. In total my server send to people around 1GB in the last week whereas Cloudflare - 3GB. And just to clarify - the weight of the article page in question is around 500kB, including everything served from third parties, like Disqus.

How did I pick the subject

I didn't aim for being featured on HN. As a matter of fact I have been looking into Feathers, an amazing real time framework for building service oriented apps. Feathers use JWTs for authentication, and I thought it would be good to know a thing or two about them, so I started exploring the subject. Quickly, it turned out that the knowledge out there is somewhat scattered and the more I read the more questions I had. I like questions but I prefer answers, so I turned to RFCs - the ultimate source of truth. It was at this point when I started noting things down in a blog post.

The research took good few afternoons, reading the specs over and over again and comparing with use cases from The Big Guys. When I was done I polished up my notes, added some sugar, corrected whatever mistakes I could find and finally pressed "publish". As I had spent some time on the piece gathering together some nuggets of wisdom scattered across a number of good posts and backed up by the spec, I figured it would be cool to see if people care and what they think. That's why I went to HN.

When did I post to Hacker News

I finished writing the article on Saturday afternoon (U.K. time) and that's when I went to HN. It was quite lucky, as I later learned, because posting on a weekend may be part of a strategy for being featured. Well, I didn't know that in advance, but there you have it. It seems to be helping.

Conclusion

Having your piece featured on HN is absolutely thrilling and very rewarding. When you see people discussing your article and upvoting, you feel that the time spent writing the post was really worth it. It's also a bit intimidating, knowing that your words reached nearly 30,000 analytical brains, used to dealing honest but sometimes harsh criticism.

As I later found out, getting featured on HN is so much of a big deal that people sometimes try to work the system. In my case it wasn't a result of weeks filled with careful planning nor some deeply cunning strategy, so I couldn't tell you what the golden recipe is. I could tell you the story, however. What lead to picking particular subject, when I posted on HN and what impact it had on my server and SEO.

I hope you liked the story.

May the Source be with you.

Jacek

comments powered by Disqus
How I got featured on Hacker News - case study
Share this