This Cyber Monday Tuts+ courses will be reduced to just $3 (usually $15). Don't miss out.
You already know that New Relic provides deep performance metrics for your Java, .NET, PHP, Python or Ruby application. But are you familiar with the power features that can bring your knowledge about your app to a new level? Don't let the name fool you. While these features have serious power, they are easy to get started with. In this tutorial, I'll get you up and running with three powerful New Relic features you should be using today.
One of the most powerful features available to Ruby developers is Developer Mode.
Developer Mode gives you high visibility into the transactions being executing on your local development machine.
You'll be able to immediately see in-depth transaction traces, including response times, individual method calls and SQL queries. Developer Mode jumps straight to the code block that is being executed, something you can't do on the normal rpm.newrelic.com site.
Instead of talking about Developer Mode, let's just dive in and take a look at it in action. After installing New Relic into your application, and clicking through a few actions, you'll have a list of transactions to explore at
Click on one of the URLs in the list and you'll get a Summary view of the entire request.
From this view, you can see every step in the request, from template rendering through the actual SQL time. In the example above, you can see that 53% of the request time was spent rendering the
show.html.erb template. This is an excellent place to implement some fragment caching to speed up the request.
From the Detail view (as shown below), you can explore each step of the request, starting from the controller and action being called, through each additional method, template and SQL query. Clicking on a line like
User#find_by_sql will take you to the exact line of code that made that method call (below, lower).
Finally, you can see every SQL query that a request makes by looking at the SQL view. From there, you can spot any duplicate SQL requests you might have made and go straight to the line of code that is creating it. Or, you can view detailed information about the statement to explore in-depth review of the query for information on the number of tables used, rows scanned and indexes accessed.
Having detailed performance information about your application, down to the line of code, is invaluable during development. The power of Developer Mode can really only be appreciated by using it, so, if you'd like, sign-up for a free 30-day Pro Account and give it a try.
The New Relic agent collects a massive number of metrics about your application with very little effort, but knowing how an application is technically performing isn't the whole picture. You need to know how your business metrics are performing in your application. Custom metrics, such as order value, login attempts and signups/registrations can all be collected within New Relic, and compared against the technical performance of your application.
Below is an example of a custom metric using the Python agent, but the concepts are the same for the other languages.
As you can see in the example above, we're sending one of two custom metrics whenever an order is processed. If the order succeeds, we send the dollar value of the order. Or if the order fails, we send a counter instead. Recording custom metrics like these can provide a deeper understanding of the impact that your application's performance has on your business metrics. In the case of the failed orders, by using custom metrics, you can spot problems sooner when you spot a spike in the failing metrics (e.g., your payment processor is down).
You can use custom metrics for recording timing data as well. This is an excellent way to monitor the response time of an external service you depend on.
Custom metrics should always have a name that begins with
Custom/* in order to avoid any namespace collisions with the native agent metrics. Once you have these custom metrics, you can get some real visibility by combining multiple native charts with charts of your custom metrics on a Custom Dashboard. If you aren't already, you should start collecting the metrics that are critical to your business with a free 30-day Pro Account.
It certainly would be nice to know if your app will be able to withstand a sudden surge in traffic before you actually hit the front page of Hacker News. But knowing which component of your application could be the bottleneck is hard. Will it be the application itself? Your database layer? Or maybe even the CPU utilization will be overwhelmed?
The final power feature you should be using today is the suite of Scalability Analysis reports that show you your app performance. In an ideal world, your application performance should hold fairly steady as the load increases throughout the day. You can see in the chart below that as the requests per minute (X-axis) increase, the application response time holds steady (Y-axis).
If, on the other hand, your app is not equipped to scale with increases in request, then you will see a chart with a steep slope like the one below. Here you can see that as the number of requests increases, the database response time also increases dramatically.
These types of trends are very difficult to spot without such rich visualization. Optimally, you want to see the response time grow fractionally with the increased requests. If you find that your application response time is growing geometrically with the increase, then it's time to optimize. Since you never know when your application is going to need to scale, it's important that you keep an eye on it's scalability as it grows. Tools like the Scalability Analysis and Capacity Analysis reports are a great way to easily make performance monitoring part of your routine.
If you haven't already, you can sign up for a free 30-day Pro Account at New Relic to try these and many more power features that will keep your application performing at its best.