Live data from Hacker News

Using Flat Files So Elections Don’t Break Your Server

open.blogs.nytimes.com

31–40 of 51 posts

Re: Using Flat Files So Elections Don’t Break Your Server

#31
post #24

Earlier quoted context omitted.

Apache has not strictly been one process per connection since 2.0. See the worker MPM. I would have chosen nginx, but Apache can be configured as a capable static file server.

Even then each thread is still one connection (according to the apache docs).

Except in the Event MPM

Re: Using Flat Files So Elections Don’t Break Your Server

#32
post #28

Earlier quoted context omitted.

So I know nothing about haproxy, but what sort of system load does it generate? They say they ran it on a EC2 micro instance, and the micro instances are specifically designed to handle spikes, not continuous heavy load. In fact, they intentionally throttle under continuous heavy load. I guess it must have been the right choice for them, I was just surprised to see it was a micro. Would that typically be the right wa…

The micro instance was fronting the render farm. As far as I can tell the article doesn't specify the instance types in use for any of the other components.

[deleted]

Re: Using Flat Files So Elections Don’t Break Your Server

#33
post #28

Earlier quoted context omitted.

So I know nothing about haproxy, but what sort of system load does it generate? They say they ran it on a EC2 micro instance, and the micro instances are specifically designed to handle spikes, not continuous heavy load. In fact, they intentionally throttle under continuous heavy load. I guess it must have been the right choice for them, I was just surprised to see it was a micro. Would that typically be the right wa…

The micro instance was fronting the render farm. As far as I can tell the article doesn't specify the instance types in use for any of the other components.

Ah! I see that now, thanks for pointing that out!

Re: Using Flat Files So Elections Don’t Break Your Server

#34

I have always been a proponent of the 5 second cache for things like blog posts. After you hit Reddit, you can see 1000 requests a second for a few minutes. If you cache for 5 seconds, nothing is ever very far out of date, but you save yourself 5000 requests. Seems like a win-win. (I'm also a big fan of Varnish. I tried it out this weekend on a site that basically serves an HTML file that says "hello world". Apache c…

Rather than repopulating the same cache entries every 5 seconds you could instead actively purge the Varnish cache entry when the content actually changes.

Re: Using Flat Files So Elections Don’t Break Your Server

#35

This is exactly why I created StaticGenerator for Django: https://github.com/luckythetourist/staticgenerator

On the drupal side there is Boost: http://drupal.org/project/boost It has some fairly smart cache invalidation logic as well. At work we use the cache invalidation logic to tell varnish what needs to be refreshed. We use this setup for over 1,000 TV station news sites; supported by 10 boxes total. Flat file cache size is around 80GB. Our load is usually under 2 on all boxes.

Re: Using Flat Files So Elections Don’t Break Your Server

#36
post #11

I may sound naive here, but: if all you're doing is serving just 184 flat files, then why do you need all this RoR jazz? Can't a bunch of Apache/Nginx servers behind a load balancer (Varnish, TrafficServer, etc.) handle that just fine? Throw in a DNS-based scheme for failover/redundancy?

The load was for election night, which is more than likely a full order of magnitude, or two above their normal traffic levels. So their normal setup of RoR is fine for normal amounts of load, but would fail under that expected spike. So they used all their page-creation code in rails, but instead of serving it out like normal, they create the static files, and serve those. You lose out on interactivity, but make up for it in performance.

Re: Using Flat Files So Elections Don’t Break Your Server

#37
post #9
post #7

Forgive my ignorance, but does "flat file" mean "prerendered static HTML page" in this usage?

Sounds very much like it. From the article: >After each batch of new data was received from the AP, this server determined which pages needed to be re-rendered and, using the Typhoeus libcurl-multi bindings for Ruby, pulled new data for each of these pages from the render pool. Sounds like their infrastructure already has a farm of servers set up to handle rendering articles into their HTML components, so for this sc…

All righty... it was just a usage of the term "flat file" I was unfamiliar with. :-)

Re: Using Flat Files So Elections Don’t Break Your Server

#38
post #37
post #9

Earlier quoted context omitted.

Sounds very much like it. From the article: >After each batch of new data was received from the AP, this server determined which pages needed to be re-rendered and, using the Typhoeus libcurl-multi bindings for Ruby, pulled new data for each of these pages from the render pool. Sounds like their infrastructure already has a farm of servers set up to handle rendering articles into their HTML components, so for this sc…

All righty... it was just a usage of the term "flat file" I was unfamiliar with. :-)

Yeah, I think they made that up. I've only ever encountered the term "flat file" in the sense of a flat file database, such as a CSV file. As you say, pre-rendered static page is a much better name for it.

Re: Using Flat Files So Elections Don’t Break Your Server

#39
Ugh. They're not talking about Flat Files. They're talking about HTML. Saying so in the headline would have saved a lot of confusion.

A flat file is essentially a .csv holding data, and can be a fast way to bulk load denormalized data. As such, it actually does have a use in the context of scaling, so it's natural to expect that they were using the term correctly.

A static file, or more simple, a HTML file is what they're actually talking about. As they've noticed, it's what web servers are best at serving, and it scales obnoxiously well.

Now that we're all talking about the same thing, I can say that I've been serving all my product blogs as .html for years, and have never had any of them fall down under load.

It's really easy to get something in place to generate static files from a blog or CMS. I do it with:

- a 404 handler that maps missed requests for .html to their equivalent generator.

- a regular old blog engine that takes an extra parameter "writeThisToHTMLOnceYouveRenderedIt"

Future visitors skip the redirecting and generating and are simply served the static file. Next time you edit the content, you can simply blow away the whatever-blog-entry.html and index.html and know that they'll show up again next time anybody asks for one of them.

Re: Using Flat Files So Elections Don’t Break Your Server

#40

I have always been a proponent of the 5 second cache for things like blog posts. After you hit Reddit, you can see 1000 requests a second for a few minutes. If you cache for 5 seconds, nothing is ever very far out of date, but you save yourself 5000 requests. Seems like a win-win. (I'm also a big fan of Varnish. I tried it out this weekend on a site that basically serves an HTML file that says "hello world". Apache c…

Why stop at 5 seconds? Unless you're updating that blog entry every 6 seconds, you're missing out on a bunch of good caching by regenerating it 12 times a minute.

How about cache it once at write-time, then again whenever you edit it?

Post reply on HN