Categories
Musing

How Hacker News Will Affect Your Site?

I have never expected that this little blog of mine will reach the 1st page of Hacker News.

I dreamed of it. How wonderful it would be if I just reached the 1st page of Hacker News… but I never think that I’ll get to the 1st page.

Just out of curiosity, I submitted the post I wrote few months back to Hacker News. It’s basically a place where startup people read whatever happening in the startup world.

And a few minutes after I went away from my laptop to watch TV, I refreshed my blog.

And it’s Error 500.

And MySQL is down.

Ops. Oh oh.

Then I realised: my site IS trending up in Hacker News.

I’m elated. Electrified is the right word I guess?

So many people want to see what the fuss is all about the blog post but it’s not up?

So how do I get my site back up running again?

And… I did a classic mistake that many made.

I did not activate caching plugin.

Nope. I did not even download it.

What a foolish mistake to make.

I thought of enabling it, but I never bothered to download it in the first place.

I opened the Hacker News link and saw so many people bashing me. (Right now most of the comments have been deleted).

Damn.

I tried rebooting my droplet (I use DigitalOcean)… but it didn’t help much. There is just so many people coming in, even when I restarted it, the MySQL service instantly crashed.

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

No matter how many times I restarted it, the service keeps on failing.

Since I’m unable to get the site up running as usual, I do what I can do: put a placeholder page until I get everything up and running again.

So, I opened up Google cache (thanks Google!) and copied and pasted the article in a HTML file that I did in a haste. Bad formatting and all. Ah, just put it up so that at least people can see it when they opened the blog.

Instead of being greeted by server 500 error, I greet visitors who is coming to my blog with this ugly looking HTML page.

That’s a quite good lesson to learn. I need to have a static site as a failover just in case your WordPress site is down.

I mean, who knows, right? Especially with a small blog that is running on 512MB VM.

Oh well, that’s a start. At least it will free the MySQL from having to serve the people, right?

I waited a bit.

I restarted the droplet again and tried to enter the admin panel again.

Yeay! I can enter the admin panel!

But usually it will crash in just a few seconds after I entered it.

It’s not successful but at least it’s a start.

I replaced the front page with the same HTML and managed to get to the Plugins page.

I added WP Fastest Cache and tweaked some settings.

After that I asked around for advice. I spammed Malaysian Open Source (Sumber Terbuka Malaysia) Telegram group and my friends for any advice they can give for someone in my situation.

One of the tips given by members of that group is I can just use CDN provided by Cloudflare for free. Why, in God green earth did I forgot about that?

That’s the next thing that I did.

I signed up for Cloudflare, followed the instruction, changed the nameservers to Cloudflare’s and also searched for Cloudflare plugin for WP if it exists. (It did, and it is developed by Cloudflare team).

By now, this blog was routinely restarted again and again.

I remembered using MySQL tuner to optimize an exam system that I helped configure and run for my current workplace (Albukhary International University).

So I used it on my blog.

But the sad part is I am running on the lowest plan so most of the suggestions are plain useless. I can’t use it.

I asked myself, can I just upgrade the droplet for a while? The RAM and the CPU just for a little while when the going gets tough?

It turns out that I can do it in DigitalOcean!

So yeah, what I do was, I powered off the droplet and then, I increase the CPU and RAM only. I use the $20/month option.

It’s getting smoother now.

I boot up the droplet and immediately feel the responsiveness of the blog. Right now I am able to browse the admin panel without having the dreaded server 500 error.

So right now, it’s a combination of caching, CDN and just a raw horsepower from bigger CPU and RAM.

How was the traffic, really?

The traffic surge from being in the Hacker News will last for 1 or 2 days.

But you may get new links from unexpected places. Other blogs linking to you or people shared it through their social media account.

So you may get residual traffic from other websites too.

For example, I do get traffic from Reddit.

That’s good for SEO I guess. Google always love links. Lots of it, especially.

For someone who is accustomed with not being seen by anyone, scaling is hard. I have never expected my site to serve thousands of users in under few minutes.

After the fact

After all the dust has settled, I read all the comments at Hacker News that I linked in the first paragraph. A lots of comments… and there are some good advices too!

One of the advice given is to use load testing tool. One of the tools linked is Loader.io. I have never encountered this before, so maybe the next time I ever send my article to Hacker News, I’ll try to use this service first and see how it goes.

And I want to say thanks to all the tips given by members of Open Source Malaysia Telegram group. Another thing that they did was they also told me if my site was down from their sides, which is good. At least I have a realtime feedback of what’s going on from another visitor point of view.

I also want to thank a friend who proofread my blog post few hours after the blog post was hit by Hacker News effect. Or else, the article would read even worse.

Some of the plugins that I mentioned above but too lazy to link to can be easily searched from WordPress Add New Plugin page.