News for hackers. Stuff that matters.
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by autotravis on Friday September 14, 2012 @11:50PM (#4525226)
"We didn’t have any page caching in place at all."

Cache me if you can! If you're a high-traffic site and you are not caching static content (I recommend Varnish highly), then your are throwing money or good user experience out the window.

Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by johnb on Saturday September 15, 2012 @02:19AM (#4525505)
The key thing I got a bit wrong was high-traffic mostly static "content", vs high-traffic "very custom" which is a) what I was used to at envato and b) what I thought we had on our hands at goodfilms.

I think in a growing site with a lot of custom per-user content (like a social network) the extra complexity of a cache layer and managing expiry is more pain than it's worth while iterating the product quickly. If you're mostly a content site, it's definitely the #1 thing you should be doing.

Realising that we're both at the same time, depending on the user or page, means that sometimes the cache stuff is the right thing to do, and sometimes not. I was leaning too far towards not, and happy now with the balance we've picked.

Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by ben_h on Saturday September 15, 2012 @02:54AM (#4525545)
Absolutely. At theconversation.edu.au we run a content site—we publish the news, which is the same for everyone. This means we can cache the front page and all the articles as static HTML, and then annotate the page with user info for signed-in commenters, editorial controls for signed-in editors, and so on.

(We have a separate cookie that is present for signed-in users, so the fronted knows whether it should fire the annotation request.)

The result is that we can serve a sudden influx of unauthenticated users (e.g. from Google News or StumbleUpon) from nginx alone, which gives us massive scale from very little hardware. It's likely that the network is actually the bottleneck in this case, and not nginx.

Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by ianpri on Saturday September 15, 2012 @05:25AM (#4525753)
Interested in what you mean by annotating the page after caching it, do you have any more info on this?
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by jhealy on Saturday September 15, 2012 @09:05AM (#4526009)
The cached page contains content suitable for everyone, so it looks the the user is logged out.

An extra AJAX request grabs the users logged in status, CSRF token and similar data as JSON and then modifies the page so the user sees what they expect (a logout button, a comment form, etc).

Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by rhizome on Saturday September 15, 2012 @05:49PM (#4527416)
Doesn't that cause content movement?
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by autotravis on Saturday September 15, 2012 @11:04AM (#4526218)
Essentially talking about edge side includes [http://en.wikipedia.org/wiki/Edge_Side_Includes].
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by stef25 on Saturday September 15, 2012 @04:36PM (#4527221)
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by patmcguire on Saturday September 15, 2012 @12:33PM (#4526475)
If you're running Ruby on Rails record cache will do it all for you (I've yet to run into any issues, the one I thought was an issue was actually a pgpool-II bug).

https://github.com/orslumen/record-cache

If you're on Django I think cache-machine does the same thing. There are some things you won't get cached this way that you could manually (functions and procedures), but I think they're both conservative enough that you won't return stale resources.

Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by lengarvey on Saturday September 15, 2012 @02:05AM (#4525474)
Part of Rails 4.0 will be further pushing the "Russian Doll" caching that 37signals/DHH talks about here: http://37signals.com/svn/posts/3112-how-basecamp-next-got-to...

One of the great things I love about Rails 3 is how easy it is to start caching. It can, and does, cause issues so make sure you're including caching in your test suite. I'm definitely looking forward to seeing how Rails 4 pushes this forward.

Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by notatoad on Saturday September 15, 2012 @02:07AM (#4525475)
When you say static content, do you mean actual static content, or dynamic-but-still-kind-of-static? Actual static content like CSS files and background images doesn't get any benefit from varnish. Something like the HN front page, where it is dynamic but consistent for all users at a specific point in time, is what you need to put behind varnish.
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by autotravis on Saturday September 15, 2012 @11:12AM (#4526242)
Both. Varnish defaults to caching jpg,gif,png,css,etc. but we also having it caching things that are pulled from the db and processed. So it leaves our cpu-intensive backend untouched for the vast majority of requests.
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by kevinprince on Saturday September 15, 2012 @05:38AM (#4525764)
In high traffic caching css and images in varnish as well makes sense as it is much faster at evaluating and responding to the HTTP request than say Apache which will be busy building dynamic requests.
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by justincormack on Saturday September 15, 2012 @09:12AM (#4526016)
Not really the case if you are using Nginx though.
Re:The Minimum Viable Rails Stack, Now Reddit Frontpage Appr... by heretohelp on Saturday September 15, 2012 @01:37AM (#4525434)
*you're

And I agree completely. Varnish is goddamn magical and a fascinating exercise in a principled approach to kernel-oriented memory management (a mindset I don't normally undertake).