Live data from Hacker News

Using Flat Files So Elections Don’t Break Your Server

open.blogs.nytimes.com

11–20 of 51 posts

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

#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?

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

#12
the filesystem is just another datastore. using it like this means you're spreading out the requests per second across each individual server's available IO, however you've also forsaken the "getting data from point a to point b" features of other datastores and therefore have to do it yourself (usually rsync).

to be honest, since there wasn't actually a problem to solve as varnish is setup as both an HA environment and to use the grace/saint features, this is a case of overengineering in my book.

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

#13
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?

Ruby on Rails is generating the flat files, while apache et al. are serving them.

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

#14
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 can do about 11,000 requests a second, but Varnish can serve 15,000 requests a second. Excellent!)

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

#15

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…

You get 1000 requests a second from Reddit? Wow, it's a whole lot bigger than I thought.

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

#16
post #8

Slightly off-topic, but the title of this blog (column?) is amazingly clever: "All the Code That's Fit to printf()"

Your threshold for amazing is pretty low. :P

Would your impression of the pun be improved if I said that the NYT's motto, on every masthead for over a century now, has been "All The News That's Fit To Print"?

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

#17
post #15

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…

You get 1000 requests a second from Reddit? Wow, it's a whole lot bigger than I thought.

Needs to prove it!

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

#18
post #6
post #3

It's nice to see detail like this on high-traffic, high-risk environments. I'm curious about their provisions for cross-datacenter failover. The article mentions haproxy being ready to direct requests to a different datacenter as well as ELB spanning availability zones. I'd expect a failover option entirely outside AWS as well, with short-TTL DNS ready to make the switch. I'm also not sure what value varnish brings t…

Doesn't Varnish handle many times more concurrent clients than apache does, at significantly lower system load? It could just be pure optimization.

It does. Apache is strictly one process per connection, varnish handles hundreds, thousands or even tens of thousands of connections with just one process so the overhead is minimal.

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

#19

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…

Chances are that you will need to do some serious kernel tuning before you will really run in to the limits of what varnish can do.

If you're using linux using IPV4 have a look at the following parameters in /proc/sys/net/ipv4:

tcp_tw_recycle

tcp_tw_reuse

Tuning those will help in allowing faster re-use of sockets in the TIME_WAIT state. This matters because at the defaults your sockets will linger for a long time before being allowed to be re-used (as per the RFC). Technically this is the correct behaviour but it can quickly become a bottle-neck.

Ulimit max open files per process:

ulimit -n 50000

The default is just 1,024, and that's not nearly enough to keep varnish working hard.

Those are the first things to look at, there are many more once you start to bottom out again, but this will get you started.

A good way to see if you've got your kernel tuned properly is when varnish starts to approach the limits of your hardware, I've seen it do well over 600Mbps on an otherwise unloaded box.

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

#20
post #15

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…

You get 1000 requests a second from Reddit? Wow, it's a whole lot bigger than I thought.

Now that I am remembering better, I actually hit the front page of Reddit and del.icio.us at the same time. Those both drive a surprising amount of traffic. (The article was "Git merging by example", now archived here: http://blog.jrock.us/posts/Git%20merging%20by%20example.pod)

I did not use varnish at the time, but I basically kept up with the load. My pages were cached with an in-memory cache in the app layer, which worked well enough, I guess. As blog.jrock.us mentions, I was unhappy with the design of my software, so I took it down. Two years later, I almost know what a good design is, and so I should have a blog again soon. But I digress :)

Post reply on HN