<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>New Relic blog &#187; Performance Tech Tips</title>
	<atom:link href="http://blog.newrelic.com/category/performance-tech-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.newrelic.com</link>
	<description>Application Performance Management</description>
	<lastBuildDate>Thu, 23 May 2013 00:37:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Simple JavaScript Testing with QUnit</title>
		<link>http://blog.newrelic.com/2013/05/15/new-simple-javascript-testing-with-qunit/</link>
		<comments>http://blog.newrelic.com/2013/05/15/new-simple-javascript-testing-with-qunit/#comments</comments>
		<pubDate>Thu, 16 May 2013 03:50:49 +0000</pubDate>
		<dc:creator>New Relic</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12904</guid>
		<description><![CDATA[<p>Matthew Setter is a professional technical writer and passionate web application developer. He’s also the founder of Malt Blue, the community for PHP web application development professionals and PHP Cloud Development Casts – learn Cloud Development through the lens of PHP. You can connect with him on Twitter, Facebook, LinkedIn or Google+ anytime. Summary As developers, we’re taught the importance of testing right from [...]</p><p>The post <a href="http://blog.newrelic.com/2013/05/15/new-simple-javascript-testing-with-qunit/">Simple JavaScript Testing with QUnit</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><em>Matthew Setter is a professional technical writer and passionate web application developer. He’s also the founder of <a title="Malt Blue" href="http://www.maltblue.com/" target="_blank">Malt Blue</a>, the community for PHP web application development professionals and <a title="PHP Cloud Development Casts" href="http://www.phpclouddevelopmentcasts.com/" target="_blank">PHP Cloud Development Casts</a> – learn Cloud Development through the lens of PHP. You can connect with him on <a title="Malt Blue's Twitter account" href="http://twitter.com/maltblue" target="_blank">Twitter</a>, <a title="Malt Blue's Facebook account" href="http://www.facebook.com/MaltBlue" target="_blank">Facebook</a>, <a title="Malt Blue's LinkedIn company page" href="http://www.linkedin.com/company/malt-blue-limited" target="_blank">LinkedIn</a> or <a title="Matthew Setter's Google+ account" href="https://plus.google.com/111401831637298616557/posts" target="_blank">Google+</a> anytime.</em></p>
<p><strong><span style="font-size: 1.25em;">Summary</span></strong><br />
As developers, we’re taught the importance of testing right from the beginning. Testing helps us write better code in less time and makes us feel more comfortable with the eventual outcome. I agree with all of these benefits. But sadly, I don&#8217;t always do it. And my guess is that you don&#8217;t always test either.</p>
<p>What&#8217;s more, I haven’t done a lot of JavaScript testing. Like a number of developers, I’m guilty of leaving JavaScript as an afterthought, whereas my PHP, Bash and Python code are first-class citizens.</p>
<p>However, I&#8217;ve started building more complex, object-driven code. As the complexity grows, it&#8217;s become rather obvious that it needs to be covered by proper unit tests. The question was how. So I started looking around for the best available JavaScript unit testing libraries and came across the following:</p>
<p style="padding-left: 30px;">* <a title="QUnit" href="http://qunitjs.com/" target="_blank">QUnit</a><br />
* <a title="Mocha" href="http://visionmedia.github.com/mocha/" target="_blank">Mocha</a><br />
* <a title="Jasmine" href="http://pivotal.github.com/jasmine/" target="_blank">Jasmine</a><br />
* <a title="Sinon JS" href="http://sinonjs.org/" target="_blank">Sinon.JS</a></p>
<p>They all seem to offer solid feature sets for testing JavaScript. So to improve my JavaScript code quality and help you with yours, I&#8217;ll walk through each of them in a series of articles on the <a title="New Relic Blog" href="http://blog.newrelic.com" target="_blank">New Relic blog</a>.</p>
<p>We’ll cover how the testing units work and what they can do, along with what they&#8217;re like to use. You&#8217;ll get an informed and honest opinion before you try them out with your own code. Sound good? Let’s start with QUnit.</p>
<p><span style="font-size: 1.25em;"><strong>Installing</strong> <strong>QUnit</strong></span><br />
QUnit is a self-contained library, requiring only one JavaScript file (qunit.js) and one CSS file (qunit.css). You can either download them from the <a title="The QUnit website" href="http://qunitjs.com" target="_blank">QUnit</a> site or clone them from the <a title="The QUnit repository on GitHub" href="https://github.com/jquery/qunit" target="_blank">QUnit GitHub</a> repository, as follows:</p>
<pre class="brush: plain; title: ; notranslate">

git clone git://github.com/jquery/qunit.git
</pre>
<p>After you get a copy of the files, add them into your project web root and include them directly or with the framework or application that you&#8217;re already using (such as Zend Framework or Oxid eSales). Then you&#8217;re ready to start testing.</p>
<p><strong><span style="font-size: 1.25em;">The JavaScript Code</span></strong><br />
This isn&#8217;t a complex example, but I believe it&#8217;s enough to write some meaningful tests. The following code example creates a jQuery object that contains the properties and functions required to perform a basic mortgage calculation. Let&#8217;s walk through it slowly to give you an overview of how it works.</p>
<pre class="brush: jscript; title: ; notranslate">
    $(document).ready(function() {

		var rateCalculator = {
</pre>
<p>The properties of the object store the following information (pre-initialized with some meaningful defaults):</p>
<p style="padding-left: 30px;">* The amount of the loan<br />
* The regular repayment amount<br />
* The repayment frequency (monthly, fortnightly, weekly)<br />
* The term of the loan<br />
* The current interest rate of the loan</p>
<p>The defaults:</p>
<pre class="brush: jscript; title: ; notranslate">
			loanAmount: 150000,
			repaymentAmount: 700,
			repaymentFrequency: &quot;monthly&quot;,
			loanTerm: 35,
			interestRate: 9.15,
</pre>
<p>We then have a simple function that allows us to override the existing defaults with the information specified in the form, which we&#8217;ll see later.</p>
<pre class="brush: jscript; title: ; notranslate">

			setLoanProperties: function(loanAmount, repaymentFrequency, loanTerm, interestRate) {
				this.loanAmount = new Number(loanAmount);
				this.repaymentFrequency = repaymentFrequency;
				this.loanTerm = new Number(loanTerm);
				this.interestRate = interestRate / 100;
				console.log(this);
			},

</pre>
<p>The <code>calculateDifference</code> method uses a mortgage calculation formula that I found on Wolfram. It calculates the recurring payment amount and the total repayable amount.</p>
<p>It initializes a series of local variables as <a title="Number objects" href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" target="_blank"><code>Number</code> objects</a> and uses the <code>pow</code> function from the <a title="Math library" href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math" target="_blank"><code>Math</code> library</a> to complete the calculation. I&#8217;ve split the calculation across a number of variables, more for readability and maintainability than anything else.</p>
<pre class="brush: jscript; title: ; notranslate">

			calculateDifference: function() {
				switch (this.repaymentFrequency) {
					case (&quot;weekly&quot;):
						var period = 52;
						break;
					case (&quot;fortnightly&quot;):
						var period = 26;
						break;
					case (&quot;monthly&quot;):
					default:
						var period = 12;
						break;
				}
				var rateByPeriod = new Number(this.interestRate / period);
				var numerator = new Number(Math.pow((1 + rateByPeriod), (this.loanTerm * period)));
				var denominator = new Number(numerator.toFixed(2) - 1);
				var regularRepayment = new Number(this.loanAmount * rateByPeriod * (numerator / denominator));
				var totalAmount = new Number(regularRepayment * (period * this.loanTerm));
				
				$(&quot;#repaymentAmount&quot;).html(regularRepayment.toFixed(2));
				$(&quot;#totalToRepay&quot;).html(totalAmount.toFixed(2));
			},
		};
</pre>
<p>When the calculation is complete, it displays the two calculated values in the form so the user can see them. The values the user enters in the form are used to initialize the object and then to calculate the amounts. There&#8217;s no validation in the form, just the key functionality required.</p>
<pre class="brush: jscript; title: ; notranslate">

		$(&quot;#submit&quot;).click(function() {
			rateCalculator.setLoanProperties($(&quot;#originalAmount&quot;).val(), $(&quot;#repaymentFrequency&quot;).val(), $(&quot;#loanTerm&quot;).val(), $(&quot;#interestRate&quot;).val());
			rateCalculator.calculateDifference();
		});
	});

</pre>
<p>The HTML itself is rather trivial, so I won&#8217;t spend time here going through it. It&#8217;s available with the rest of the code.</p>
<p><strong><span style="font-size: 1.25em;">QUnit Functions</span></strong><br />
Although simple in scope, the QUnit Framework is rather effective. Unlike other unit testing frameworks such as <a title="PHPUnit" href="https://github.com/sebastianbergmann/phpunit/" target="_blank">PHPUnit</a> or <a title="SimpleTest" href="http://www.simpletest.org/" target="_blank">SimpleTest</a>, it doesn&#8217;t have a lot of methods and assertions.</p>
<p>That&#8217;s not to say that isn&#8217;t fully capable. This is a list of the key tests available:</p>
<table summary="Available tests" border="0" cellspacing="5">
<tbody>
<tr>
<td><strong>FUNCTION</strong></td>
<td><strong>DESCRIPTION</strong></td>
</tr>
<tr>
<td><strong>ok</strong></td>
<td>Assert that a statement is &#8220;truthy&#8221;</td>
</tr>
<tr>
<td><strong>equal</strong></td>
<td>Assert that two values are equivalent to each other using non-strict comparison. i.e., ==</td>
</tr>
<tr>
<td><strong>strictEqual</strong></td>
<td>Make a strict assertion that two values are equivalent to each other. i.e, ===</td>
</tr>
<tr>
<td><strong>test</strong></td>
<td>Add a test to the list of tests to run</td>
</tr>
<tr>
<td><strong>asyncTest</strong></td>
<td>Add a test for an asynchronous section of code</td>
</tr>
<tr>
<td><strong>throws</strong></td>
<td>A test to run in the event of an exception being thrown</td>
</tr>
</tbody>
</table>
<p>While I haven’t used all the tests above, they show that QUnit is a solid package for testing. What&#8217;s more, we can use them in combination with the power of jQuery and JavaScript to do what we need to do. Now let&#8217;s walk through the unit tests to see how they work.</p>
<p><span style="font-size: 1.25em;"><strong>The Basic Unit Test</strong></span><br />
Tests can be grouped together into modules. Any call to <code>test</code> – which is preceded by a call to <code>module</code> – is considered part of a group until the next call to module or the end of the test suite. I&#8217;ve done that below and included the classic setup and teardown functions. Actually, I&#8217;ve done nothing in either of them, but you can use these functions as needed to set up your DOM or do any other work.</p>
<pre class="brush: jscript; title: ; notranslate">

    module( &quot;module&quot;, {
		setup: function() {
			//ok( true, &quot;one extra assert per test&quot; );
		}, teardown: function() {
			//ok( true, &quot;and one extra assert after each test&quot; );
		}
	});

</pre>
<p>Another good thing about using QUnit is that you can set up tests to run as an atomic unit. I&#8217;ve broken the testing for my code into two parts:</p>
<p style="padding-left: 30px;">1. Check the availability of the required form elements.<br />
2. Ensure that the calculation operates as expected with a correct set of inputs.</p>
<p>The first test checks to make sure that all the required form elements are in place. I used simple <a title="W3C information on CSS Selectors" href="http://www.w3.org/TR/CSS2/selector.html" target="_blank">CSS Selectors</a> to access the elements in question, then checked that the length property is not equal to zero – which is a simple way to ensure it&#8217;s present.</p>
<p>The second element is the message for when the test passes or fails, so you know which one worked or didn&#8217;t. In the call to <code>test</code>, I provided a meaningful description for it (which is output when the test runs), the number of tests to expect and an anonymous function containing the tests.</p>
<pre class="brush: jscript; title: ; notranslate">

		// ensure all the required form elements are in place
		test( &quot;All required form elements exist&quot;, 7, function() {
			ok($(&quot;#originalAmount&quot;).length != 0, &quot;original amount element exists&quot;);
			ok($(&quot;#repaymentFrequency&quot;).length != 0, &quot;repayment frequency element exists&quot;);
			ok($(&quot;#loanTerm&quot;).length != 0, &quot;loan term element exists&quot;);
			ok($(&quot;#interestRate&quot;).length != 0, &quot;interest rate element exists&quot;);
			ok($(&quot;#submit&quot;).length != 0, &quot;submit button element exists&quot;);
			ok($(&quot;#repaymentAmount&quot;).length != 0, &quot;total repayment amount output element exists&quot;);
			ok($(&quot;#totalToRepay&quot;).length != 0, &quot;total amount to repay output button element exists&quot;);
		});

</pre>
<p>As I did in the first test, I&#8217;ve provided a description for the second one: the number of tests that will run and an anonymous function containing the tests. In this one, I&#8217;ve provided a bit of setup, which I could have provided in the <code>setup</code> method. I initialized variables to predefined values and then set the various form elements accordingly.</p>
<p>After that, I leveraged QUnit’s ability to manually build an event object that can trigger the click event on the Submit button as if the user had done it. Assuming the events fire and the values are generated correctly, I&#8217;ve run two tests with the QUnit <code>equal</code> method to check that the calculated values are what I expected.</p>
<pre class="brush: jscript; title: ; notranslate">

		test( &quot;test calculation output&quot;, 2, function() {
			var dummyLoanAmount = 270000;
			var dummyYearsRemaining = 30;
			var dummyInterestRate = 8.00;
			
			$( &quot;#originalAmount&quot; ).val(dummyLoanAmount);
			$( &quot;#loanTerm&quot; ).val(dummyYearsRemaining);
			$( &quot;#interestRate&quot; ).val(dummyInterestRate);

			var event,
				$submitButton = $( &quot;#submit&quot; );

			// trigger event
			event = $.Event( &quot;click&quot; );
			event.keyCode = 9;
			$submitButton.trigger( event );

			var monthlyRep = $( &quot;#repaymentAmount&quot; ).val();
			var totalRep = $( &quot;#totalToRepay&quot; ).val();
			equal(monthlyRep, 457.04, &quot;monthly repayment amount correctly totals&quot; );
			equal(totalRep, 712985.68, &quot;total repayment amount correctly totals&quot; );
		});

</pre>
<p><strong><span style="font-size: 1.25em;">The Test Output</span></strong><br />
Now that we’ve set up the tests and run them, how do they look? In the screenshot below you can see that the tests ran and the first test suite passed, but there&#8217;s a problem in the second one.<br />
<a href="http://blog.newrelic.com/wp-content/uploads/test-result-1-550px.png" target="_blank"><img class="size-full wp-image-12902 aligncenter" style="margin-top: 15px; margin-bottom: 15px;" title="QUnit Mortgage Calculator" alt="test-result-1-550px" src="http://blog.newrelic.com/wp-content/uploads/test-result-1-550px.png" width="550" height="551" /></a><br />
I expected the DOM to get updated after the click event was triggered, just like when a user clicks the Submit button. Then I could compare the calculated values against the expected amounts.</p>
<p>But, according to QUnit, the value of the two <code>div</code> elements is empty. So I&#8217;d like to throw this one out to you. Have you had a similar experience? If so, what solution did you come up with? Is it something small that I&#8217;ve missed? Let me know in the comments.</p>
<p><span style="font-size: 1.25em;"><strong>Enhancing the Tests</strong></span><br />
We&#8217;ve covered the core of the library. But let&#8217;s take it further. QUnit has a number of functions that allow us to register callbacks around various events in the unit testing lifecycle. They are:</p>
<table summary="QUnit callback functions" border="0" cellspacing="5">
<tbody>
<tr>
<td><strong>EVENT</strong></td>
<td><strong>DESCRIPTION</strong></td>
</tr>
<tr>
<td><strong>begin</strong></td>
<td>Fire when the test suite begins</td>
</tr>
<tr>
<td><strong>done</strong></td>
<td>Fire when the test suite ends</td>
</tr>
<tr>
<td><strong>log</strong></td>
<td>Fire when an assertion completes</td>
</tr>
<tr>
<td><strong>moduleDone</strong></td>
<td>Fire when a module completes</td>
</tr>
<tr>
<td><strong>moduleStart</strong></td>
<td>Fire when a module starts</td>
</tr>
<tr>
<td><strong>testDone</strong></td>
<td>Fire when a test completes</td>
</tr>
<tr>
<td><strong>testStart</strong></td>
<td>Fire when a test starts</td>
</tr>
</tbody>
</table>
<p>To create a simple example, I&#8217;ve implemented all of them in the code below. I&#8217;ve rerun the code with them in place so you can see the output.</p>
<pre class="brush: jscript; title: ; notranslate">

    QUnit.begin(function( details ) {
		console.log( &quot;Test Suit Starting.&quot; );
	});

	QUnit.done(function( details ) {
		console.log( &quot;Test Suit Ending. Results: Total: &quot;, details.total, &quot; Failed: &quot;, details.failed, &quot; Passed: &quot;, details.passed, &quot; Runtime: &quot;, details.runtime );
	});

	QUnit.log(function( details ) {
		console.log( &quot;Assertion complete. Details: &quot;, details.result, details.message );
	});

	QUnit.moduleStart(function( details ) {
		console.log( &quot;Starting module: &quot;, details.module );
	});

	QUnit.moduleDone(function( details ) {
		console.log( &quot;Finished Running Module: &quot;, details.name, &quot;Failed/total: &quot;, details.failed, details.total );
	});

	QUnit.testStart(function( details ) {
		console.log( &quot;Now Running Test: &quot;, details.module, details.name );
	});

	QUnit.testDone(function( details ) {
		console.log( &quot;Finished Running Test: &quot;, details.module, details.name, &quot;Failed/total: &quot;, details.failed, details.total, details.duration );
	});
</pre>
<p><a href="http://blog.newrelic.com/wp-content/uploads/test-result-1-550px1.png" target="_blank"><img class="size-full wp-image-12903 aligncenter" style="margin-top: 15px; margin-bottom: 15px;" title="QUnit Console Window" alt="test-result-1-550px" src="http://blog.newrelic.com/wp-content/uploads/test-result-1-550px1.png" width="550" height="551" /></a><br />
By displaying the console window, you can see all the events were intercepted and view their respective details. Now granted, this isn&#8217;t always necessary. But it can be handy to have when debugging the tests &#8212; especially if you want to know as much as possible about what&#8217;s going on in your test suite. Full credit to the <a title="QUnit Manual" href="http://qunitjs.com/" target="_blank">QUnit manual</a> for a number of the test examples above.</p>
<p><strong><span style="font-size: 1.25em;">Conclusion</span></strong><br />
Whew! This was a rapid introduction to QUnit, one of the simplest and most effective unit testing libraries for JavaScript. What did you think? I realize that I haven’t covered everything available, but it&#8217;s more than enough to get started.</p>
<p>Personally, I was surprised by its functionality. I had expected it to be less capable that what I found it to be. One thing to note, I&#8217;m not sure how QUnit will fare if you run it from the command line or include it in an automated testing workflow.</p>
<p>There&#8217;s a post from 2010 <a title="QUnit from the command line" href="http://twoguysarguing.wordpress.com/2010/11/06/qunit-and-the-command-line-one-step-closer/" target="_blank">about QUnit and the command line</a>, which indicates that it&#8217;s rather difficult to do. The post mentions that the library contains a lot of browser-related assumptions. I&#8217;ve wondered whether using <a title="PhantomJS" href="http://phantomjs.org/" target="_blank">PhantomJS</a> could get around any of these aforementioned issues, but I haven&#8217;t had time to test it.</p>
<p>A few more questions before I wrap up: Have you used QUnit in an automated context? Do you use QUnit as a normal part of your development workflow? We&#8217;d like to hear about your experience with QUnit in the comments below.</p>
<p><strong><span style="font-size: 1.25em;">Next Time</span></strong><br />
I hope this article gave you a good idea of what&#8217;s possible with unit testing in JavaScript. In my next article, I&#8217;ll show you another unit testing library. See you there.</p>
<p><strong><span style="font-size: 1.25em;">Further Reading</span></strong></p>
<p style="padding-left: 30px;">* <a title="Wolfram" href="http://mathworld.wolfram.com/Mortgage.html" target="_blank">Mortgage Calculation from Wolfram</a><br />
* <a title="JQuery Testing" href="https://github.com/jquery/qunit" target="_blank">JQuery Unit Testing on Github</a><br />
* <a title="QUnit" href="http://qunitjs.com/" target="_blank">QUnit Javascript Unit Testing Framework</a><br />
* <a title="QUnit" href="http://benalman.com/talks/unit-testing-qunit.html" target="_blank">Unit Testing with QUnit</a></p>
<p>The post <a href="http://blog.newrelic.com/2013/05/15/new-simple-javascript-testing-with-qunit/">Simple JavaScript Testing with QUnit</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/05/15/new-simple-javascript-testing-with-qunit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dive into your JVM with New Relic</title>
		<link>http://blog.newrelic.com/2013/05/09/dive-into-your-jvm-with-new-relic/</link>
		<comments>http://blog.newrelic.com/2013/05/09/dive-into-your-jvm-with-new-relic/#comments</comments>
		<pubDate>Fri, 10 May 2013 01:03:27 +0000</pubDate>
		<dc:creator>Ashley Puls</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Product Updates]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12845</guid>
		<description><![CDATA[<p>If you’ve been looking for deeper insight into your JVM and application server, we’ve got some good news for you. The latest release of the New Relic Java agent includes an increase in the amount of data we collect on your Java applications and these new metrics can be used to solve a multitude of [...]</p><p>The post <a href="http://blog.newrelic.com/2013/05/09/dive-into-your-jvm-with-new-relic/">Dive into your JVM with New Relic</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>If you’ve been looking for deeper insight into your JVM and application server, we’ve got some good news for you. The latest release of the New Relic Java agent includes an increase in the amount of data we collect on your Java applications and these new metrics can be used to solve a multitude of performance problems.</p>
<p>The new metrics are located under the JVM tab and include the following:</p>
<p style="padding-left: 30px;">* Loaded and unloaded class count for the JVM<br />
* Active thread count for the JVM<br />
* Active and idle thread count for each thread pool<br />
* The ratio of active to maximum thread count for each thread pool<br />
* Active, expired and rejected HTTP session counts per application<br />
* Active, finished and created transaction counts per application server</p>
<p style="padding-left: 30px; text-align: center;"><a href="http://blog.newrelic.com/wp-content/uploads/JVM-new-tabset.png"><img class="wp-image-12863 aligncenter" alt="JVM tab" src="http://blog.newrelic.com/wp-content/uploads/JVM-new-tabset-1024x692.png" width="523" height="353" /></a></p>
<p>Now let’s take a closer look at each of them:</p>
<p><b>Loaded &amp; Unloaded Class Count</b></p>
<p style="padding-left: 30px;"><i>Location: </i>Under the <b>Memory </b>tab in the bottom-right corner of the screen.</p>
<p style="padding-left: 30px;"><i>Supported Application Servers: </i>All application servers that have JMX enabled.</p>
<p style="padding-left: 30px;"><i>Use Cases: </i>The loaded and unloaded class count can be used for a variety of purposes. For example, if the loaded class count is constantly going up, then the app server or a class loader may have a bug. Or if you perform upgrades without bringing down the JVM, you can use it to verify that classes were unloaded and then reloaded.</p>
<p><b>Active Thread Count</b></p>
<p style="padding-left: 30px;"><i>Location: </i>Under the <b>Threads</b> tab.</p>
<p style="padding-left: 30px;"><i>Supported Application Servers: </i>All application servers that have JMX enabled.</p>
<p style="padding-left: 30px;"><i>Use Cases: </i>You can use the thread count to determine how many active threads are running in your application. This is useful for determining usage trends. For example, it can show the time of day and the day of the week in which you usually reach peak thread count. In addition, the creation of too many threads can result in out of memory errors or thrashing. By watching this metric, you can reduce excessive memory consumption before it’s too late.</p>
<p><b>Thread Pool Metrics</b></p>
<p style="padding-left: 30px;"><i>Location: </i>Under the <b>Threads</b> tab.</p>
<p style="padding-left: 30px;"><i>Supported Application Servers:</i> Tomcat, JBoss 5 and 6, Resin, Jetty, WebLogic, TomEE, Glassfish, and WebSphere</p>
<p style="padding-left: 30px;"><i>Use Cases: </i>Thread pools are typically used to service multiple requests simultaneously. However, to get the best throughput, thread pools must be configured appropriately. For example, if the maximum thread count is set too high, the app will slow down from excessive memory usage. But if the maximum thread count is too low, it will cause requests to block or timeout.</p>
<p style="padding-left: 30px;">You can use these metrics to see if you are reaching the maximum thread count in a pool. In addition, they can be used to tune other properties – such as the amount of time before an idle thread is destroyed and the frequency of when new threads are created.</p>
<p style="padding-left: 30px;">This graph displays information on the http-bio-8080 thread pool on a Tomcat 7.0 application server. It shows that the thread pool starts with 10 idle threads and never handles more than five active requests at a time. The 0.23% capacity indicates that the number of active threads is well under the limit.</p>
<p style="text-align: center;"><a href="http://blog.newrelic.com/wp-content/uploads/threadpool_screenshot.png" target="_blank"><img class="size-full wp-image-12850 aligncenter" style="border: 1px solid black; margin-top: 15px; margin-bottom: 15px;" title="Threadpool" alt="threadpool_screenshot" src="http://blog.newrelic.com/wp-content/uploads/threadpool_screenshot.png" width="528" height="302" /></a></p>
<p><b>Session Metrics</b></p>
<p style="padding-left: 30px;"><i>Location: </i>Under the <b>HTTP Sessions</b> tab.</p>
<p style="padding-left: 30px;"><i>Supported Application Servers: </i>Tomcat, JBoss 5 and 6, Resin, TomEE, Glassfish, and WebSphere</p>
<p style="padding-left: 30px;"><i>Use Cases: </i>HTTP session information is used to determine usage trends such as the time of day when an application is getting the most amount of traffic. It can also be used to tune configuration properties such as the maximum number of active sessions allowed at one time and the amount of time a session remains active. For example, a high rejected session count usually indicates that the maximum active session count should be increased. Meanwhile, a high expired session count can suggest that the session timeout is too low.</p>
<p style="padding-left: 30px;">The graphs below show session information for two applications. The first indicates that a maximum of two sessions have been created for the application ‘examples’, but the sessions are constantly expiring. After increasing the timeout, the number of expired sessions reduces to zero. From the second graph, we see that zero sessions have been created for the application ‘host-manager’.</p>
<p style="text-align: center;"><a href="http://blog.newrelic.com/wp-content/uploads/session_screenshot.png" target="_blank"><img class="size-full wp-image-12851 aligncenter" style="border: 1px solid black; margin-top: 15px; margin-bottom: 15px;" title="Sessions" alt="session_screenshot" src="http://blog.newrelic.com/wp-content/uploads/session_screenshot.png" width="694" height="330" /></a></p>
<p><b>Transaction Metrics</b></p>
<p style="padding-left: 30px;"><i>Location: </i>Under the <b>App Server Transaction</b> tab.</p>
<p style="padding-left: 30px;"><i>Supported Application Servers: </i>JBoss 7, Resin, and Glassfish</p>
<p style="padding-left: 30px;"><i>Use Cases: </i>These metrics show info on transactions that go through the application server&#8217;s transaction manager. They are used to show transaction traffic patterns and help to configure the transaction manager.</p>
<p><span style="font-size: 1.25em;"><b>Get Started Today</b></span><br />
New Relic uses Java Management Extensions (JMX) to gather data on these new metrics. Before you get started using these new metrics, you must update to <a href="https://newrelic.com/docs/java/java-agent-self-installer">our latest Java agent</a> and enable JMX on your application server.</p>
<p>You can also set up New Relic to show custom JMX metrics. To see how to display custom metrics, <a title="Video: Importing JMX Data to New Relic" href="http://www.youtube.com/watch?v=IyS1gxpJajY" target="_blank">watch this video</a>.</p>
<p>The post <a href="http://blog.newrelic.com/2013/05/09/dive-into-your-jvm-with-new-relic/">Dive into your JVM with New Relic</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/05/09/dive-into-your-jvm-with-new-relic/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Test All the Combinations!</title>
		<link>http://blog.newrelic.com/2013/05/09/test-all-the-combinations/</link>
		<comments>http://blog.newrelic.com/2013/05/09/test-all-the-combinations/#comments</comments>
		<pubDate>Thu, 09 May 2013 16:43:19 +0000</pubDate>
		<dc:creator>Jason Clark</dc:creator>
				<category><![CDATA[Company News]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Top Post]]></category>
		<category><![CDATA[New Relic]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12792</guid>
		<description><![CDATA[<p>Most applications test for their own correctness. But sometimes gems need to go further and test their interactions with other gems. newrelic_rpm – otherwise known as the New Relic Ruby agent – is definitely one of them. It needs to not only coexist with other gems, but to seamlessly instrument them. So, how do we [...]</p><p>The post <a href="http://blog.newrelic.com/2013/05/09/test-all-the-combinations/">Test All the Combinations!</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Most applications test for their own correctness. But sometimes gems need to go further and test their interactions with other gems. <i>newrelic_rpm</i> – otherwise known as the New Relic Ruby agent – is definitely one of them. It needs to not only coexist with other gems, but to seamlessly instrument them.</p>
<p>So, how do we test code that’s heavily dependent on other components? How do we validate different combinations of frameworks that can occur in the wild? Read on for the nitty gritty of testing the Ruby agent in multiple environments.</p>
<p><span style="font-size: 1.25em;"><b>The Uncertainties of Life (and Testing)</b></span><br />
Before coming to New Relic, I was an app developer. At that time I never realized how much simpler life was when you could choose 1) what dependencies to take, 2) how the production environment was configured and 3) the fundamentals, like language versions. Unfortunately, library authors don’t get these certainties.</p>
<p>The richness of the gem ecosystem keeps the Ruby agent team on our toes. We support at least six different Ruby versions (depending on exactly how you count), eight versions of Rails, and a pile of other frameworks. If you ever need to be sure your code runs against Rails 2.0 and Ruby 1.8.6, I’ve got the test suite for you!</p>
<p>At the highest level, we follow a standard unit / functions (or integration) test breakdown. Let’s take a look at the unit tests first.</p>
<p><span style="font-size: 1.1em;"><b>Unit Testing</b></span><br />
Unit tests are the front line of our testing. They run quickly (about 10 seconds locally for the full suite of &gt; 1000 tests), with the lightest dependencies. We execute them across the broadest number of combinations of Ruby and Rails versions.</p>
<p>Historically Rails has been a big focus for the agent, so the unit tests run in the context of a Rails application. While most of the agent’s unit tests could run without any external dependencies, we’ve encountered many subtle bugs from interesting intersections between Rails (I’m looking at you, ActiveSupport) and the various flavors of Ruby. Running the unit tests under Rails helps flush out these odd interactions. For example, we found one problem with subtly incompatible versions of the to_json method floating around during the 2.x versions of ActiveSupport.</p>
<p>Which version of Rails do we run against? Well, if you <a title="Get it from GitHub" href="http://github.com/newrelic/rpm" target="_blank">download the agent source</a> and run the unit tests, you’ll see this:</p>
<pre class="brush: ruby; title: ; notranslate">
♥♥♥~/source/newrelic/ruby_agent [1.9.3] [release]:rake test

/Users/jclark/.rbenv/versions/1.9.3-p374/bin/ruby -I&quot;lib:/Users/jclark/source/newrelic/ruby_agent/test:/Users/jclark/source/newrelic/ruby_agent/lib&quot; -I&quot;/Users/jclark/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib&quot; &quot;/Users/jclark/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb&quot; &quot;/Users/jclark/source/newrelic/ruby_agent/test/new_relic/**/*_test.rb&quot;

Running tests in standalone mode.
Run options:

# Running tests:

...more dots...

Finished tests in 8.206038s, 129.6606 tests/s, 338.4094 assertions/s.

1064 tests, 2777 assertions, 0 failures, 0 errors, 0 skips
</pre>
<p>The line &#8216;Running tests in standalone mode&#8217; hints at what’s going on. In &#8216;standalone mode&#8217; we <a title="View the code" href="https://github.com/newrelic/rpm/blob/171fd110221a8cd0e456a13240381c5f15f4df31/test/test_helper.rb#L27-41" target="_blank">construct a tiny Rails app</a> in the agent that – by default – runs a Rails 3.2 app.</p>
<p>But what about all those other versions of Rails? That’s where <a title="Get the rpm_test app from GitHub" href="https://github.com/newrelic/rpm_test_app" target="_blank">rpm_test_app</a> comes in. It’s a full, separate application with branches for each flavor of Rails we support. These get stitched together with some Rake goodness to <a title="Check it out in GitHub" href="https://github.com/newrelic/rpm/blob/master/lib/tasks/tests.rake" target="_blank">run the unit tests for newrelic_rpm</a> in rpm_test_app&#8217;s context:</p>
<pre class="brush: ruby; title: ; notranslate">
Rake::TestTask.new(:newrelic) do |t|
  t.libs &lt;&lt; &quot;#{agent_home}/test&quot;
  t.libs &lt;&lt; &quot;#{agent_home}/lib&quot;
  t.pattern = &quot;#{agent_home}/test/new_relic/**/*_test.rb&quot;
  t.verbose = true
end
</pre>
<p>With `rake test:newrelic`, our CI system can run the gambit of Rails and Ruby versions. Jenkins configurations let us dictate which combinations make sense given that, for instance, you can&#8217;t run Rails 3.x and greater on Ruby 1.8.6.</p>
<p style="text-align: center;"><a href="http://blog.newrelic.com/wp-content/uploads/test_all_unittests.png" target="_blank"><img class="size-full wp-image-12842 aligncenter" style="border: 1px solid black; margin-top: 15px; margin-bottom: 15px;" title="Testing Ruby " alt="test_all_unittests" src="http://blog.newrelic.com/wp-content/uploads/test_all_unittests.png" width="550" height="367" /></a></p>
<p><span style="font-size: 1.25em;"><b>Not All About Rails</b></span><br />
That&#8217;s all good, but there&#8217;s much more to Ruby than just Rails. With the rich variety of frameworks to support, we needed an approach to mix and match dependencies.</p>
<p>This need led to our functional/integration testing layer, affectionately referred to as the &#8216;Pangalactic Multiverse&#8217; tests.</p>
<p>At heart, Multiverse is a series of suites, each representing a collection of dependencies. We have one for Sinatra, one for Resque and one for ActiveRecord outside of Rails. The exact versions are specified by an Envfile:</p>
<pre class="brush: ruby; title: ; notranslate">
suite_condition(&quot;Sinatra not compatible with 1.8.6&quot;) do
  RUBY_VERSION != '1.8.6'
end

gemfile &lt;&lt;-RB
  gem 'sinatra', '1.3.3'
  gem 'rack-test', :require =&gt; 'rack/test'
RB

gemfile &lt;&lt;-RB
  gem 'sinatra', '1.2.8'
  gem 'rack-test', :require =&gt; 'rack/test'
RB
</pre>
<p>Multiverse reads the Envfile and generates a Gemfile for each call to `gemfile`. It will <a title="About &quot;bundle install&quot;" href="http://gembundler.com/v1.3/man/bundle-install.1.html" target="_blank">bundle install</a> those dependencies and run the suite&#8217;s tests in a separate child process.</p>
<p>Unlike the unit tests that focus on individual classes, Multiverse tests run a full agent cycle – starting up, monitoring work, shutting down and transmitting data. They even run a fake service endpoint so data flows over HTTP, keeping as close to the runtime reality of the agent as possible.</p>
<p>With the additional environment spin-up and running our full stack, Multiverse tests are slower, but vital for coverage. We can easily write targeted automated tests against multiple different versions of individual frameworks, and validate that the agent works with new releases as they come out.</p>
<p>The Envfile lets each suite run multiple sets of dependent versions. And our CI system takes care of running Multiverse against various Ruby versions, too. So many combinations!</p>
<p style="text-align: center;"><a title="Ruby Multiverse test" href="http://blog.newrelic.com/wp-content/uploads/test_all_functionaltests.png" target="_blank"><img class="size-full wp-image-12844 aligncenter" style="border: 1px solid black; margin-top: 15px; margin-bottom: 15px;" title="Ruby Multiverse test" alt="test_all_functionaltests" src="http://blog.newrelic.com/wp-content/uploads/test_all_functionaltests.png" width="550" height="182" /></a></p>
<p><span style="font-size: 1.1em;"><b>The Hard Part</b></span><br />
Testing always presents unique challenges. And a library like the Ruby agent introduces its own set of fun twists.</p>
<p><span style="font-size: 1.1em;"><b>It’s About the Environment</b></span><br />
A lot of the work on our testing system has gone into getting environment setup scripted, both locally and in CI. We&#8217;re currently using a solution with Vagrant and Puppet that lets us spin up consistently formatted build boxes.</p>
<p><span style="font-size: 1.1em;"><b>Leaky Test State</b></span><br />
Testing needs to mimic reality to find some types of problems. This presents difficulties for the Ruby agent.</p>
<p>In production, the agent starts once per process. However, in a test run, the agent might restart hundreds of times. We&#8217;ve had to take care to avoid a leaking state between tests. Otherwise we could be faced with tests that work fine in isolation, but break when run in the suite. However, an upshot of this pain is the <a title="Jon's bisect test in GitHub" href="https://github.com/gnarg/test_bisect" target="_blank">test_bisect gem</a> my coworker <a href="https://github.com/gnarg">Jon</a> wrote. If you’ve ever suffered from leaky tests you should check it out.</p>
<p><span style="font-size: 1.1em;"><b>Timeliness Counts</b></span><br />
It’s also hard to write good tests for monitoring time and the underlying system. It’s much easier to write brittle timing tests that run fine locally, but break when deployed to the slower VM-based CI system under heavy load. Given how much of the Ruby agent&#8217;s functionality is about accurate timing, this is a continuing pain point we wrestle with in testing. In general, we’ve moved toward stubbing time values in unit tests and applying thresholds or percentage comparisons rather than strict timeframes whenever possible in functional tests.</p>
<p><span style="font-size: 1.25em;"><b>Need for Speed</b></span><br />
Running Multiverse is relatively slow. So, we’ve worked hard to prune that time. Two major approaches were: a) keeping suites coarse grained and b) applying local bundling. Both of these hinged off the setup being the slowest part of Multiverse.</p>
<p>In the first case, our early experience saw new Multiverse suites cropping up per feature. Often these would just copy an existing environment with minimal tweaks. Merging those suites along the lines of their gem dependencies gave a huge performance bump. Getting the right granularity for grouping tests was a big win.</p>
<p>Second, the Multiverse setup tries to bundle without contacting <a title="The RubyGems website" href="http://rubygems.org" target="_blank">RubyGems</a>, but re-runs a full bundle if that doesn&#8217;t work. Less network chatter = faster setup = faster tests.</p>
<p><span style="font-size: 1.25em;"><b>Conclusion</b></span><br />
That’s how we deal with testing multiple frameworks and Ruby environments on the Ruby agent team. It’s given us a nice balance of having our fast unit tests against the most common cases, with easy access to full-stack Multiverse tests to cover other configurations.</p>
<p>Are you a gem author who tests against different frameworks and Ruby implementations? Got a trick (or two) that’s helped you keep your dependency testing under control? Tell us about your experiences in the comments below.</p>
<p>The post <a href="http://blog.newrelic.com/2013/05/09/test-all-the-combinations/">Test All the Combinations!</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/05/09/test-all-the-combinations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Red Code, Green Code</title>
		<link>http://blog.newrelic.com/2013/05/02/red-code-green-code/</link>
		<comments>http://blog.newrelic.com/2013/05/02/red-code-green-code/#comments</comments>
		<pubDate>Thu, 02 May 2013 16:25:58 +0000</pubDate>
		<dc:creator>Merlyn Albery-Speyer</dc:creator>
				<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12815</guid>
		<description><![CDATA[<p>I’ve got an idea I want to share with you. It’s the concept of Red Code and Green Code. Now, this doesn’t have anything to do with the red / green / refactor cycle, code coverage or testing. You&#8217;ll know Green Code when you see it. It’s code that&#8217;s made elegant due to some cleverly written [...]</p><p>The post <a href="http://blog.newrelic.com/2013/05/02/red-code-green-code/">Red Code, Green Code</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I’ve got an idea I want to share with you. It’s the concept of Red Code and Green Code. Now, this doesn’t have anything to do with the red / green / refactor cycle, code coverage or testing. You&#8217;ll know Green Code when you see it. It’s code that&#8217;s made elegant due to some cleverly written supporting Red Code.</p>
<p>Here’s an example of Green Code in Ruby:</p>
<p>
<pre>class Customer < ActiveRecord::Base
  has_many &#58;orders
end</pre>
</p>
<p>In this code snippet, <code>has_many</code> is ActiveRecord’s Red Code. There’s a lot of machinery backing the <code>has_many</code> code that the Green Code doesn’t need to concern itself with.</p>
<p>You’ll often find Red Code in frameworks, APIs and DSLs. There are numerous examples including Gradle, Geb, jQuery, Mocha, Rake, Rails, RSpec, and Spock. And depending on the language, Red Code typically makes heavy use of some of the more powerful language features (e.g. meta programming in Ruby, byte code manipulation in Java).</p>
<p>However, the <a title="Red Code, Green Code, My Code" href="http://tapestryjava.blogspot.com/2013/01/red-code-green-code-my-code-your-code.html" target="_blank">Red Code / Green Code concept</a> isn’t a new one. In his book On Lisp, Paul Graham referred to this as <a title="Bottom-Up Programming" href="http://paulgraham.com/progbot.html" target="_blank">Bottom-Up Programming</a>. Graham encouraged his readers to increase the expressiveness of the language (Red Code) in order to make their code shorter and more readable (Green Code).</p>
<p>Depending on the task you’re trying to solve, you’ll probably want to be careful about writing any Red Code as it is apt to violate the principle of least surprise. For example, in Java you may come up with a clever solution using reflection. But reflection is unusual enough that it will likely trip up unsuspecting navigators of the code. As a good rule of thumb, candidates for Red Code are areas of your code that would make good open source libraries. To be worthwhile, the benefit of the Red Code has to outweigh the cost of discovering the unusual behavior, learning its proper usage and maintaining the more complex solution.</p>
<p>To illustrate this, take a look at the code behind Backbone.js. It’s very much Green Code and there are no big surprises. Then compare it with Angular, where there’s clearly Red Code under the hood. When you use the frameworks,  you’ll notice the difference, too. Backbone.js is easier to get into, but you need to write a fair amount of boiler place code. On the other hand, Angular has ‘magic’ conventions that take time to get use to. But once you’ve adjusted to how it work, you’ll benefit from the reduced boiler plate code.</p>
<p>Do you have experiences working with or writing Red Code and Green Code? Tell us about your experiences in the comments below.</p>
<p>The post <a href="http://blog.newrelic.com/2013/05/02/red-code-green-code/">Red Code, Green Code</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/05/02/red-code-green-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debugging Stuck Ruby Processes – What to do Before You Kill -9</title>
		<link>http://blog.newrelic.com/2013/04/29/debugging-stuck-ruby-processes-what-to-do-before-you-kill-9/</link>
		<comments>http://blog.newrelic.com/2013/04/29/debugging-stuck-ruby-processes-what-to-do-before-you-kill-9/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 19:34:27 +0000</pubDate>
		<dc:creator>Ben Weintraub</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12807</guid>
		<description><![CDATA[<p>RailsConf 2013 has begun! To celebrate, we’re publishing a series of blog posts that highlight what’s new and exciting in the world of New Relic’s Ruby support. Don’t forget to check out the entire series so far: Cross Application Tracing, Thread Profiling, Living on the Edge with Rails 4 &#38; Ruby 2, Thread Safe APIs &#38; Sidekiq Support for [...]</p><p>The post <a href="http://blog.newrelic.com/2013/04/29/debugging-stuck-ruby-processes-what-to-do-before-you-kill-9/">Debugging Stuck Ruby Processes – What to do Before You Kill -9</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><em><a title="RailsConf 2013 logo" href="http://blog.newrelic.com/wp-content/uploads/railsconf_logo.png" target="_blank"><img class="alignleft" style="margin: 5px;" title="RailsConf 2013 logo" alt="RailsConf 2013 logo" src="http://blog.newrelic.com/wp-content/uploads/railsconf_logo.png" width="88" height="88" /></a>RailsConf 2013 has begun! To celebrate, we’re publishing a series of blog posts that highlight what’s new and exciting in the world of New Relic’s Ruby support. Don’t forget to check out the entire series so far: <a title="Cross App Tracing: Time to Break Up that Huge Rails Application?" href="http://blog.newrelic.com/2013/04/22/cross-app-tracing-time-to-break-up-that-huge-rails-application/" target="_blank">Cross Application Tracing</a>, <a title="Thread Profiling: See Exactly What Your App Is Doing" href="http://blog.newrelic.com/2013/04/23/thread-profiling-see-exactly-what-your-app-is-doing/" target="_blank">Thread Profiling</a>, <em><a title="Living on the Edge with Rails 4 &amp; Ruby 2" href="http://blog.newrelic.com/2013/04/24/living-on-the-edge-with-rails-4-ruby-2/" target="_blank">Living on the Edge with Rails 4 &amp; Ruby 2</a>, <a title="Thread Safe APIs and Sidekiq Support for Your Threading" href="http://blog.newrelic.com/2013/04/25/thread-safe-apis-and-sidekiq-support-for-your-threading/">Thread Safe APIs &amp; Sidekiq Support for Your Threading</a>, and <a title="Security Banners (For If You Forgot to Apply the Latest CVE Patch)" href="http://blog.newrelic.com/2013/04/26/security-banners-for-if-you-forgot-to-apply-the-latest-cve-patch/" target="_blank">Security Banners (For If You Forgot to Apply the Latest CVE Patch)</a>.<br />
</em></em></p>
<p>If you’ve spent enough time working with a production system (or even just a continuous integration server), you&#8217;ve surely encountered a Ruby process that was ‘stuck.’  You know the type – not crashing, but not making any real progress either. And giving you no obvious indication of what it was doing.</p>
<p>When finding a stuck process, your primary goal usually is to just get the wheels of progress turning again. And the quickest path to that goal is usually to `kill -9` the stuck process and restart it.</p>
<p>But I want to you to make your future self a promise. The next time this happens, don’t just kill that stuck process and move on. Dig in and figure out what&#8217;s really going on. You might just discover the root cause of your problem, hone your debugging techniques or discover a clue that helps you fix that tricky bug in your favorite open source project that no one has been able to pin down.</p>
<p>Since encountering a stuck process (especially in production) is often stressful, I find it helps to think about the debugging steps you plan to take ahead of time. Create a ‘checklist’ of things to run through so you don’t forget anything or skip any steps. Failing to capture enough information to reproduce a bug usually means you’ll hit it again. So make sure you seize the opportunity when it’s available.</p>
<p>Here are the steps I follow when debugging a stuck Ruby process:</p>
<p><span style="font-size: 1.25em;"><b>Who Said What?</b></span><br />
First, figure out exactly what process is stuck. This sounds trivial, but it’s especially important for systems like <a title="Unicorn" href="http://unicorn.bogomips.org/" target="_blank">Unicorn</a>, <a title="Passenger" href="http://rubygems.org/gems/passenger" target="_blank">Passenger</a>, <a title="Resque" href="https://github.com/resque" target="_blank">Resque</a>, etc. where the system is composed of multiple processes that have different roles (often a single master process plus a number of workers).</p>
<p>Identifying exactly which process is stuck is important in order to get a full picture of the behavior of the system as a whole. The trusty ps utility is usually my first stop here &#8212; a quick `ps aux | grep &lt;process name&gt;`.</p>
<p>I like to keep a transcript of the exact commands I’ve run, along with their output. And the ps aux output is usually the first thing that goes into that transcript.</p>
<p>Tools like <a title="htop" href="http://htop.sourceforge.net/" target="_blank">htop</a> and <a title="pstree" href="http://www.thp.uni-duisburg.de/pstree/" target="_blank">pstree</a> can also be useful here. They give you a visual tree of the relationship between the stuck process, its sibling and its parent process (e.g. a Unicorn master and its workers).</p>
<p><span style="font-size: 1.25em;"><b>Grab Any Logs that are Available</b></span><br />
Again this may seem obvious, but the goal of the checklist is to remind you of everything you need to track. This will give you the best possible chance of debugging the problem offline. Before getting started, consider these questions:</p>
<p style="padding-left: 30px;">* Where is STDOUT of the stuck process being sent?</p>
<p style="padding-left: 30px;">* Where is STDERR of the stuck process being sent?</p>
<p style="padding-left: 30px;">* Are there any other log files created by the stuck process? Check the command line and config file used for the process. Did either specify a log path?</p>
<p style="padding-left: 30px;">* Are there any other log files created by processes related to the stuck process?</p>
<p><span style="font-size: 1.25em;"><b>Other Non-Invasive Basics</b></span><br />
Try gathering the following before you move into the more invasive actions:</p>
<p style="padding-left: 30px;">* Grab the list of open files and sockets from the process using lsof -p &lt;PID&gt;</p>
<p style="padding-left: 30px;">* If you&#8217;re on Linux, poke around in /proc/&lt;PID&gt; and consider gathering:</p>
<p style="padding-left: 60px;">* cmdline contains the command line that was used to launch the process</p>
<p style="padding-left: 60px;">* cwd is a link to the current working directory of the process</p>
<p style="padding-left: 60px;">* environ is a list of environment variables set for the process</p>
<p><span style="font-size: 1.25em;"><b>Check the CPU Usage of the Stuck Process</b></span><a title="Locks" href="http://blog.newrelic.com/wp-content/uploads/locks.jpg" target="_blank"><img class="alignright size-full wp-image-12809" style="margin: 5px;" title="Locks" alt="Locks" src="http://blog.newrelic.com/wp-content/uploads/locks.jpg" width="200" height="133" /></a><br />
There are two basic flavors of hangs: static and dynamic. (Note: This is my own terminology, but I think it’s a useful taxonomy.) In a static hang, the threads of the stuck process are stuck in the same exact state for an extended period of time. Examples include traditional deadlocks and processes blocked for extended periods in system calls (often things like `read`, `select`, etc.). In a dynamic hang, the threads of the stuck process are changing state, but are caught in some kind of loop that prevents them from making progress (this is sometimes called a &#8216;livelock&#8217;).</p>
<p>The techniques used to debug the two types of hangs are different. So it’s useful to be able to differentiate between them in the wild. A quick heuristic for doing this is to check the CPU usage of the stuck process. Static hangs will generally result in processes with no CPU usage, whereas dynamic hangs will result in processes with non-zero CPU usage (often very high, if the process is stuck in a tight loop).</p>
<p>There are a variety of tools you can use to do this, but a quick look at `top` or `ps -o cpu &lt;pid&gt;` is often enough.</p>
<p><span style="font-size: 1.05em;"><b>Static Hangs</b></span><br />
For static hangs where the stuck process demonstrates no CPU usage, gather information on the backtraces of all threads in the stuck process. This is often the most important data. Since the threads aren&#8217;t changing state, a single snapshot of thread backtraces is usually sufficient.</p>
<p>There are a variety of different tools for accomplishing this goal, depending on the platform you&#8217;re running on and the Ruby implementation you&#8217;re using, but I&#8217;m going to focus on what is perhaps the most common case: MRI on a Linux host.</p>
<p>`gdb` is a time-tested and widely available tool that can be used to interrogate a running process on a variety of UNIX-ish platforms. You can attach to a running process with gdb by using the -p option, like this:</p>
<pre class="brush: ruby; title: ; notranslate">
```
gdb -p
```
</pre>
<p>Once gdb has successfully attached to the target process, it will drop you at a prompt. The very first thing you should do here is to gather C-level backtraces for all threads of the stuck process, like this:</p>
<pre class="brush: ruby; title: ; notranslate">
```
(gdb) t a a bt
```
</pre>
<p>This is short for `thread apply all backtrace`. Copy this output and save it to your transcript file, even if it&#8217;s not immediately informative.</p>
<p>Sometimes C-level backtraces are all you need in order to debug a hang. In other cases though, you really need a Ruby-level backtrace to see what&#8217;s going on. Luckily, gdb can help you generate those, too.</p>
<p><span style="font-size: 1em;"><b>Getting a Ruby Backtrace with gdb</b></span><br />
Getting a Ruby backtrace out of gdb involves interacting with the Ruby interpreter in the running process that you&#8217;ve attached to. And to get that, the interpreter needs to be in a semi-working state.  If the root cause of the issue is a Ruby bug, the process may be stuck in such a way that it isn’t possible to get the backtrace at all.</p>
<p>That said, it’s always worth trying. Here’s the technique I use:</p>
<p>Most mechanisms for dumping Ruby backtraces will output them to stdout or stderr. It’s fine if you know where the stdout and stderr for your process is going, and you have access to it. If not, first you’ll need to redirect the output streams to an accessible location.</p>
<p>To do this, we rely on POSIX conventions and some trickery. stdout and stderr are file descriptors 1 and 2 on POSIX-compliant systems. We want to close these file descriptors, and reopen them attached to files that we can actually read from. Closing is easy:</p>
<pre class="brush: ruby; title: ; notranslate">
```
(gdb) call (void) close(1)
(gdb) call (void) close(2)
```
</pre>
<p>The call command tells gdb to invoke close from within the target process. Next, we need to re-associate file descriptors 1 and 2 with a file we can actually read from. We could use a file on the filesystem, but it&#8217;s even more convenient to see the output directly in gdb. To do that, we want to figure out the device file corresponding to our current TTY and open it twice. Since file descriptors are assigned sequentially, descriptors 1 and 2 will end up being re-associated with our TTY device. Here&#8217;s how this looks:</p>
<pre class="brush: ruby; title: ; notranslate">
```
(gdb) shell tty
/dev/pts/0
(gdb) call (int) open(&quot;/dev/pts/0&quot;, 2, 0)
$1 = 1
(gdb) call (int) open(&quot;/dev/pts/0&quot;, 2, 0)
$2 = 2
```
</pre>
<p>Now, any output generated by the target process will be echoed directly to our console so we can see it in our gdb session.</p>
<p>Finally, we need to get the Ruby interpreter in the target process to spit out a backtrace. There are many ways to do this. But the easiest way is just to use gdb to call the rb_backtrace() function from the Ruby interpreter directly:</p>
<pre class="brush: ruby; title: ; notranslate">
```
(gdb) call (void)rb_backtrace()
```
</pre>
<p>With luck, you&#8217;ll see a Ruby backtrace dumped to your console.</p>
<p><span style="font-size: 1em;"><b>Digging Deeper with gdb</b></span><br />
If you know what you’re looking for in the stuck process, there’s a lot more you can do with gdb. <a title="Jon Yurek on Twitter" href="https://twitter.com/jyurek" target="_blank">Jon Yurek</a> at <a title="thoughtbot" href="http://www.thoughtbot.com/" target="_blank">thoughtbot</a> has a <a title="Using GDB to inspect a running Ruby process" href="http://robots.thoughtbot.com/post/47202759358/using-gdb-to-inspect-a-running-ruby-process" target="_blank">great post</a> on this topic that explains how you can get gdb to evaluate arbitrary Ruby code in the target process to inspect the values of Ruby variables, get backtraces for all threads and any number of other things</p>
<p><span style="font-size: 1.05em;"><b>Dynamic Hangs</b></span><br />
A stuck process that shows high CPU usage is likely stuck in a tight loop. This means that the exact backtraces you get out of it may vary from one sample to the next, but backtraces can still be very helpful to point you in the right direction.</p>
<p>If you find a stuck process with high CPU usage, it may be worth gathering backtraces 2 or 3 times to get a more representative sample. (You can use gdb&#8217;s continue command to resume the process after you&#8217;ve attached).</p>
<p>You can also use other tracing tools to examine the behavior of the looping process. On Linux, strace -p &lt;pid&gt; allows you to view the system calls being made by the process. If you&#8217;re on an OS that has dtrace available, you can use dtruss -p &lt;PID&gt; instead to get a similar output.</p>
<p><span style="font-size: 1.25em;"><b>Thanks, from your Future Self</b></span><br />
You might not always have the luxury of being able to spend time debugging a stuck process. But when you do dive in, you’ll probably be glad you did. I’ve only scratched the surface of the tools available for analyzing problems like this, but hopefully I’ve given you enough information that you’ll be comfortable doing more than just sighing, SIGKILL-ing, and waiting for your problem to reappear.</p>
<p><span style="font-size: 1.15em;"><b>Bonus: Mac OS X</b></span><br />
If you happen to be debugging a stuck process on Mac OS X, check out this <a title="Mac OS X Sample Utility" href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sample.1.html" target="_blank">sample utility</a> (a handy tool that ships with OS X). It will automate the collection of multiple C-level backtraces, aggregate them together and print out a nicely formatted call tree report showing where the stuck process is spending most of its time.</p>
<p><i>At RailsConf 2013? Stop by our booth to see the New Relic Ruby Agent in action, pick up your free Data Nerd t-shirt and more. You can </i><i>even try New Relic Pro free for 30 days. For more information, go to <a title="Attn. RailsConf attendees: Get New Relic Pro free for 30 days!" href="http://newrelic.com/railsconf" target="_blank">newrelic.com/railsconf</a>.</i></p>
<p>The post <a href="http://blog.newrelic.com/2013/04/29/debugging-stuck-ruby-processes-what-to-do-before-you-kill-9/">Debugging Stuck Ruby Processes – What to do Before You Kill -9</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/04/29/debugging-stuck-ruby-processes-what-to-do-before-you-kill-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SnapStack App Bootcamp: Adding New Relic Monitoring to SnapStack</title>
		<link>http://blog.newrelic.com/2013/04/23/snapstack-app-bootcamp-adding-new-relic-monitoring-to-snapstack/</link>
		<comments>http://blog.newrelic.com/2013/04/23/snapstack-app-bootcamp-adding-new-relic-monitoring-to-snapstack/#comments</comments>
		<pubDate>Tue, 23 Apr 2013 18:54:41 +0000</pubDate>
		<dc:creator>Leigh Shevchik</dc:creator>
				<category><![CDATA[Partners]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12767</guid>
		<description><![CDATA[<p>This is a guest post from our partner StackMob who provides an end-to-end development platform for mobile application developers. The post originally appeared on their blog as part of the SnapStack App Bootcamp series. To view the earlier posts, visit the StackMob blog. The Case for New Relic So you completed our SnapStack tutorial series, and [...]</p><p>The post <a href="http://blog.newrelic.com/2013/04/23/snapstack-app-bootcamp-adding-new-relic-monitoring-to-snapstack/">SnapStack App Bootcamp: Adding New Relic Monitoring to SnapStack</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><i>This is a guest post from our partner StackMob who provides an end-to-end development platform for mobile application developers. The post originally appeared on their blog as part of the SnapStack App Bootcamp series. </i><i>To view the earlier posts, <a title="StackMob blog" href="https://blog.stackmob.com" target="_blank">visit the StackMob blog</a>.</i></p>
<p><a title="iOS App Bootcamp" href="http://blog.newrelic.com/wp-content/uploads/iOS_App_Bootcamp.png" target="_blank"><img class="alignright  wp-image-12769" style="margin: 5px;" title="iOS App Bootcamp" alt="iOS App Bootcamp" src="http://blog.newrelic.com/wp-content/uploads/iOS_App_Bootcamp.png" width="134" height="134" /></a><span style="font-size: 1.25em;"><b>The Case for New Relic</b></span><br />
So you completed our <a title="SnapStack Tutorial Series" href="https://blog.stackmob.com/2013/03/snapstack-app-bootcamp-part-1-setup/" target="_blank">SnapStack tutorial series</a>, and released your app into the App Store. The work is over, right? Contrary to belief, the work has just begun. Even after your app has shipped out, the development process continues. No amount of testing will substitute for the experience of putting your app into the wild. Developers are constantly responding to users interacting with their app, sometimes in ways they might not have imagined.</p>
<p>Unfortunately, this makes the debugging process exponentially more difficult. Many developers spend large amounts of time scouring the reviews of their app, looking for reappearing bugs or issues. This leaves them firefighting issues blindly; relying on differing, incomplete accounts from user reviews. In addition to handling issues in a reactive manner, the practice comes at a price: developers often have to wait for a batch of poor reviews before they’re alerted to an issue.</p>
<p><a href="http://newrelic.com/stackmob">New Relic</a> solves the problem with its mobile SDK, which provides real time HTTP request and error monitoring. The mobile monitoring SDK enables developers to be proactive about identifying and fixing bugs. New Relic doesn’t stop at error logs; their dashboard presents plenty of useful and informative data about a live app, all in an easily accessible manner. The more context the better &#8212; with New Relic, app developers can make informed decisions at every turn.</p>
<p><span style="font-size: 1.25em;"><b>Adding the New Relic SDK</b></span></p>
<p style="padding-left: 30px;">1. If you don’t have one yet, <a title="Sign up for your FREE New Relic account" href="http://newrelic.com/stackmob" target="_blank">sign up for a New Relic account</a>.</p>
<p style="padding-left: 30px;">2. Log in and click the Mobile tab on the left.</p>
<p style="padding-left: 60px;"><a title="New Relic Mobile tab" href="http://blog.newrelic.com/wp-content/uploads/NR_Mobile_tab.png" target="_blank"><img class="wp-image-12770 alignnone" title="New Relic Mobile tab" alt="New Relic Mobile tab" src="http://blog.newrelic.com/wp-content/uploads/NR_Mobile_tab.png" width="167" height="366" /></a></p>
<p style="padding-left: 30px;">3. From the Mobile Dashboard, select your app (create one if you haven’t done so) and click the <i>Settings</i> tab.</p>
<p style="padding-left: 30px; text-align: center;"><a title="New Relic Mobile Dashboard" href="http://blog.newrelic.com/wp-content/uploads/NR_Mobile_Dashboard.png" target="_blank"><img class="aligncenter  wp-image-12771" style="border: 1px solid black;" title="New Relic Mobile Dashboard" alt="New Relic Mobile Dashboard" src="http://blog.newrelic.com/wp-content/uploads/NR_Mobile_Dashboard.png" width="694" height="102" /></a></p>
<p style="padding-left: 30px;">4. From the <i>Settings</i> tab, click <i>Installation</i>.</p>
<p style="padding-left: 30px; text-align: center;"><a title="New Relic Settings tab" href="http://blog.newrelic.com/wp-content/uploads/NR_Settings_tab.png" target="_blank"><img class="aligncenter size-full wp-image-12772" style="border: 1px solid black;" title="New Relic Settings tab" alt="New Relic Settings tab" src="http://blog.newrelic.com/wp-content/uploads/NR_Settings_tab.png" width="617" height="288" /></a></p>
<p style="padding-left: 30px;">5. Select the iOS SDK and download it. Unzip it and drag NewRelicAgent.framework into the frameworks folder of the project.</p>
<p style="padding-left: 30px; text-align: center;"><a title="New Relic Frameworks folder" href="http://blog.newrelic.com/wp-content/uploads/NR_Frameworks_folder.png" target="_blank"><img class="aligncenter  wp-image-12773" style="border: 1px solid black;" title="New Relic Frameworks folder" alt="New Relic Frameworks folder" src="http://blog.newrelic.com/wp-content/uploads/NR_Frameworks_folder.png" width="723" height="482" /></a></p>
<p style="padding-left: 30px;">6. Add <code>CoreTelephony.framework</code>, <code>libz.dylib</code> and <code>SystemConfiguration.framework</code> to the project.</p>
<p style="padding-left: 30px;">7. In the MOBAppDelegate.m file add the following import: <code>#import</code></p>
<p style="padding-left: 30px;">8. Add this line of code at the very beginning of the <code>application:didFinishLaunchingWithOptions:</code> method.</p>
<p style="padding-left: 30px;">Replace YOUR_NEW_RELIC_KEY with your New Relic application token:</p>
<p style="padding-left: 30px;">[NewRelicAgent startWithApplicationToken:@"YOUR_NEW_RELIC_KEY"];</p>
<p style="padding-left: 30px;">9. Build your project and run, and you should see activity in your New Relic dashboard immediately.</p>
<p><span style="font-size: 1.25em;"><b>Congrats!</b></span><br />
We’ve reached the end of this tutorial. In it, we discussed the challenges and pitfalls that developers encounter with live app debugging. Next, we presented the solution that New Relic provides, and covered the benefits of the New Relic mobile monitoring SDK. Finally, we leveraged the partnership between StackMob and New Relic, and walked through adding it to our SnapStack project.</p>
<p><span style="font-size: 1.25em;"><b>Are You a StackMob Customer?</b></span><br />
Through our partnership, StackMob customers get <a title="Attn. StackMob Customers: Get New Relic Standard FREE of charge!" href="http://newrelic.com/stackmob" target="_blank">New Relic Standard free of charge</a>. You’ll even get a free 14 day trial of New Relic Pro. So, what are you waiting for? <a title="StackMob customers get New Relic Standard free of charge" href="http://newrelic.com/stackmob" target="_blank">Sign up for your free account today</a>!</p>
<p>The post <a href="http://blog.newrelic.com/2013/04/23/snapstack-app-bootcamp-adding-new-relic-monitoring-to-snapstack/">SnapStack App Bootcamp: Adding New Relic Monitoring to SnapStack</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/04/23/snapstack-app-bootcamp-adding-new-relic-monitoring-to-snapstack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Community News: Speeding up the Mobile Web and More</title>
		<link>http://blog.newrelic.com/2013/04/05/community-news-speeding-up-the-mobile-web-and-more/</link>
		<comments>http://blog.newrelic.com/2013/04/05/community-news-speeding-up-the-mobile-web-and-more/#comments</comments>
		<pubDate>Fri, 05 Apr 2013 16:00:49 +0000</pubDate>
		<dc:creator>Leigh Shevchik</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12716</guid>
		<description><![CDATA[<p>In this week’s community news, we get tips for speeding up the mobile web, ask why eCommerce sites are slower than last year and more. * Steve Souders looks at how fast we really are in his slides from the HTML5 Conference. * The Web Performance Today podcasts talks CDNs with guest Aaron Peters. * [...]</p><p>The post <a href="http://blog.newrelic.com/2013/04/05/community-news-speeding-up-the-mobile-web-and-more/">Community News: Speeding up the Mobile Web and More</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In this week’s community news, we get tips for speeding up the mobile web, ask why eCommerce sites are slower than last year and more.</p>
<p style="padding-left: 30px;">* Steve Souders looks at <a title="How fast are we going now?" href="http://www.slideshare.net/souders/how-fast-are-we-going-now" target="_blank">how fast</a> we really are in his slides from the HTML5 Conference.</p>
<p style="padding-left: 30px;"><span style="font-size: 13px;">* The Web Performance Today podcasts </span><a style="font-size: 13px;" title="CDNs And Turbobytes With Guest Aaron Peters " href="http://webperformancepodcast.com/cdns-and-turbobytes-with-guest-aaron-peters/" target="_blank">talks CDNs</a><span style="font-size: 13px;"> with guest Aaron Peters.</span></p>
<p style="padding-left: 30px;">* Adams Wiggins, CTO and Co-Founder of Heroku, publishes <a title="Routing and Web Performance on Heroku: a FAQ" href="https://blog.heroku.com/archives/2013/4/3/routing_and_web_performance_on_heroku_a_faq" target="_blank">an extensive FAQ</a> on routing and web performance on Heroku.</p>
<p style="padding-left: 30px;">* Anselm Hannemann describes why he <a title="Use a CDN on GitHub pages" href="http://helloanselm.com/2013/use-a-cdn-on-github-pages/" target="_blank">uses a CDN</a> for static files on GitHub.</p>
<p style="padding-left: 30px;">* Harry Roberts has a few tips for designers and developers to make their <a title="Frontend performance for web designers and front-end developers" href="http://csswizardry.com/2013/01/front-end-performance-for-web-designers-and-front-end-developers/" target="_blank">frontends even faster</a>.</p>
<p style="padding-left: 30px;">* Joshua Bixby wonders why <a title="More new findings: Top ecommerce sites are 22% slower than they were last year" href="http://www.webperformancetoday.com/2013/03/27/top-ecommerce-sites-are-slower-than-they-were-last-year/" target="_blank">eCommerce sites are slower</a> than they were last year.</p>
<p style="padding-left: 30px;">* Johan Johansson shares tips for making your website <a title="How To Make Your Websites Faster On Mobile Devices" href="http://mobile.smashingmagazine.com/2013/04/03/build-fast-loading-mobile-website/" target="_blank">faster on mobile devices</a>.</p>
<p style="padding-left: 30px;">* Intechnica looks at the <a title="15 Web Performance Nightmares, and the damage they caused" href="http://blog.intechnica.co.uk/2012/04/25/15-web-performance-nightmares-and-the-damage-they-caused/" target="_blank">worst 15 web performance nightmares</a> and the damage they caused.</p>
<p>The post <a href="http://blog.newrelic.com/2013/04/05/community-news-speeding-up-the-mobile-web-and-more/">Community News: Speeding up the Mobile Web and More</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/04/05/community-news-speeding-up-the-mobile-web-and-more/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Heroku CTO Publishes Complete Routing and Performance FAQ</title>
		<link>http://blog.newrelic.com/2013/04/03/heroku-cto-publishes-complete-routing-and-performance-faq/</link>
		<comments>http://blog.newrelic.com/2013/04/03/heroku-cto-publishes-complete-routing-and-performance-faq/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 19:02:52 +0000</pubDate>
		<dc:creator>Chris Kelly</dc:creator>
				<category><![CDATA[Partners]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12704</guid>
		<description><![CDATA[<p>Heroku&#8217;s routing mesh and queue time has been a regular topic of conversation over the past few months. If you are new to the conversation, you can catch up on our blog about this topic. As part of this conversation, we updated our Ruby agent to improve the accuracy of the queue time metrics. Today [...]</p><p>The post <a href="http://blog.newrelic.com/2013/04/03/heroku-cto-publishes-complete-routing-and-performance-faq/">Heroku CTO Publishes Complete Routing and Performance FAQ</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a title="Heroku logo" href="http://blog.newrelic.com/wp-content/uploads/heroku-logo.png" target="_blank"><img class="alignright  wp-image-12559" style="margin: 15px 5px;" title="Heroku logo" alt="Heroku logo" src="http://blog.newrelic.com/wp-content/uploads/heroku-logo.png" width="140" height="140" /></a>Heroku&#8217;s routing mesh and queue time has been a regular topic of conversation over the past few months. If you are new to the conversation, you can <a title="Using New Relic on Heroku? Read How Our New Ruby Agent Measures Queue Time" href="http://blog.newrelic.com/2013/02/21/using-new-relic-on-heroku-read-how-our-new-ruby-agent-measures-queue-time/" target="_blank">catch up on our blog</a> about this topic. As part of this conversation, we updated our Ruby agent to improve the accuracy of the queue time metrics.</p>
<p>Today Heroku&#8217;s CTO, Adam Wiggins, published an extensive FAQ discussing <a title="Routing and Web Performance on Heroku: a FAQ" href="https://blog.heroku.com/archives/2013/4/2/routing_and_web_performance_on_heroku_a_faq" target="_blank">routing and web performance on Heroku</a>. The FAQ is a complete guide to the routing layer, a retrospective on how things evolved and a look into the future. In the FAQ, you can find how to determine if your application is affected by the routing layer, as well as extensive help on what steps to take if it is.</p>
<p>This is essential reading for anyone running a Rails application on Heroku.</p>
<p>The post <a href="http://blog.newrelic.com/2013/04/03/heroku-cto-publishes-complete-routing-and-performance-faq/">Heroku CTO Publishes Complete Routing and Performance FAQ</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/04/03/heroku-cto-publishes-complete-routing-and-performance-faq/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Quick Guide to Getting Started with New Relic</title>
		<link>http://blog.newrelic.com/2013/03/29/a-quick-guide-to-getting-started-with-new-relic/</link>
		<comments>http://blog.newrelic.com/2013/03/29/a-quick-guide-to-getting-started-with-new-relic/#comments</comments>
		<pubDate>Fri, 29 Mar 2013 20:32:48 +0000</pubDate>
		<dc:creator>Chris McCraw</dc:creator>
				<category><![CDATA[Did You Know]]></category>
		<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Real User Monitoring]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12682</guid>
		<description><![CDATA[<p>Are you new to New Relic? Looking to get a little deeper than the overview graphs? This is an introduction and first in a series of UI walkthroughs for our site. Our UI exposes a lot of information in a little bit of space and it can be easy to miss available functionality. To get [...]</p><p>The post <a href="http://blog.newrelic.com/2013/03/29/a-quick-guide-to-getting-started-with-new-relic/">A Quick Guide to Getting Started with New Relic</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Are you new to New Relic? Looking to get a little deeper than the overview graphs? This is an introduction and first in a series of UI walkthroughs for our site.</p>
<p>Our UI exposes a lot of information in a little bit of space and it can be easy to miss available functionality. To get the most from New Relic, we recommend that you get started with our existing site documentation beginning with the <a title="New Relic Docs: Application section" href="https://newrelic.com/docs/site" target="_blank">Application section</a>. This area goes into the application dashboard screen in great detail. You can get information on each of the following categories:</p>
<p style="padding-left: 30px;">* <a title="New Relic Docs: Overview" href="https://newrelic.com/docs/site/applications-overview" target="_blank">Overview</a><br />
* <a title="New Relic Docs: Application Map (aka App Map)" href="https://newrelic.com/docs/site/map" target="_blank">Application Map (aka App Map)</a><br />
* <a title="New Relic Docs: Web Transactions" href="https://newrelic.com/docs/site/web-transactions" target="_blank">Web Transactions</a><br />
* <a title="New Relic Docs: Database &amp; Slow SQL" href="https://newrelic.com/docs/site/database-and-slow-sql" target="_blank">Database &amp; Slow SQL</a><br />
* <a title="New Relic Docs: External Services" href="https://newrelic.com/docs/site/external-services" target="_blank">External Services</a><br />
* <a title="New Relic Docs: Background Tasks" href="https://newrelic.com/docs/site/background-tasks" target="_blank">Background Tasks</a><br />
* <a title="New Relic Docs: Geography" href="https://newrelic.com/docs/site/geography" target="_blank">Geography</a><br />
* <a title="New Relic Docs: Geography" href="https://newrelic.com/docs/site/browsers" target="_blank">Browsers</a></p>
<p>If you don’t have time to read through all that, here are some tips to get you started quickly.</p>
<p><span style="font-size: 1.25em;"><b>The Application Overview Page</b></span><br />
The <a title="New Relic Docs: Application Overview page" href="https://newrelic.com/docs/site/applications-overview" target="_blank">Application Overview page</a> has details about the overall state of your application and a quick look at the data that’s fleshed out in the other tabs. It’s a good place to see your performance trends at a glance – from page load times, to error rates, slow transactions, and a list of servers running the app. There’s a great deal of data here to be found and you can click through to take a deeper dive into any category.</p>
<p>Here you can experiment with the time picker and zoom in on any of the graphs. And if you’re using our <a title="New Relic Docs: Server Monitoring" href="https://newrelic.com/docs/server/new-relic-for-server-monitoring" target="_blank">Server Monitoring</a> feature, you can see a list of servers at the bottom of the page. Click through and you’ll reach the server monitoring section of our UI.</p>
<p>In the Response Time graph, you can see how events like outages, setting changes and deployments are affecting your performance. And the <a title="New Relic Docs: Browser / App Server selector" href="https://newrelic.com/docs/features/how-does-real-user-monitoring-work" target="_blank">Browser / App Server selector</a> allows you to hide or expose Real User Monitoring (browser) data.</p>
<p style="text-align: center;"><a title="Browser Data" href="http://blog.newrelic.com/wp-content/uploads/appbrowser.png" target="_blank"><img class="aligncenter  wp-image-12688" style="border: 1px solid black;" title="Browser Data" alt="Browser Data" src="http://blog.newrelic.com/wp-content/uploads/appbrowser.png" width="189" height="39" /></a></p>
<p style="text-align: left;">You&#8217;ll also find a historical comparison button that will let you see how your performance has changed over the past day or week.</p>
<p style="text-align: center;"><a title="Comparison Button" href="http://blog.newrelic.com/wp-content/uploads/historical1.png" target="_blank"><img class="aligncenter  wp-image-12687" style="border: 1px solid black;" title="Comparison Button" alt="Comparison Button" src="http://blog.newrelic.com/wp-content/uploads/historical1.png" width="335" height="464" /></a></p>
<p><span style="font-size: 1.25em;"><b>The App Map Page</b></span><br />
The <a title="New Relic Docs: App Map" href="https://newrelic.com/docs/site/map" target="_blank">App Map page</a> is interesting if your app talks to external services or other apps New Relic knows about. If your app does have multiple tiers, this page provides a good summary dashboard of all your external (HTTP) services, databases, <a title="New Relic Docs: Cross Application Traces" href="https://newrelic.com/docs/features/cross-application-traces" target="_blank">other apps being monitored by New Relic</a>, and browser load times, with response times and throughputs for each of these services.</p>
<p><span style="font-size: 1.25em;"><b>The Web Transactions Page</b></span><br />
The <a title="New Relic Docs: Web Transactions" href="https://newrelic.com/docs/site/web-transactions" target="_blank">Web Transactions page</a> shows you where the app spends most of its time and effort, and causes the most user dissatisfaction. Its also where you can find overview details about a type of transaction, as well as specific recorded slow transactions including HTTP parameters, an execution waterfall graph and details about slow SQL queries.</p>
<p>On this page, the number one under-used feature is the <i>Sort Order </i>dropdown. There we <span style="font-size: 13px;">show you the transactions chewing the most CPU, but you may be more interested in the highest throughput or flat-out slowest transaction, even if it’s infrequently called. </span>Also note the <i>Graph vs. Table View </i>selector in the upper right. This will give you a more complete list instead of a top five graph.</p>
<p style="text-align: center;"><a title="Graph vs. Table View" href="http://blog.newrelic.com/wp-content/uploads/graphtable.png" target="_blank"><img class="aligncenter  wp-image-12684" style="border: 1px solid black;" title="Graph vs. Table View" alt="Graph vs. Table View" src="http://blog.newrelic.com/wp-content/uploads/graphtable.png" width="266" height="140" /></a></p>
<p>And don’t miss the <i>Show more slow transactions </i>link in the bottom right. It will show you a more complete listing for the time window you’ve picked, sorted in order of slowest execution.</p>
<p><span style="font-size: 1.25em;"><b>The Database Page</b></span><br />
The <a title="New Relic Docs: Database &amp; Slow SQL" href="https://newrelic.com/docs/site/database-and-slow-sql" target="_blank">Database page</a> shows you information about your app’s SQL usage – where your app spends most of its database times and effort, and it’s where you can find details about your slowest queries. The <i>Sort order </i>dropdown can help you re-filter your results and don’t miss the ability to click through a specific trace to the transaction name.</p>
<p style="text-align: center;"><a title="Database Click Through" href="http://blog.newrelic.com/wp-content/uploads/dbclickthru.png" target="_blank"><img class="aligncenter  wp-image-12685" style="border: 1px solid black;" alt="Database Click Through" src="http://blog.newrelic.com/wp-content/uploads/dbclickthru.png" width="466" height="157" /></a></p>
<p><span style="font-size: 1.25em;"><b>The Externals Page</b></span><br />
The <a title="New Relic Docs: External Services" href="https://newrelic.com/docs/site/external-services" target="_blank">Externals page</a> shows you detailed throughput and response graphs about the services you contact via HTTP.</p>
<p><span style="font-size: 1.25em;"><b>The Background Page</b></span><br />
The <a title="New Relic Docs: Background Tasks" href="https://newrelic.com/docs/site/background-tasks" target="_blank">Background page</a> has information about tasks you’ve marked as background and/or we know are run from the command-line. We do collect transaction traces for background jobs as long as the run time exceeds your trace threshold. You can click through to any errors we’ve recorded.</p>
<p style="text-align: center;"><a title="Error Click Through" href="http://blog.newrelic.com/wp-content/uploads/errorclickthru.png" target="_blank"><img class="aligncenter  wp-image-12686" style="border: 1px solid black;" title="Error Click Through" alt="Error Click Through" src="http://blog.newrelic.com/wp-content/uploads/errorclickthru.png" width="413" height="216" /></a></p>
<p><span style="font-size: 1.25em;"><b>The Geography Page</b></span><br />
The <a title="New Relic Docs: Geography" href="https://newrelic.com/docs/site/geography" target="_blank">Geography page</a> helps you visualize how your RUM timing data varies by geographic location. Go to the Settings (Application) page to break out specific countries or states. Once again, sort order will let you see the list organized in the way that’s most important to you.</p>
<p><span style="font-size: 1.25em;"><b>The Browsers Page</b></span><br />
The <a title="New Relic Docs: Browsers" href="https://newrelic.com/docs/site/browsers" target="_blank">Browsers page</a> lets you visualize your RUM data per browser statistics. It’s a great place to find a focus for browser specific optimization or to see if optimizations are even necessary.</p>
<p><span style="font-size: 1.25em;"><b>Next Steps</b></span><br />
If you’re looking for a good follow up to this post, check out our <a title="New Relic Docs: The New Relic UI" href="https://newrelic.com/docs/site/the-new-relic-ui#drilldown" target="_blank">general conventions</a> for using the New Relic dashboard. It includes instructions for setting your view to include a date range or particular server.</p>
<p>We’ll be running a follow ups to this post soon, so remember to check back later. And if there’s anything you’d like us to cover in the future, let us know in the comments below.</p>
<p>The post <a href="http://blog.newrelic.com/2013/03/29/a-quick-guide-to-getting-started-with-new-relic/">A Quick Guide to Getting Started with New Relic</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/03/29/a-quick-guide-to-getting-started-with-new-relic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Your Provider Down? New Relic Can Help!</title>
		<link>http://blog.newrelic.com/2013/03/25/is-your-provider-down-new-relic-can-help/</link>
		<comments>http://blog.newrelic.com/2013/03/25/is-your-provider-down-new-relic-can-help/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 13:30:27 +0000</pubDate>
		<dc:creator>Lee Atchison</dc:creator>
				<category><![CDATA[Performance Tech Tips]]></category>
		<category><![CDATA[Top Post]]></category>

		<guid isPermaLink="false">http://blog.newrelic.com/?p=12635</guid>
		<description><![CDATA[<p>On October 22, 2012, Amazon Web Services had a significant event in their US-East region. The net result was that the websites of many companies were down or otherwise negatively impacted. Even though I work at New Relic, I run a couple of personal websites that were affected by the event. And New Relic helped [...]</p><p>The post <a href="http://blog.newrelic.com/2013/03/25/is-your-provider-down-new-relic-can-help/">Is Your Provider Down? New Relic Can Help!</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>On October 22, 2012, Amazon Web Services had a significant event in their US-East region. The net result was that the websites of many companies were down or otherwise negatively impacted.</p>
<p>Even though I work at New Relic, I run a couple of personal websites that were affected by the event. And New Relic helped me quickly figure out what was going on and what I could do about it.</p>
<p><span style="font-size: 1.25em;"><b>It All Started with a Page</b></span><br />
My first indication that there was a problem came from a page sent to my iPhone. At 10:46 am, I got the following message:</p>
<p><i>“ALRT #212 on New Relic: Alert on nimbus secure opened”</i></p>
<p style="text-align: center;"><a title="New Relic Alert page from PagerDuty" href="http://blog.newrelic.com/wp-content/uploads/NewRelic_alert_page.png" target="_blank"><img class="aligncenter  wp-image-12636" title="New Relic Alert page from PagerDuty" alt="New Relic Alert page from PagerDuty" src="http://blog.newrelic.com/wp-content/uploads/NewRelic_alert_page.png" width="248" height="370" /></a></p>
<p>The page came from <a href="http://www.pagerduty.com/">PagerDuty</a> (another great support tool), that I have setup to receive notifications of events from New Relic. Within minutes of the start of the event, I was engaged.</p>
<p><span style="font-size: 1.25em;"><b>What Was Going On?</b></span><br />
So, what was up? I logged into New Relic and immediately found that my applications were in distress:</p>
<p style="text-align: center;"><a title="Applications alert screenshot" href="http://blog.newrelic.com/wp-content/uploads/applications_screenshot.png" target="_blank"><img class="aligncenter  wp-image-12637" style="border: 1px solid black;" title="Applications alert screenshot" alt="Applications alert screenshot" src="http://blog.newrelic.com/wp-content/uploads/applications_screenshot.png" width="632" height="171" /></a></p>
<p>Neither application was serving traffic. I’d already received an alert on one of them. And the second was about to … obviously something was very, very wrong.</p>
<p>I clicked on the first application. This confirmed no traffic was going through. My Apdex score had dropped to zero:</p>
<p style="text-align: center;"><a title="Apdex Score" href="http://blog.newrelic.com/wp-content/uploads/apdex_score.png" target="_blank"><img class="aligncenter  wp-image-12638" style="border: 1px solid black;" title="Apdex Score" alt="Apdex Score" src="http://blog.newrelic.com/wp-content/uploads/apdex_score.png" width="386" height="200" /></a></p>
<p>Given this, my next step was to look at my application servers:</p>
<p style="text-align: center;"><a title="Recent Server Events" href="http://blog.newrelic.com/wp-content/uploads/Recent_Server_Events.png" target="_blank"><img class="aligncenter  wp-image-12639" style="border: 1px solid black;" title="Recent Server Events" alt="Recent Server Events" src="http://blog.newrelic.com/wp-content/uploads/Recent_Server_Events.png" width="630" height="234" /></a></p>
<p>I noticed two things here. First, half of my servers were being impacted – all within in single AWS availability zone. The number went up as the event went on and spread. Secondly, my servers were reporting that disk I/O went up to 100%. I clicked on ip-10-1-0-101, which is my primary webserver for my distressed application and got the following charts:</p>
<p style="text-align: center;"><a title="Load Average" href="http://blog.newrelic.com/wp-content/uploads/load_average.png" target="_blank"><img class="aligncenter  wp-image-12640" style="border: 1px solid black;" title="Load Average" alt="Load Average" src="http://blog.newrelic.com/wp-content/uploads/load_average.png" width="499" height="216" /></a></p>
<p style="text-align: center;"><a title="CPU Usage" href="http://blog.newrelic.com/wp-content/uploads/CPU_usage.png" target="_blank"><img class="aligncenter  wp-image-12641" style="border: 1px solid black;" title="CPU Usage" alt="CPU Usage" src="http://blog.newrelic.com/wp-content/uploads/CPU_usage.png" width="530" height="183" /></a></p>
<p>From these, I saw that the processes were getting backed up trying to do disk I/O which appeared to look backlogged. Looking further, I saw this:</p>
<p style="text-align: center;"><a title="Disk I/O Utilization &amp; Network I/O" href="http://blog.newrelic.com/wp-content/uploads/Disk-Network-IO.png" target="_blank"><img class="aligncenter  wp-image-12642" style="border: 1px solid black;" title="Disk I/O Utilization &amp; Network I/O" alt="Disk I/O Utilization &amp; Network I/O" src="http://blog.newrelic.com/wp-content/uploads/Disk-Network-IO.png" width="630" height="160" /></a></p>
<p>I saw that I was no longer sending data over the network to my disks (in AWS, the disks are on remote servers, called EBS volumes.) Obviously, Amazon’s EBS service was having problems. This is a common cause of outages on AWS, so it wasn’t much of a surprise to me. I went to the Amazon website and confirmed they were aware of the problem and working on a resolution.</p>
<p style="text-align: center;"><a title="AWS Current Status" href="http://blog.newrelic.com/wp-content/uploads/AWS_Current_Status.png" target="_blank"><img class="aligncenter  wp-image-12643" style="border: 1px solid black;" title="AWS Current Status" alt="AWS Current Status" src="http://blog.newrelic.com/wp-content/uploads/AWS_Current_Status.png" width="630" height="368" /></a></p>
<p><span style="font-size: 1.25em;"><b>Now What …</b></span><br />
You can see that within a few minutes of the problem occurring, and with just a couple minutes of evaluation of data on existing New Relic charts, I was able to determine exactly what the problem was and exactly which servers were impacted and in which availability zone. (Amazon never tells you which availability zones are impacted, just whether it’s one or more.)</p>
<p>As a result, I knew exactly what my options were. For example, I could have deployed new servers with backup images to other servers in other AWS availability zones (avoiding the problematic one) or have traffic routed to servers I setup in other backup service providers.</p>
<p><span style="font-size: 1.25em;"><b>Summary</b></span><br />
In this particular case, the problem came from a large-scale outage on AWS and it was difficult to self-recover since so much was impacted. However, this sort of problem occurs on a much smaller scale at other times with AWS and similar providers. Disk volumes go bad, servers go down, I/O gets backlogged, etc. The point is that I was able to immediately diagnose the problem in just a couple minutes using New Relic, and could quickly switch my focus to helping my customers and working around the issue. Using just the tools and data that AWS (or other service providers) give me, it’s a potentially significantly harder &#8212; and more time consuming &#8212; problem to solve.</p>
<p>Have you run into a similar situation? Let us know in the comments below.</p>
<p>The post <a href="http://blog.newrelic.com/2013/03/25/is-your-provider-down-new-relic-can-help/">Is Your Provider Down? New Relic Can Help!</a> appeared first on <a href="http://blog.newrelic.com">New Relic blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.newrelic.com/2013/03/25/is-your-provider-down-new-relic-can-help/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
