The APM gives you an overview of how your application is performing: performances, error rate, throughput, transactions per second, etc...
Transactions
You can track Web Transactions (API calls) and Non-Web Transactions (background jobs)
Troubleshoot slow transactions
When navigating to the transactions tab, you can find the list of most time consuming transactions.
Transactions taking more than a configured threshold will be listed under the transaction traces and can be analysed more precisely to identify bottlenecks.
The list of usual suspects to look at:
- Slow database queries (missing index, in-memory aggregation of data, N+1)
- Nested loops
- Lack of caching
Good tips to improve ruby code performances can be found here: https://github.com/JuanitoFatas/fast-ruby
Databases
This gives extremely useful information about your database queries and response times. It helps you finding inefficient database queries which most of the time are the applications bottlenecks.
Slow database queries will be listed on this page with hints to improve performances.
Ruby VMs
The Ruby Virtual Machine manages the memory allocation throughout objects life-cycle. The Garbage Collector (GC) kicks in to destroy unreferenced objects and free memory space.
If your Ruby VM runs out of memory, the GC is executed more often to free memory space. If no object can be destroy, the Ruby process will run out of memory, the GC will require a lot of CPU and the server will become slower. This kind of memory leak needs thorough inspection of the code to be addressed.
Things to look at:
- Are the objects instantiated referenced in an array, other objects via associations
- Are unbound collections loaded via has_many associations
- Can objects processing be batched (look at ActiveRecord find_each and find_in_batches methods)
- Are large files loaded (CSV, JSON) and parsed in memory