logoalt Hacker News

PunchyHamstertoday at 1:56 PM1 replyview on HN

One time I decided to check how much faster really you can go while still getting decent usability out of "simple blog platform" type of webapp.

End result, written in go, did around 80-200us to generate post page and 150-200us (on cheap linode VPS... probably far faster on my dev machine) for index page with a bunch of posts.

Core was basically

* pre-compile the templates

* load blogpost into RAM, pre-compile and cache the markdown part

cache could be easily kicked off to redis or similar but it's just text, there is no need

Fun stuff I hit around:

* runtime template loading takes a lot just for the type-casting; the template framework I used was basically thin veneer over Go code that got compiled to Go code when ran

* it was fast enough that multiple Write() vs one was noticeable on flame graph

* smart caching will get you everywhere if you get cache invalidation right, making the "slow" parts not matter; unless you're running years of content and gigabytes of text you probably don't want to cache it anywhere else than in RAM or at the very least have over-memory cache be second tier.

The project itself was rewrite of same thing that I tried in Perl(using Mojolicious) and even there it achieved single digit ms.

And it feels so... weird, using webpage that just reacts with speed that the well-written native app has. Whole design process was going against the ye olde "don't optimize prematurely" and it was complete success, looking at performance in each iteration of component paid off really quickly. We got robbed of so much time from badly running websites.


Replies

jonathanstrangetoday at 5:54 PM

I had my page served with Go and it was instant, 100% speed score. Then I moved the static content to a CDN and it's slower now, only 96% speed. However, the question is really how fast the page is when it comes under heavy load.