High Availability with Unicorn Zero Down Time Deploys

December 17th, 2009

If you have not heard of unicorn and you actively develop ruby applications for the web. It is no doubt well worth your time to check it out. Github has a very good write up about unicorn that is definitely worth reading. Let me first show you this quick video of deploying to our yet to be released client site while sieging.

Read more…

Software

Sitemaps and Siege

December 17th, 2009

If you are like me and always want to test the performance of your sites before releasing them to the public eye and you have an interest in publishing sitemaps to google and friends. This handy ruby script might be just the thing for you.

Assuming you already have your sitemap.xml file, if not try googling

Next run the ruby script, given the sitemap.xml file as the first argument:

ruby sitemap-to-siege.rb sitemap.xml

That will create the urls.txt file.

Now run siege:
siege -c50 -t1M -f urls.txt

Note on mac you can install siege with
sudo port install siege
On redhat:
yum install siege
Or grab the source.

Software

Updated Theme

December 16th, 2009

Okay, I really liked this theme last year when I installed it but today I decided it was time for a change… Well a minor change, I hacked up the theme to support a variable width grid. Setting a min-width and width:%% to allow the content area expand.

Software

Follow up on caches_action and content_for blocks

December 16th, 2009

Alright, I worked on a solution today to follow up on my earlier post… This is very raw, but showing some good signs of working. I’ve been testing locally against memcached. One concern, I have with this solution is the content_for block is cached in a separate key, if the action key expires after the content_for key, then some requests might render without the content_for content… Perhaps, before rendering the action from cache we need to check that all fragments are available? This could also make it possible to do a multi get from memcached as well? Let me know what you all think.
Read more…

Software

caches_action and content_for blocks

December 16th, 2009

Today, I realized that using content_for blocks as nice as they are make it much harder to cache.   Typically, I won’t cache the layout for my actions so I would end up with a caches_action expression like the following:

caches_action :index, :layout => false, :expires_in => 10.minutes, :if => Proc.new {|c| c.send(:current_user).nil? }

However, I also started to add multiple yield blocks in my layouts.  For example:
Read more…

Software

Anerian & 1901 Group raise money for charity: Teardrops to Rainbows

October 21st, 2009

Safe MemCache client wrapper

October 5th, 2009

I find it really annoying that memcache-client raises exceptions when the memcached server is down…  In my opinion, if memcached isn’t there it’s a cache miss, not an error.  So, I figured it should be okay to have a SafeMemCache wrapper around the normal MemCache object that rescues MemCacheError and returns nil…  Here’s what I have so far, was thinking there is probably away to safely wrap any method with another function using ruby dynamically, rather then repeating… but here’s what i have… so copy & paste.

#
# A Safe Wrapper around memcache client that will not raise exceptions
#
class SafeMemCache < MemCache

 def decr(key, amount = 1)
 super
 rescue MemCacheError => e
 nil
 end

 def get(key, raw = false)
 super
 rescue MemCacheError => e
 nil
 end

 def fetch(key, expiry = 0, raw = false)
 super
 rescue MemCacheError => e
 nil
 end

 def get_multi(*keys)
 super
 rescue MemCacheError => e
 nil
 end

 def incr(key, amount = 1)
 super
 rescue MemCacheError => e
 nil
 end

 def set(key, value, expiry = 0, raw = false)
 super
 rescue MemCacheError => e
 nil
 end

 def cas(key, expiry=0, raw=false)
 super
 rescue MemCacheError => e
 nil
 end

 def add(key, value, expiry = 0, raw = false)
 super
 rescue MemCacheError => e
 nil
 end

 def replace(key, value, expiry = 0, raw = false)
 super
 rescue MemCacheError => e
 nil
 end

 def append(key, value)
 super
 rescue MemCacheError => e
 nil
 end

 def prepend(key, value)
 super
 rescue MemCacheError => e
 nil
 end

 def delete(key, expiry = 0)
 super
 rescue MemCacheError => e
 nil
 end

 def flush_all(delay=0)
 super
 rescue MemCacheError => e
 nil
 end

 def reset
 super
 rescue MemCacheError => e
 nil
 end

 def stats
 super
 rescue MemCacheError => e
 nil
 end

end

Software