Rails performance analysis with New Relic
New Relic offers Rails performance monitoring and profiling as Software as a Service (SaaS). We talked to Lew Cirne of New Relic to find out how the technology works.
InfoQ: How's your performance monitoring implemented, what's the performance impact? Does it run on Ruby versions besides MRI?
Our Agent is implemented in 100% Ruby code, and therefore runs in any Ruby environment on any hardware/os combination, and in any Ruby VM implementation. This includes the reference implementation as well as JRuby and Rubinius. We use Ruby's dynamic language features to place lightweight "tracers" on relatively heavyweight operations like Controller actions, ActiveRecord queries and the like.
This is a relatively simple concept, but it is very difficult to do really well. Fortunately, we have deep experience in doing things like this from building Wily Technology's Introscope, which is the industry leading application performance management solution for the enterprise Java platform. So while it is possible that a poorly written agent using these approaches might impact the performance or stability of an application, ours does not. Our testing shows that we add no more than 2-5 milliseconds on a transaction's response time, and our CPU consumption is also very low (well below 5%.) And yet we provide incredibly deep performance data of what the application is doing in near realtime.
Since we don't analyze log files after the fact, we get several benefits: - we can report this data much more quickly (once per minute) at lower overhead and zero disk/io - we can get very deep visibility, and that visibility is easily customizable - if it's a ruby method, we can trace it. - There is no extra process to deploy, maintain or consume resources on the production machine
We have 50 private beta customers using RPM in private beta - many of them are very high volume rails sites - and none are experiencing any problems with regards to our agent technology.
InfoQ: New Relic is described as working as SaaS - how is this implemented? Is the gathered information sent over the network to your service?
The agent that I described above reports the performance data it gathers once per minute to NewRelic.com via http or https, depending on the customer's preference. This data is presented in a collection of highly intuitive views that answer some of the commonly asked performance questions for a live rails application, such as:
- What are my slowest controller actions?
- How is their performance changing over time?
- How does a specific controller action's response time break down?
- What ActiveRecord objects are most often queried? Or saved? What are the slowest ActiveRecord finders?
- Am I missing an index?
InfoQ: What kinds of performance problems are currently recognized and reported by New Relic? Would bad coding practices, missing caching, etc. be discovered?
Those are two excellent examples. Another example we see a lot of is when the application invokes a large number of (possibly quick) active record operations in a tight loop that in total add up to a lot of database utilization. the DB tools say that it's performing well, but the app may be abusing the DB by issuing many queries when one query could do a better job. We also track memcache usage by controller action which is another common area of focus for high performance and scale rails sites.
InfoQ: You mentioned one user of New Relic - Lighthouse - do you have a list of other customers that you can mention?
Though we are still in private beta, we have a lot of customers that I would consider to be the "who's who" of the rails community. Lighthouse is a great example of that - Rick Olson is one of the core developers on the Ruby on Rails platform and is known as a prolific contributor to the rails community. His endorsement means a lot, in my opinion.
Other customers that are on-record as being big fans of New Relic are Moku Gift (give an E-Tree and they'll plant a real one!), Redeparede.com (social networking with focus on non-english speaking markets), and Hutz.com (vacation home rental marketplace). Expect more endorsements from our customer base in the near future.
InfoQ: What kind of licensing model or pricing structure do you plan?
We haven't announced specific pricing yet, but when we do, RPM will be offered as a subscription-based service for which customers will pay a monthly fee that will scale with the size of their managed environment.
RubyInside's coverage of New Relic, which also mentions New Relic Inc's recent $ 3.5 million venture financing, points out another performance monitoring solution in FiveRuns' RM-Manage.
For general performance tips for Rails applications, you can also check out James Cox' resentation "Managing a high performance Rails app without tearing your hair out" here at InfoQ.
Iordanis Giannakakis, Savvas Dalkitsis Aug 28, 2015
Ben Linders Aug 28, 2015