Live data from Hacker News

Using Flat Files So Elections Don’t Break Your Server

open.blogs.nytimes.com

21–30 of 51 posts

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

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

It's risk mitigation... this is one way you can deal with unpredictably large spikes in traffic.... for the NYT - elections probably represent their extreme.

For the regular ebb and flow of data, you can plan, and use varnish/rails/nginx/ all the magic tools you want, and things will work great - but you also have added complexity, and when something goes wrong, the more complex the system, the longer it generally takes to fix. Especially under unexpected heavy load.

Simplifying the system down to flat files and de-coupling the ROR stuff gives you a clear troubleshooting point - if something goes berzerk, you can cut the link between the two and troubleshoot in relative safety before turning replication back on.

I'm rambling - the main point is to reduce the complexity involved in the end-user transaction to be as efficient and fast as possible so you can deal with an unknown load factor coming in on a really important day. Going down that day would be BAD for business.

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

#22
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…

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 way to go?

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

#23
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…

If you look at the current webserving stacks propagating out there, wev'e gone from apache to multi-layered stuff, haproxy/varnish/nginx/apache/mongrel/rails/ various fcgi/etc..... and the thing to keep in mind is there is overlap between most of these projects.

Apache can, one way or the other, do most of what the others can do - possibly not as well, and at the risk of a much more complex configuration.

Haproxy does one thing and does it really,really well - it's great for dealing with load balancing, concurrency limiting per user defined resource, and identifying and routing incoming requests to the right infrastructure. It's really good at this - that's what it does.

Varnish does one thing and does it really, really well - it caches content and serves it up (usually out of memory, but even if it's swapped, it's optimized) to keep the load off your application servers. It has various optimizations built into make it really good at this.

So - in this case, the answer might be "not much - we could just put the apache's out front behind haproxy" - but it appears putting the varnish server out front with a 5 second cache dropped the load on the application servers (in this case apache serving static files that it receives over rsync - dont' forget the rsync part - resources are needed for that). This might result in smoother output for the end user, rather than something hitting a node that's busy servicing an rsync update. It may also be their engineers are very familiar with the haproxy/varnish front end setup, as it presumably exists in their current day to day operation as well.. so the people responsible for keeping things up probably decided "Yes, we'd like to keep it there - it makes our lives easier."

There is an operational anti-pattern in there - removing too many elements from a known system is also a kind of added cmoplexity - all your troubleshooting methods disappear.

Their goal here was to de-couple the dynamic elements from the event-driven side of things and turn them into something more resilient (and less flexible) for a short time to deal with unknown and unpredicably large load.

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

#24
post #6

Earlier quoted context omitted.

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.

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.

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

#25
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…

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…

HAProxy is very light. We put it between nginx and our webservers for better failure handling, load-balancing, and some additional logging detail. On a small system (single AMD 1226) it's averaged 3% CPU over the last 15 days while handling ~300M requests.

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

#26
post #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…

When dealing with unpredictably high traffic spikes, on days when you cannot afford any kind of downtime - when that downtime comes at great cost, it's not overengineering (and it's hard to determine if it's overengineered until you know the budget and time spent on the actual project - this may have been a relatively simple modification all things considered)

Static content is easy to crank up to web-scale. You can use DNS, any kind of load balancer, all kinds of web services, CDNs, whatever.

Dynamic content is hard to scale (compared to static). You have several layers of added complexity. Yes, you can build wonderful, self-scaleable systems - but at some point they hit a limit, there are many more resources that can be tied up, and troubleshooting and scaling that out beyond anything you've previously imagined on short notice can take time you can't afford.

So - simply de-coupling the dynamic content generation from the static web serving is a great way to make a clean break - you now have a known & tuneable load on your dynamic application (because your'e running it at known intervals, rather than being event driven by user requests) and you have a front-end static infrastructure that you can scale like mad, and even if your back-end collapses, edit by hand.

Surely there are other ways to approach the problem.... but it also depends on the engineers involved, the time taken, and their confidence in their ability to deal with it.

I'm also fairly sure they aren't the first company out there to take this approach to burst scalability issues... but it's curious to note how the NYT actually operates.

TL;DR: Look at the old configuration, and the new configuration. Decide which one will best serve your business in terms of your ability to troubleshoot it when it gets hit by a level of traffic higher than you can plan for, because you have NO idea how high it will go.

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

#27
post #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…

In my book, overengineering is defined as doing more work than is necessary to ensure that the risks are within acceptable bounds.

As the author points out, having the Times election site go down on election eve would be a BIG PROBLEM -- massive losses in both reputation and advertising revenue. For the system architect, a failure could possibly mean losing his job.

What the author has laid out is a system that is robust to multiple, simultaneous failures (with possible exception of the loss of AWS, although that's not entirely clear). That just seems like good planning.

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

#28
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…

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.

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

#29
post #16
post #8

Earlier quoted context omitted.

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

I understood the joke perfectly, it's just not that witty...

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

#30
post #24

Earlier quoted context omitted.

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.

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).
Post reply on HN