Obama Day Caching Funtime

January 30, 2009
Obama Day was caching day!

Obama Day was caching day!

Obama day was sort of intense! Not only did Aretha Franklin have a sweet hat, but all the internet traffic on CNN Live put the hurt on old skool Spongecell Promote. Chris  saved the day by quickly page caching the content that was in high demand. So basically some files were copied and everyone was happy (except maybe Texas?)

This trick is super obvi, but hella useful, yo. But, <tear>, its not a permanent fix. Alas, not every day can be Obama Day ! So I set out to fix this permanently. We need to page cache for one customer who always sends the same request, expire the page when the data changes, and action cache for everyone else who is not logged in.

So I wrote a tiny little conditional page cache plugin to let you choose your caching type at runtime. You want to page cache giraffe 1, action cache giraffe 2 when they are green and serve everything else straight up.

class PictureController

  conditionally_cache :giraffe

  def page_cache?; @giraffe == 1; end
  def action_cache?; @giraffe = 2 && @giraffe_color = 'blue'; end

  def giraffe
    @giraffe = blah_blah

To clarify the temporary caching trick:
Suppose you have: http://snowgiraffe.com/pictures/giraffe/1.html

Then you simply move the file to:

Fastest CDN to Sacramento

August 27, 2008

I tested content delivery to a server we have at Engine Yard in Sacramento.

We are testing CDN’s for our flash delivery so I tested with a 160kb swf file. Media Temple doesn’t claim to be a CDN but I tested it anyways on it’s budget grid server. Panther and Edgecast are CDNs. I did all testing using apache bench from a slice in Engine Yard cluster EY01. The Intranet test was with content from a slice in their cluster EY02. This was a baseline since the servers are probably only meters from each other. S3′s latency is a big reason we’re looking for a good CDN.

.mac was the surprise contender and they only cost $100 a year. Perhaps we were just geographically lucky. They limit to 100gb a month and we hope to be serving more flash than that so .mac is not a realistic solution. Their consumer agreement is not sufficient as well but in reality neither is S3′s.

I tested 10,000 requests with a concurrency of 10. I repeated the ~4 minute test to make sure numbers were settled. The huge bias was location and perhaps time of day. Tests were done at noon on 8/27/08.

Conclusion: the two CDNs performed better than the non-CDN delivery. This data isn’t fair nor significant enough to rule one CDN better than the other.

Layered Tech vs. Engine Yard

June 4, 2007


This is not a fair test. Yesterday we upgraded from the bottom of the line Layered Tech dedicated server to 2 slices from Engine Yard. I wanted to see what our money was getting us so I did some benchmarking.

The Contenders

We have had an AMD Sempron 2600 1gb from LT since December 2005. It’s been awhile, no? Our machine there was running Apache 1.3, no gzip compression, FastCGI and MySQL 5.0. We had been trying to upgrade to another system with 2 very nice guys from San Francisco but they weren’t able to get the job done. Finally we contacted EY and they got a system ready for us in just a few weeks.

We are using 3 slices at EY in production. One of those slices is utility and was not included in this test. Each slice is 512mb and has 4 mongrels. EY manages the load balancing and database layer. Gzip compression is enabled.

The Fight

3 different pages were benchmakred.

Static Page – This page has no db hit but spends time rendering. There is no cache on this page.

Event Page – This page is not cached. It spends a bunch of time rendering and hitting the database.

Embedded Calendar – This page is cached so there is no db hit for this test. The result was 240kb from LT and 18kb from EY thanks to the gzip compression. That makes this particular test very biased in favor of EY.

All of the above tests were done using Apache Bench with 1,000 or 500 requests and a concurrency of 10. Each test was run at least twice to make sure there were no anomolies. The tests were run from a shared Dream Host account.

The Winner

Engine Yard wins! This is really not too surprising if you compare the price of the cheapest LT server to 2 slices at Engine Yard. In the first two tests LT was comparable to a single slice. For the third test I think that if we had gzip enabled in Apache the embedded calendar would have been comparable as well. LT does not have the load balancing, firewall, and db management (including replication) so in my opinion EY is well worth the price.

So far I received a lot of positive comments from users about the new snappiness of our site. Engine Yard has been very helpful in the last week to get us up and running. Tom Mornini was even helping me iron out some last details Saturday night after midnight! Below is a picture of Tom in a Spongecell t-shirt at RailsConf2007.

Thanks Engine Yard!



Get every new post delivered to your Inbox.