another redis automatic failover solution for ruby

13 Jan 2013

Redis gets more and more popular as a backend storage, so the redis failover solution becomes important before you use redis as a critical resource.

Currently the most popular automatic master/slave failover solution for ruby is redis_failover, it's based on ZooKeeper, if you already have ZooKeeper in your infrastructure, it's great.

But I noticed that redis already has a built-in automatic failover solution, called Redis Sentinel. In case you didn't heard of it, please read the official document, it's simple and no other external dependency. I searched on github...

Read More

Tags 


newrelic-grape released

21 Dec 2012

No instrumentation, no performance tuning!

This is my first time to use grape to build an api service, grape repo has more than 2k watchers, but I'm surprised there is no existing newrelic grape suppport, I just found some gists to do it, and this blog post gave me the idea to add newrelic instrument as grape middleware, but it's not the standard way newrelic recommends.

So I released newrelic-grape gem to help you integrate newrelic into grape.

What you need to do is

require "ne...
Read More

Tags 


How I find out a memory leak in grape

16 Dec 2012

I'm helping my customer build a high performance api service these weeks, we are close to release, but when I did load test this Wednesday, I found the memory kept growing when I sent traffic and never went down, it was obviously a memory leak.

Lucky is I can reproduce the memory leak on my local machine, so I can detect it easily. Our api service is simple, only contains model layer (AR and redis) and api layer (based on grape). At first, I disabled model layer, but memory lea...

Read More

Tags 


JRuby at OpenFeint - a JRuby migration success story

14 Nov 2012

TL;DR: OpenFeint gets 40% performance improvement after migrating to JRuby from REE.

About OpenFeint

OpenFeint was the largest mobile social gaming platform in the world, It was acquired by GREE for $104 million last year, and a new global platform is building to replace OpenFeint. It is still one of the biggest rails applications, with hundreds of thousands API calls per minute.

OpenFeint platform is using rails 2.3.14 and was running on ree 1.8.7.

Why try JRuby

My main job is to improve the performance and scalability of OpenFeint platform. This April, I attended Railsc...

Read More

Tags 


switch_user 0.9 released

31 Oct 2012

switch_user provides a convenient way to switch current user that speeds up your development and reproduce user specified error on production.

Today switch_user gem 0.9.0 is released, all thanks to Luke Cowell.

He is a collaborator of switch_user gem, and did a great job for 0.9.0 gem.

  1. did lots of refactors.
  2. added unit tests.
  3. made switch_user a rails engine.

check out the changelog here.

I also updated switch_user example to use switch_user 0.9.0.

Read More

Tags 


zero downtime deployment

23 Oct 2012

This is my new post on jrubytips. It teaches you how to achieve zero downtime deployment for jruby servers.

http://jrubytips.com/posts/5-zero-downtime-deployment

Read More

Tags 


set proper value for CodeCache

19 Oct 2012

This is my new post on jrubytips. It tells you the jvm CodeCache which may affect your server performance.

http://jrubytips.com/posts/4-set-proper-value-for-codecache

Read More

Tags 


newrelic-rake released

12 Oct 2012

4 months ago, I released newrelic-workling gem, which helps us montior the performance of background jobs. We used it to find out a GC performance issue. But we still have some cron jobs, who call rake tasks, running in the black box.

So I created a new project newrelic-rake that adds newrelic instrument for rake tasks. Now when I go to the newrelic, I can see the rake tasks listed in Background tasks section, it shows me the average execution time and call count for all rake tasks.

newrelic rake tasks

I can also see the performance breakdown for each rake...

Read More

Tags 


avoid using rubyzip

02 Oct 2012

More precisely I want to say allocating as less objects as you can, rubyzip is just an example.

We have a background job compressing webui assets, uploading to S3, so mobile sdk can download assets to update webui dynamically.

After iphone5 and ios6 came to the market, we received much more webui req...

Read More

Tags 


speed up git deployment with depth 1

14 Sep 2012

By default, when you deploy your application by capistrano git, it will clone the repository with entire history on production server, but it's meaningless. You should never go to production host and check git log, instead you just need latest code on production host.

With your application grows, git clone with entire history may take a bit longer time than you expected. The following is the time spent with fully cloning.

$ time git clone g...
Read More

Tags