If you ever coded with Ruby on Rails, you probably are already aware that Garbage Collector is its Achilles’ heel. Though it has been significantly improved through the last couple of years, it still has plenty room for improvement. It is hard to find a Ruby app that would be happy with default Garbage Collector settings. To help you with this, we decided to share with a pretty handy tool called TuneMyGC. Learn about it now!
What is TuneMyGC?
TuneMyGC is a product designed to provide repeatable and systematic tuning process of Garbage Collector in order to make your development faster and more enjoyable. It works as a lightweight agent, which suggests GC configuration and additional tips and insights. Sounds pretty good. But how does it work?
Have a look at rough scheme of its interaction with your application.
Why should I use TuneMyGC?
If your are still a bit skeptic about this product, have a look at the main benefits it brings about:
- Faster boot times
- Less major GC cycles during requests
- Less worst case memory usage
- No need to keep up to date with the C Ruby GC
And here’s comparison of GC default settings to suggested TuneMyGC ones:
As you see, TuneMyGC is a real treasure for those, who are looking for ways to improve the performance. Let’s see how to install it.
How to install TuneMyGC?
Luckily, installing TuneMyGC isn’t a lot of pain. Just follow the instruction.
- Add it to your Gem file
- Register your app
1$ bundle exec tunemygc -r email@example.com#Application registered. Use RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d51 in your environment.
- Boot the application. Recommended Garbage Collector configurations will be provided in a report after it ends.
1$ RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d51 RUBY_GC_TUNE=200 bundle exec rails s
As you see, al work would take you less than 15 minutes, but as a result you will get GC configurations that work best specifically for your app.
We, Rubyroid Labs Team, highly recommend using this gem for optimization. And how do you cope with Ruby Garbage Collector? Share with us in the comments!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?