Top 10 KPIs To Measure For Rails Applications

Rails is already tracking and measuring a multitude of metrics or Key Performance Indicators (KPIs) for you. All you need to do is figure out where the data lies.

Are you familiar with ActiveSupport? ActiveSupport is a RubyGem providing Ruby language extensions, utilities and more. The connection adapters of ActiveSupport are used by Arel to connect to various engines, perform quoting, connection pools, and do type conversion. I’m getting ahead of myself here. Now, Arel is a library used on a daily basis by lots of Rails developers. Arel acts as the basic building block for frameworks to build APIs more suitable for the end user. These frameworks help us build and represent SQL queries. You could say that Arel is an SQL, Abstract Syntax Tree (AST) Manager for Ruby.

ActiveSupport also comes with an Instrumentation API. This allows developers to provide hooks for other developers to hook into. These hooks are called with SQL queries on a database. Subscribe to the database with a custom listener, and you’ll find many hooks or events. The moment you do come across one, Rails introduces you to useful data. When you customize these events, you get more useful information out of the data.

If you’re just starting out, take advantage of Google Analytics. It’s free, easy to setup and provides you traffic and usage information. Later on, you can identify the KPI’s that are important to your company and adopt methods and tools, which help you measure them. There are also Gems that help with analytics like Redis. These RubyGems are for custom implementations like ActiveSupport. You can also look into Segment.io, which is a SaaS data warehouse that connects to dozens of popular SaaS products. Like most analytics tools, you need to install Segment’s JavaScript library to access and run reports.

KPIs you should measure:

1. Time between events

A measure of the time between events gives you more clarity on how elapsed time affects your product’s user experience. To measure this use another hook around the processing of an action and it tracks the amount of time taken by specific events. You can also track events through Google Analytics.

2. Database & service time

The time spent interacting with the database is an indication of problematic queries that may need to be rewritten to optimize performance. The service time is the external interaction time. New Relic, a popular application performance monitoring tool, helps you tackle these issues.

3. Number of users & request count

This gives you a general overview of site traffic. You can measure this by running some Arel queries until you find the events you’ve been searching for. Use AREL to build SQL Queries. Once you choose your queries, put them through a rake test. If you need this information often, create a Cron job that runs each hour, day, week or month and sends the report to your stakeholders via email. You can also use Mixpanel to measure user metrics, which is a paid service with lots of great features you don’t have to build custom, so your development team can focus on building a better product.

4. Queuing time

New Relic helps you identify the hidden latency issues affecting your server’s response time. It finds the application code causing performance issues. For instance, take the case of an action controller responsible for deciphering requests and producing appropriate outputs. A chart depicts the slowest controller actions for you. New Relic is the best tool for measuring queuing time because it lets you zoom into specific issues to see what’s causing the slowdown.

5. Conversion events & benchmarking

Adopt the Google Analytics’ conversion funnel. Simply put, it tracks events set up by engineers or business users. The tracking can be for specific parameters such as page value, per visit goal value, goal conversions, social sharing, user behavior and more. The key is to identify where users aren’t doing what you want them to do and making changes, so more users convert. Benchmarking helps you identify how you are doing when compared to your previous tests or other companies in your industry. You can also use MixPanel as an alternative to Google Analytics.

6. Speed and memory constraints

With a single run of performance tests, you better understand your application’s speed and memory constraints. The MiniProfiler gem and the Flamegraph gem provides useful profiling information.

7. Time spent processing requests

A log analysis done on your Mac gives you information on the time spent processing requests. It also provides specifics on rendering time and cache details so you can identify and fix bottlenecks.

8. Slow spots

The Rails Analyzer Gem comes with multiple tools you can use to identify slow spots. You can use the Slim Scrooge Gem, which is an optimization layer.

9. Network performance

Firebug is a plugin for Firefox that monitors network performance for you. RailsPanel is a Chrome extension that gives you much of the same insights into the performance of your network.

10. Security vulnerabilities

Breakman is an open source gem and a static analysis tool, which scans your Rails applications for security vulnerabilities. Breakman is an ideal tool to employ for the continuous delivery pipeline. Running this tool on every commit helps identify vulnerabilities that could pop up at any stage of your development process. Do look into Breakman Pro for advanced features.

I hope this proves useful in helping you define the KPIs you need to track.


Need help with product design or development?

Our product development experts are eager to learn more about your project and deliver an experience your customers and stakeholders love.

Read more