<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Tech Blog]]></title>
  <link href="http://devblog.thinkthroughmath.com/atom.xml" rel="self"/>
  <link href="http://devblog.thinkthroughmath.com/"/>
  <updated>2014-07-16T14:30:53-04:00</updated>
  <id>http://devblog.thinkthroughmath.com/</id>
  <author>
    <name><![CDATA[TTMers]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Meet the Team: Manda Brown]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2014/07/01/meet-the-team-manda-brown/"/>
    <updated>2014-07-01T13:18:00-04:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2014/07/01/meet-the-team-manda-brown</id>
    <content type="html"><![CDATA[<p>Hi! I&#8217;m Manda Brown, a software developer at Think Through Math, where I enjoy working with an amazing team to build great software. Although I love my job, occasionally everyone needs a change of pace, and I&#8217;m just returning to the office after a week-long vacation.</p>

<p>Last summer, my then 14-year-old daughter got a taste of bike camping over a weekend, and enjoyed it so much that she convinced us to make the trek from our home town of Pittsburgh, PA to Washington, DC. We took six days to do it, travelling 335 miles on the <a href="http://www.atatrail.org/">Great Allegheny Passage and the C&amp;O Canal Towpath</a>; bikes heavy with gear, food, and water. It was an amazing adventure! I&#8217;m so happy to have done it and to have been able to give that experience to my daughter. I&#8217;m also happy to be back home again, where I have a shower and a laptop.</p>

<p>Pedalling along the trail for hours a day leaves a lot of time for observation and contemplation. Beautiful forests sheltered the trail; it wound beside and around sinuous rivers, threaded through occasional towns, and eventually led us to the capital. Math was all around us; often the setting inspired thoughts about things like the <a href="https://www.youtube.com/watch?v=ahXIMUkSXX0">fibonacci numbers apparent in natural growth of the plants</a>, the diversity and population cycles of the creatures we glimpsed as we passed (or swatted when they took a bite), the complex and beautiful math that describes the swirling currents of water, or the stresses and forces at work to create and expose the varied rock formations sporadically embellishing the scenery. And the evidence of math informing human activity was everywhere from the canal and towpath itself, to the railroads, to the architecture that ranged from simple and functional to the ornate and grandiose.</p>

<p>We used math a lot too. There were very important questions to answer: where will we stop for snacks? Do we need to stop in town and acquire more calories and deliciousness? Should we refill our water now, or can we wait until the next opportunity? How long should we expect to be on the bike each day? Will we beat the thunderstorm edging ominously closer on the radar? (We didn&#8217;t.) We were constantly exercising simple math involving time and distance to help us manage our resources and energy.</p>

<p>But my favorite trail math is even simpler: subtracting one. My daughter and I wouldn&#8217;t really consider ourselves athletes; we like to ride our bikes, but this was by far the most challenging ride we&#8217;ve ever undertaken and it wasn&#8217;t always easy. Each mile marker was a small victory. And they added up to larger minus ones. One mile at a time until we got to the next stopping point. One stretch and water break at a time until we got to the next meal. One meal at a time until we got through the next day (at day 5, we were pretty happy with our progress; but stayed at a hostel with a bunch of amazing Appalachian Trail through-hikers whose time units were months!). One day at a time until we finished one trail, and then the other. And finally one challenge complete, the adventure over.</p>

<p>The best thing about that last one is that the minuend of the expression is infinite. So what&#8217;s next?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[From "SYS 2064" to "git push origin master"]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2014/06/17/meet-the-team-keith-weightman/"/>
    <updated>2014-06-17T13:20:00-04:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2014/06/17/meet-the-team-keith-weightman</id>
    <content type="html"><![CDATA[<p><a href="http://devblog.thinkthroughmath.com/uploads/keith_c64.JPG"><img src="http://devblog.thinkthroughmath.com/uploads/keith_c64.JPG" alt="HAHAHA!  Look at that couch!" width="235" style="float:right; margin-left: 10px;" /></a></p>

<p>Howdy!  My name is Keith Weightman.  I&#8217;m a Senior Software Developer (and Man of Mystery) here at Think Through Math.  I have been programming pretty much since I was around 12.</p>

<p>Dig that C64!</p>

<p>Well I mostly played games, and only dabbled in code.  Things got serious when I double majored at <a href="http://www.upj.pitt.edu/" target="_blank">UPJ</a> in math and computers, which turns out is a great fit for working here at TTM!</p>

<p>So what does it mean to be a &#8220;senior&#8221; developer?  Well basically since I have experience on many programming languages, many databases, many development processes (I even go back to the waterfall model) - I have seen many scenarios and design methods that work and don&#8217;t work, and can advise as such going forward.</p>

<p>At TTM, being senior can sometimes just mean older!  Back in 2012 our CTO Jim Wrubel chose to take our team, and company, in a different technical direction.  The conversation went something like this:</p>

<blockquote><p><strong>Jim:</strong>   &#8220;So Keith, you know how we hired you 6 weeks ago to do .NET and SQL Server?&#8221;</p>

<p><strong>Keith:</strong> &#8220;Ah, yeah?&#8221;</p>

<p><strong>Jim:</strong>    &#8220;Well we decided to take a different technical path.  We are going to convert everything to a Ruby on Rails app with a Postgresql back end.  You in?&#8221;</p>

<p><strong>Keith:</strong> (After wondering what Ruby on Rails was). &#8220;Sure!&#8221;</p></blockquote>

<p>Jim&#8217;s wise decision meant many changes and challenges for TTM and myself:</p>

<ul>
<li><p>TTM closely follows a <a href="http://en.wikipedia.org/wiki/ROWE" target="_blank">ROWE</a> management strategy.  This is based on results, not necessarily focusing on <em>how</em> you get there.  You can have more flexible work hours, but you also sometimes need to work at non-typical times and places.  This is rare in Pittsburgh, and I am blessed to be a part of it, as I am divorced with 2 children and have a complicated non-standard home life. All my previous positions were a standard east coast 9-5 type of day.  Time for me to <strong>adapt</strong>.</p></li>
<li><p>I&#8217;m more comfortable with tightly coupled languages where the compiler forces syntax.  RoR is loosely coupled, not so much compile checking, and components know little or nothing of other components .  Time for me to <strong>grow</strong>.</p></li>
<li><p>The Ruby community strives and excels as an Open Source community.  It&#8217;s a simple effective mindset - &#8220;Share with others what you love to do&#8221;.  What&#8217;s this Open Source thing you say?</p></li>
</ul>


<blockquote><ul>
<li>Share (open-source) your code online (<a href="http://devblog.thinkthroughmath.com//github.com" target="_blank">github</a>)</li>
<li>Share your knowledge with coworkers (lunch &amp; learns, code pairing)</li>
<li>Attend conferences (<a href="http://www.steelcityruby.org/" target="_blank">SCRC</a>, <a href="http://devopsdays.org/" target="_blank">DevOpsDays</a>)</li>
<li>Join meet-up groups (<a href="http://www.meetup.com/pittsburgh-ruby/" target="_blank">Ruby Meetups</a>, <a href="http://www.meetup.com/Pittsburgh-Code-Supply/" target="_blank">Code Supply</a>)</li>
</ul>
</blockquote>

<p>I came from the opposite mindset (Department of Defense, Seagate) where they want you to hide and secure your great work so no one can steal it.  This is the most challenging change for me, but guess what?  Time for me to <strong>change</strong>.</p>

<ul>
<li>I didn&#8217;t know Ruby!  We hired many incredibly awesome developers who are familiar with Ruby and the Open Source style.  So I&#8217;m the old dog now learning new tricks from these young spring chickens!  Fortunately, I don&#8217;t have much pride and am happy to learn from them.  Time to <strong>learn</strong>!</li>
</ul>


<p>It&#8217;s been a year or so and I&#8217;m still changing, and a little more &#8220;senior&#8221; than I was when Jim and I had our talk.  As you will find out if you take a career in software development, things are always advancing.  Being &#8220;senior&#8221; means you are always <strong>growing</strong>, always <strong>adapting</strong>, always <strong>learning</strong>, and often <strong>changing</strong>!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Meet the Team: Joel McCracken]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2014/04/30/meet-the-team-joel-mccracken/"/>
    <updated>2014-04-30T21:41:00-04:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2014/04/30/meet-the-team-joel-mccracken</id>
    <content type="html"><![CDATA[<p>Hi! I&#8217;m Joel McCracken, a software developer at Think Through Math.
We developers have been trying to introduce ourselves so that people
outside of our team can get to know us.
I have worked on a number of features in the Think Through Math
application, including
the equation builder and the calculator.</p>

<p>I love programming. I think it is one of the most rewarding
and intellectually satisfying pursuits that exist! In fact, next to
reading, it is the most important thing that I have ever learned to
do.</p>

<p>A little while back, I was part of a conversation with our CTO, James
Wrubel. James mentioned to us that he didn&#8217;t realize at first how much
programmers care about mathematics education, and the mission at TTM
would make it eaiser to hire programmers to work on our system.</p>

<p>This conversation got me to thinking: Why do I care so much about
math and education? I don&#8217;t think the connection between math and
programming is obvious. Often, we do not need to use much math
in our day-to-day work as software developers.
At a glance, it would seem that programming and math do not have all
that much in common.</p>

<p>Conversely, computer science is considered a sub-discipline of
mathematics. Part of a computer science education typically requires
classes in some advanced mathematics. And, computers were
developed in order to help humans perform math faster.
So it would seem that mathematics is somehow central to what a
programmer does.
How do we reconcile the fact that we do not
need to use advanced math in what we do,
and yet math is fundamental to programming?</p>

<p>Here is my answer, in two parts.
Back in school, I enjoyed some parts of my math classes.
Math helped me to understand parts of the world.
I liked learning how things worked and related to one another,
and how we can use math to figure things out.
Many of the problems we had to do were a certain type
we called &#8220;word problems&#8221;. These problems presented a scenario, and
we had figure out how to apply what we are learning to that scenario.</p>

<p>Similarly, developers solve problems with software.
We need to ask the right questions, look at code and information
available, and then develop solutions based upon what we have
discovered. Basically, we do word problems all day, every day, but
with real life challenges.</p>

<p>However, I believe there is a more important and subtle connection
between math and programming.
Programming a computer requires a very rigorous way of thinking.
In a mathematics problem, if you write a 4 instead of a 5, forget to
carry the one, etc, you will come up with the wrong answer.
In software, if a developer forgets to &#8220;carry the one&#8221; in
their code, this creates bugs.
Of the things we learn in school, mathematics
is the only thing topic that is remotely similar.</p>

<p>In fact, you may be familiar with a recent bug named
&#8220;heartbleed&#8221;. This bug left most of the world&#8217;s information exposed to
prying eyes. The cause of bug might be likened to forgetting to carry
the one! So, exactness and precision are very important to programming.</p>

<p>In our society, mathematics is the gateway into programming.
It trains you to think in the way that programmers must think in order
to build software.
Personally, I hope that the work I do at Think Through Math will help
some students become better at math,
and through that comfort will be able to experience
the intellectual wonders of the world, such as programming.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Meet the Team: Jeff Koenig]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2014/03/09/meet-the-team-jeff-koenig/"/>
    <updated>2014-03-09T23:25:00-04:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2014/03/09/meet-the-team-jeff-koenig</id>
    <content type="html"><![CDATA[<p>Hi web surfers! My name is Jeff Koenig and I am the Quality Assurance Manager and relentless automator at Think Through Math.
  I&#8217;ve been with TTM for a little over a year now and I&#8217;ve loved working here. In my time here I&#8217;ve worked setting up a
scalable jenkins continuous integration environment, load testing and have helped maintain the quality of the software that
our awesome team produces.</p>

<p>How do I use math in my everyday life? Well something that has been very important to me in many aspects of my life is efficiency.
  Efficiency is basically the cost of particular task. This cost can be a combination of time, money, and effort, among other things.
This turned out to be a very important value to have while working as a line cook. Which is what I did from the time I turned 15 up
until I graduated from college. But wait, what does any of this have to do with math? Well the main job a of a line cook is to
reproduce a number of menu items as fast as possible without sacrificing the quality or taste of the dish. So it becomes very
important to figure out how you can assemble a dish in the least amount of time possible. This requires analysing the process of
putting together a particular dish, and shorting every step of the process that you can. This means that anything that can be prepared
ahead of time is a must. After that, the next major time savings is having things located as close to where they will be used in the
process as possible. Doing this will keep you from having to waste precious time taking steps away from your station and the dish
you are preparing. When you do have to take the hit of walking a couple steps away from your station, it is important to make that
movement as effective as possible by getting anything you are going to need from that area so that you take that trip as few times
 as possible. Then, continue you tearing apart the longest step of the process and making it shorter and before you know it, you
are putting out beautiful dishes in a matter of a few minutes.</p>

<p>As it turns out to be an excellent value to have in any part of your life. Finding the most effective way to perform particular
tasks in your everyday life and in your work will make you a much more effective person and save you time and money.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Meet the Team: Tim Bickerton]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2014/03/03/meet-the-team-tim-bickerton/"/>
    <updated>2014-03-03T17:32:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2014/03/03/meet-the-team-tim-bickerton</id>
    <content type="html"><![CDATA[<h2>About Me</h2>

<p>Hi everyone. I&#8217;m Tim Bickerton, Project Manager at Think Through Math, and I&#8217;m just about to celebrate my one-year
anniversary with the team. I&#8217;m pleased to be able to spend every day working with an extraordinary group of people
all committed to helping students learn math.</p>

<p>What&#8217;s a Project Manager do, you ask? Together with Jim, our CTO, and our Product Management organization,
I help to ensure our talented engineers have a clearly defined feature roadmap
<strong>and</strong> are kept free from distraction to focus on their creativity. I also partner with TTM Customer Support
to ensure that customer feedback and issues are addressed in a timely manner with
world-class technical customer service. In the past year, I&#8217;ve partnered with TTM engineers to develop new reports and
dashboards for teachers and administrators, new problem types for students and enhanced experiences for parents, among
other projects.</p>

<p>Jim promotes a culture of teaching and learning at TTM, and that&#8217;s a culture I&#8217;m proud to stand behind. As a part-time
adjunct instructor of IT Management at a local university, I take my job of demystifying technology to my
undergraduate students very seriously. My goal is to provide my students the tools to be successful, and leave my
courses with an understanding of just how much technology complements their professional and personal lives.
Teaching and working at TTM provide me avenues to &#8220;give back&#8221; to students by providing them with the
tools, feedback and instruction they need to be successful in math, technology, or even life!</p>

<h2>So, how do I use math in my life every day?</h2>

<p>Calculating my students&#8217; grades, of course!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Working at Think Through Math]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/12/23/working-at-think-through-math/"/>
    <updated>2013-12-23T10:33:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/12/23/working-at-think-through-math</id>
    <content type="html"><![CDATA[<p>When we screen candidates, they frequently ask, &#8220;What&#8217;s special about Think Through Math?&#8221;</p>

<p>Developers hate to repeat themselves so this post is an attempt to describe what we think makes working at TTM different than other companies. Though this post is focused on working on the Think Through Math product development team (engineering, QA, project management, UX), many of the concepts are valid for the company as a whole.</p>

<h2>Our culture</h2>

<p>We&#8217;ve developed a very cohesive team over the years. We&#8217;re all working
at Think Through Math because we find the work meaningful and we
believe in the work that we do. We also have some very specific values
that are important to us as we work to fulfill our corporate mission:</p>

<ul>
<li><p>Everyone is a teacher, and everyone is a learner. Literally half of
the company is made up of current or former certified teachers, but
even for those of us who aren&#8217;t certified, teaching and learning are
core values. Our staff come from diverse backgrounds - teachers,
publishers, designers, developers, but we all share an interest in
teaching and learning (and math of course!). From this value, we get
pair programming and peer code review as practices. We also get
involved with the larger community (local and online), since we
realize that the answers we seek are not always held by the people
we work with directly.</p></li>
<li><p>Continuous Improvement. We follow many Agile processes; we do a
daily standup (and some sub-teams do their own separate standup), we
organize our work in to iterations while shipping features when
they&#8217;re ready, and hold iteration demos. But these are just
actions. As a team, the thing we care most about is continuously
improving everything we do: git workflow, deployment, operations
support, etc. Our git structure reflects our principle of continuous
improvement. We have two primary branches for our projects: master
(which reflects what&#8217;s in production) and rc (release candidate).</p></li>
<li><p>Giving back. We rely heavily on open source software and
platforms. It would be irresponsible of us to not try to find
opportunities to contribute back to that community through code,
knowledge sharing (including this blog), responding to Stack
Overflow questions, participating in local meetups, and so forth. In
many ways, this goes hand-in-hand with our focus on teaching and
learning. In addition to corporate goals, every member of the team
is expected to contribute to at least one open source project every
year and to give two presentations on topics in their area of
expertise at national/international conferences, regional meetups,
or even company lunch-and-learns.</p></li>
</ul>


<h2>The hiring process</h2>

<p>For technical positions, our hiring process is two steps. The first step is a group interview with 5-6 of the current development, QA, design, UX, and project management staff. We do a group interview so that we don&#8217;t pester candidates with the same set of questions, and because one of the things we look for in a candidate is their ability to gel with the team.</p>

<p>We realize it can be intimidating to do a panel-style interview but they are really informal. At one point during an interview we stopped to pull up the Lego interpretation of Eddie Izzard&#8217;s <a href="https://www.youtube.com/watch?v=MpfmzfRf8UI">Death Star Canteen skit</a>.</p>

<p>Great developers will always have options when they&#8217;re looking for a job, and it&#8217;s important for us to make sure the candidate knows what it would be like to work at Think Through Math as much as it is for us to get to know the candidate.</p>

<p>For the second step of the interview process, we ask candidates to give a 30-minute presentation on a topic they&#8217;re passionate about. We prefer the topic be nontechnical since technical topics can be dull and we value diversity of interests. Our interview process matches our corporate culture; we are all teachers and our interview process selects for people who share that interest. Over the past year+ we&#8217;ve had this policy we&#8217;ve had presentations on coffee, henna tattooing, bowling, watches, and vinyl records, among others.</p>

<p>One thing we don&#8217;t do in interviews is ask people to write code, pseudo or other. We favor candidates with active open source contributions (giving back to OSS is another of TTM&#8217;s values), so typically by the time a candidate comes for an interview we&#8217;ve had a chance to see their code already. There&#8217;s not much we would learn in 45 minutes of live-code interviewing that we couldn&#8217;t see from someone&#8217;s OSS contributions.</p>

<p>Another reason we don&#8217;t do code in interviews is that it&#8217;s an unrealistic scenario. TTM has an aggressive roadmap, but I can&#8217;t think of a situation where we would have a 45-minute deadline to write code. It&#8217;s too easy for a live-code interview to turn in to a series of gotcha questions. Old standbys like &#8220;How do you reverse a string?&#8221; become meaningless when the language includes a <code>.reverse</code> method. We want our interviews to reflect what people will actually do day-to-day. If you&#8217;re working on something and don&#8217;t immediately have the answer, you search for it. Usually you end up on Stack Overflow, find something that works, and move on. In an interview situation how would a potential employer feel about a candidate going to Stack Overflow? The process of writing code in an interview feels awkward, so we tend to avoid it.</p>

<h2>Summary</h2>

<p>If you&#8217;re interested in working at Think Through Math, or you&#8217;re a candidate wondering what the interview process is like, hopefully this post is useful to you. If you <em>are</em> interested in working here, check out <a href="http://apangea.theresumator.com/apply">our openings</a> and drop us a line!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Pennsylvania dev team uses this one weird trick to save 67% on their New Relic bill]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/11/11/pennsylvania-dev-team-uses-this-one-weird-trick-to-save-67-percent-on-their-new-relic-bill/"/>
    <updated>2013-11-11T20:12:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/11/11/pennsylvania-dev-team-uses-this-one-weird-trick-to-save-67-percent-on-their-new-relic-bill</id>
    <content type="html"><![CDATA[<p>We love <a href="http://newrelic.com">New Relic</a>. It&#8217;s saved us countless times in production, it&#8217;s the tool we use when we turn developer attention toward optimization, and it&#8217;s the gold standard for application monitoring. The only issue we have honestly is that as we&#8217;ve grown the monthly spend on New Relic starts to get steep.</p>

<p>Our primary platform is a rails app. We help nearly 10% of the U.S. math students in grades 3 through Algebra, so on any given school day we&#8217;re pushing a <em>lot</em> of traffic. At peak loads we run a pool of 20 web servers on AWS to handle our traffic. We typically only need max capacity for 6 hours a day as our night and weekend traffic is much lower, but New Relic charges by the server for their Standard and Pro accounts (we use Pro and would recommend it to anyone). Although there&#8217;s some allowance in their pricing model for &#8216;burst&#8217; models, at <a href="http://newrelic.com/pricing">list price $149/mo per server</a> on an annual contract we would end up spending nearly $3k per month for their service.</p>

<p>At Think Through Math we&#8217;re always looking to spend money wisely. Anything we save can help us reach more students at lower cost or add staff to help us add features more quickly. So any infrastructure spend is a candidate. Our app server pool uses random request routing <a href="http://aphyr.com/posts/277-timelike-a-network-simulator">(yeah, we know)</a>. But an interesting side effect of random routing and a large pool of server targets is that a statistical sample of overall traffic becomes a valid representation of the whole. In other words, of our 20 servers if we only reported data to New Relic from 7, the data generated would be equally actionable.</p>

<p>New Relic provides average, median, 95th percentile, and 99th percentile values for overall browser page load time and app server response time, as well as breakdowns for frequently accessed controller methods, on the default dashboard home page. Error rate is also reported on the dashboard. On the <code>Web Transactions</code> page there are more detailed breakdowns for controller methods and on the <code>Database</code> tab there are similar breakdowns for individual database calls. All of these are calculated based on a total population of calls. As long as your throughput is high enough on the servers that are sending traffic to New Relic, these statistics will closely mirror the population as a whole. Likewise New Relic&#8217;s Apdex value is calculated based off of the overall statistics so the value should be the same for the subset as the whole.</p>

<p>So what&#8217;s the downside? If you use New Relic ppm or rpm values as indicators of capacity or throughput, you&#8217;ll need to translate the values for the subset to the population as a whole. We post metrics to an internal <a href="http://shopify.github.io/dashing/"> dashboard</a>, so in order to make our statistics match we are using two New Relic accounts, one Pro and one on the free Lite tier, and combining the values from both API calls. This gives us the advantage of being able to use New Relic Lite features for the rest of the servers, which are very robust even with their limitations. Also if you use any of the New Relic reports (SLA, Capacity, Scalability, etc) again the absolute values reported by your subset will not reflect your true throughput.</p>

<h3>Implementation</h3>

<p>New Relic uses an API Key to match data from a reporting server to an account. In our environment we use a YAML file that&#8217;s loaded during initialization. The key is, in order to set this up you need a method for a specific server to effectively determine the total server count for its type during initialization. We use <a href="http://scalr.com">Scalr</a> for managing our production environment. Their <a href="http://wiki.scalr.com/display/docs/Accessing+Environment+Variables+from+a+Server">API</a> provides SCALR_INSTANCE_INDEX, so we can use the modulo of that property to determine whether the server should register with the Pro New Relic account. We added a different app on the Lite plan and use modulo to balance between them - every third server gets the Pro key:</p>

<p><code>license_key: &lt;%= ENV["SCALR_INSTANCE_INDEX"] % 3 == 0 ? ENV["NEW_RELIC_LICENSE_KEY"] : ENV["NEW_RELIC_LITE_KEY"] %&gt;</code>
(from config/newrelic.yml in our rails app)</p>

<p>On boot, depending on the index of the server it will pick up the Pro or Lite key. We&#8217;ve set up gists for implementing on <a href="https://gist.github.com/jwrubel/7437761">Scalr</a> and <a href="https://gist.github.com/jwrubel/7437771">Heroku</a> for reference. These are Ruby/Rails-specific, but we welcome feedback on implementations in other platforms and languages. If we get any we&#8217;ll update this post. In any event this should be enough to get you started - hit up the comments if you need more guidance.</p>

<p>We realize this is gaming the New Relic system to an extent by signing up for multiple accounts at different tiers. At TTM we&#8217;re big fans of paying for software and services that we use (either through cash or contributions to OSS), and if we don&#8217;t need Pro monitoring on our entire farm it should be easier to specify only the servers we want to use for Pro. Right now it&#8217;s not, but this enhancement made it possible for us to control costs and get the same value out of New Relic regardless of how big we get.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Moving from Heroku to AWS at Think Through Math]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/11/04/moving-from-heroku-to-aws-at-think-through-math/"/>
    <updated>2013-11-04T15:41:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/11/04/moving-from-heroku-to-aws-at-think-through-math</id>
    <content type="html"><![CDATA[<p>Think Through Math launched a completely rebuilt version of our core math instruction platform in time for the 2012-2013 School Year. We launched on Heroku - it&#8217;s the platform that provides the least deployment friction and has the most developer-friendly interface for managing production environments. Almost from the beginning we were plagued by performance issues. TTM added some very large customers at the same time we launched our application, and that exacerbated the problem, but as it turns out the greatest source of our production issues were the ones that the <a href="http://news.rapgenius.com/James-somers-herokus-ugly-secret-lyrics">Rap Genius incident</a> exposed around request queuing at the router level. Once we found the issue we were able to mitigate it by switching to double dynos and dramatically increasing our dyno count, but even our best-case scenario had 500-700ms of request queuing at peak load.</p>

<p>After consideration of options we made the decision to transition away from Heroku. As a company we believe the public cloud is the right place to host our application at this stage in our growth, and for a host of reasons (some of which we will cover in future posts) we decided to use AWS vs. other cloud providers. There are many things heroku does really well with their platform; we wanted to maintain those features in our new platform as well. We made the following list of features we needed to have on AWS:</p>

<ul>
<li>Deploy with git</li>
<li>Environment variables in the same manner that heroku uses them</li>
<li>API &#8216;parity&#8217; - ideally mimic heroku&#8217;s CLI commands to reduce learning curve</li>
<li>Templatized server roles</li>
<li>Cron support</li>
<li>Rails Console and psql console through CLI</li>
<li>Centralized logging through papertrail</li>
<li>Scaling through the CLI</li>
<li>Database backups</li>
<li>Follower databases, including fast db cutovers</li>
</ul>


<p>After some research we settled on <a href="http://scalr.com">Scalr</a> as a replacement for much of the functionality we got from Heroku. Scalr provides AWS templates for our rails stack, background workers (we use <a href="http://sidekiq.org/">Sidekiq Pro</a>), and Postgres. All of our other production services we left as cloud solutions: redis, logging, and solr.</p>

<p>Scalr allows us to pick instance sizes based on our needs; after some experimentation we settled on c1.xlarge for our web and background tier. We use Unicorn for our web tier so based on the available memory and our app size we set the worker processes per server to 20. We used scalr&#8217;s Postgres 9.2 template running on m3.2xlarge with the EBS-optimized IO feature, and we tuned postgres settings based on our app parameters. One of the things we always suspected about running our app on Heroku is that our inability to tune <code>work_mem</code> and other postgres attributes was responsible for some of our performance limitations, and caused us to need larger databases overall to support our traffic. Scalr supports slave databases that are similar to heroku followers, although a bit more limited in that it&#8217;s a one-to-one ratio. If the master database runs in to problems Scalr does automatically promote the slave to master and build a new replacement slave.</p>

<p>At the routing layer we settled on ELB for load balancing with random routing to the rails servers. If we had more time we might have gone with ha_proxy, but as an education platform we have a narrow window in the summer when school&#8217;s out to launch and test significant changes like a platform switch.</p>

<p>Scalr uses &#8216;farms&#8217; which are conceptually similar to Heroku apps, and inside each farm we were able to add roles based on the templates we defined. We added two special roles; one for cron (to mimic Heroku scheduler) and one for ad-hoc remoting to mimic heroku console. Each of these roles runs a full stack of our app and the servers are updated along with the rest of the app whenever we deploy.</p>

<p>Speaking of deployments, we again wanted to follow the model that heroku uses - deploy via CLI and git. To implement this we set up separate private tracking repos for all of our farms in github. Scalr provides event hooks to their application workflow, so we configured each farm to pull from its equivalent repo when it receives a deploy command. One thing we don&#8217;t get with this workflow is the ability to watch the deploy process do its thing, but in our experience 90% of that process on heroku was asset compliation.</p>

<p>As a team we&#8217;ve gotten used to managing everything through the command line, so an additional goal for our team was to maintain &#8216;parity&#8217; in syntax for management of our production deployments. Scalr has a <a href="https://github.com/RedbeardTech/scalr">gem wrapper</a> for its API, but it wasn&#8217;t well maintained. So we <a href="https://github.com/thinkthroughmath/scalr">forked it</a> and added syntactic sugar to match the heroku API. So where we previously could list our environment variables with heroku config -a <code>APP_NAME</code> we now use ttmscalr config -f <code>FARM_NAME</code>. To build out the API we implemented <code>deploy</code>, <code>rails c</code>, <code>psql</code>, <code>restart</code>, and <code>maintenance</code>, along with some commands we couldn&#8217;t use under heroku like <code>ssh</code> and <code>scp</code>.</p>

<p>The results we&#8217;ve seen from the cutover are pretty dramatic. According to New Relic our App Server average response is now below 200ms even at usage levels that are 40% over last year&#8217;s peak. On heroku even at our most stable we were seeing 500-700ms of request queuing on our best days. We can&#8217;t say with certainty why things are so much better. We are using larger rails servers with higher workers per server, so the impacts of random routing are minimized. We also suspect that Postgres tuning makes a big difference. Beyond that we don&#8217;t have good answers, but with performance now stable we&#8217;re able to refocus attention on functionality, so we haven&#8217;t spent a lot of time investigating.</p>

<p>One thing we did not see was a lot of cost savings from the switch from Heroku to Amazon. Costs are much lower on a server-to-server basis, but factoring in support costs, the fact that we now pay for dedicated slave databases, and now we pay for things like backups, storage and data transfer, our overall hosting cost is roughly the same. The big win here for us was stability and response time. Those benefits alone made the cutover worthwhile.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Meet the Team: Mario Signore]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/07/21/meet-the-team-mario-signore/"/>
    <updated>2013-07-21T02:42:00-04:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/07/21/meet-the-team-mario-signore</id>
    <content type="html"><![CDATA[<p>Hey y&#8217;all, I&#8217;m Mario Signore, a quality assurance guy at Think Through Math. This has been my first job in the technology field since graduating college, and I couldn&#8217;t imagine a better place to start. It is such a privilege to work with people who are passionate about education!</p>

<p>When not working I am usually playing baseball. Growing up, everyone would make fun of baseball for being an &#8216;easy sport&#8217;. Football players would say that it wasn&#8217;t physical enough. Basketball and Soccer players would say that they ran more in one practice than baseball players do all year. Determined to prove to everyone that baseball was the hardest sport, I turned to math.</p>

<p>The pitcher stands 60.5 feet away from the batter. Lets say the average Major League pitcher pitches around 90 miles per hour.</p>

<p>1 mile = 5280 feet and 90 miles = 475,200 feet, so the pitcher pitches 475,200 feet per hour.</p>

<p>1 hour = 3600 seconds, so the pitcher pitches 475,200 feet per 3600 seconds.</p>

<p>475,200 divided by 3600 = 132 feet per second.</p>

<p>So at this point, the ball is coming at the batter at a rate of 132 feet per second. However, the pitcher is only 60.5 feet away. 60.5 feet / 132 feet per second = 0.46 seconds. That means that the batter has ~0.46 seconds to hit the baseball, which is pretty fast. That&#8217;s why baseball players whose batting averages are .350 (35%) get paid millions of dollars to fail 65% of the time!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Meet the Team: Carol Nichols]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/03/28/meet-the-team-carol-nichols/"/>
    <updated>2013-03-28T19:34:00-04:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/03/28/meet-the-team-carol-nichols</id>
    <content type="html"><![CDATA[<p>Hi, I&#8217;m Carol Nichols, Software Architect and Hammer of Justice at Think
Through Math! Since I started in October 2012, I&#8217;ve worked on projects such as
sharding our database and integrating with <a href="http://getclever.com">Clever</a>. I
love my job and getting to work with an incredible team to make software that
helps kids learn math!</p>

<p>To introduce ourselves, Jim has suggested that each of us post a bit about how
we use math in our everyday lives. After a day of working in the virtual world
of software, I enjoy going home and working on the concrete, physical aspects
of my house. I try to do a lot of repairs and improvements myself, &#8220;try&#8221; being
the important word!</p>

<p>I especially enjoy building my own furniture. I get to make exactly what I
need, and if I use solid wood, it&#8217;s usually better quality and lasts longer.
But making furniture does take time and thought.</p>

<p><a href="http://devblog.thinkthroughmath.com/uploads/math-fail.jpg"><img src="http://devblog.thinkthroughmath.com/uploads/math-fail.jpg" alt="My shelf without sides and the piece of wood that I cut too short" width="235" style="float:right; margin-left: 10px;" /></a></p>

<p>You may have heard the saying &#8220;Measure twice, cut once&#8221;, meaning you should
spend more time checking your measurements that are easy to change before
cutting your materials since you can&#8217;t undo a cut. In my house, the saying is
&#8220;Calculate three times, measure twice, cut once&#8221;! I have done some math in my
head to figure out how big a piece of wood needed to be, checked my math (but
made the same mistake when checking), measured twice, cut once, and then found
out that my math was incorrect. This shelf in my house still doesn&#8217;t have sides
on it; I haven&#8217;t gone to get a replacement for the wood that I cut too short
yet.</p>

<p>Since that incident, I check my assumptions and calculations with a friend and
I use a calculator to make sure my mental math was right. Getting the math
right helps me to buy exactly the amount of materials I need and saves me from
making multiple trips to the hardware store. Math is important!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Introducing status_site: a starting point for a status. subdomain]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/03/04/introducing-status-site-a-starting-point-for-a-status-subdomain/"/>
    <updated>2013-03-04T13:28:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/03/04/introducing-status-site-a-starting-point-for-a-status-subdomain</id>
    <content type="html"><![CDATA[<p><strong>Summary:</strong> Many high-traffic web apps use an http://status.* site to communicate platform availability notices. We found ourselves needing this so we built it. We think this is a general need so we open-sourced ours at <a href="http://github.com/thinkthroughmath/status_site/">http://github.com/thinkthroughmath/status_site/</a>.</p>

<p>There&#8217;s a lot that goes in to running a high-traffic, production web app, especially one that grows quickly. Over the past several months we&#8217;ve found ourselves needing to schedule small amounts of downtime to run migrations, scripts, reorganize, and denormalize data. We generally schedule these off-hours since our traffic slows significantly outside of school hours, but we want to provide a mechanism to notify interested customers about downtime or issues without spamming our entire population over email, or using in-app messaging.</p>

<p>We did a survey of big-name companies and how they were handling this issue. Most commonly we saw combinations of a custom web app and twitter feed that was specifically dedicated to platform status. We searched for an existing repo to use as a base and we didn&#8217;t find anything, so we built a version that tries to use the best practices of other status sites. Because contributing to OSS is important to us we&#8217;ve open-sourced our baseline at <a href="http://github.com/thinkthroughmath/status_site/">http://github.com/thinkthroughmath/status_site/</a>. The initial version allows for an admin login that can CRUD a new issue (meaning there is a problem with system performance or there is an outage), CRUD a new maintenance event (for planned downtime), and display system metrics from New Relic if applicable. status_site supports subscriptions via email and RSS to Issues and Maintenance updates. Lastly status_site provides a javascript snippet that you can embed on your main app that will automatically display upcoming planned maintenance events.</p>

<p>Other things we&#8217;ve thought would be cool to add:
* twitter integration
* timeline visualization
* automatic calculation of uptime based on outages
* tie issue creation to New Relic alerts</p>

<p>What do you think should be added? Feel free to drop an issue in the repo or fork it and issue a pull request. Get involved, and let us know how you decide to use it!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Managing request queuing with Rails on Heroku]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/02/27/managing-request-queuing-with-rails-on-heroku/"/>
    <updated>2013-02-27T17:54:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/02/27/managing-request-queuing-with-rails-on-heroku</id>
    <content type="html"><![CDATA[<p><strong>Summary</strong>: Heroku&#8217;s random routing algorithm causes significant problems with high-traffic, single-threaded Rails apps. This post describes how we&#8217;ve configured our Unicorn dynos to reduce the impact of the router. We set the unicorn backlog to extremely low values to force the router to retry requests until it gets a dyno that&#8217;s not loaded. The post also presents a wishlist for Heroku of things that would help futher address the problem.</p>

<p>At Think Through Math, we run an e-learning platform designed to help students become successful at math. We&#8217;re running a Rails stack and hosted on Heroku. Over the past six months, our usage skyrocketed thanks to a string of big customer wins and a compelling solution. As our usage grew, performance started to suffer for reasons we couldn&#8217;t explain. We monitor our application with New Relic. What it showed us was a fairly flat app server response time, but as usage grew during the day, the end user response time grew dramatically. All of the growth was in the graph section marked <em>network</em>. We also saw waves of dyno restarts along with H12 timeouts.</p>

<p>At the end of every browser using our application is a math student. Many of them have struggled with math for years. They&#8217;re conditioned to think they are bad at it; that math is too hard for them. When our app is slow or times out that&#8217;s just another reason for the student to lose confidence. So we took these performance issues very seriously, and we felt powerless to stop them since we couldn&#8217;t figure out the cause of the elevated response times.</p>

<p><a href="http://rapgenius.com/James-somers-herokus-ugly-secret-lyrics">This post</a> from Rap Genius illustrated the problem we were seeing. <a href="http://aphyr.com/posts/278-timelike-2-everything-fails-all-the-time">This post on Timelike</a> covers the same topic, but goes in depth on the math behind routing algorithm efficiencies. Math always gets to us. Heroku has created a <a href="https://blog.heroku.com/archives/2013/2/27/unicorn_rails">blog post</a> recommending Unicorn as a way to minimize the inefficiency in random routing. For high traffic apps, the default configuration they provide won&#8217;t have much impact since dynos are severely memory-limited. Each dyno can ony run a small number of worker processes, so they are still at risk of taking on more requests than they can handle in a reasonable fashion, and the default Unicorn settings are not optimal as a solution to request queuing.</p>

<p>Over the course of a couple of months of research, tweaking, and performance monitoring, we&#8217;ve finally gotten a handle on our request queuing in Heroku. It&#8217;s not eliminated, and it probably won&#8217;t be as long as we are using a single-threaded Ruby implementation. However, we have been able to minimize our end user response time and virtually eliminate H12s, even at peak throughput, with some specific Unicorn configuration settings. We&#8217;re writing this post not to attack or defend Heroku&#8217;s routing implementation. Our goal is to describe our strategy to minimize request queuing, developed with invaluable guidance and research from <a href="http://www.unicon.net">Unicon</a>:</p>

<h3>Get visibility into your request queue depth</h3>

<p>If you use New Relic (and you definitely should if you are running a high-traffic app), grab their latest gem (since the issue in this post primarily affects Rails, we&#8217;ll link directly to the relevant information). Once you have this gem fielded you will see the impact of request queuing on your app. For us, the picture was pretty grim.</p>

<p><img src="http://ttm-public.thinkthroughmath.com/static/new_relic_before.png"></p>

<p><img src="http://ttm-public.thinkthroughmath.com/static/new_relic_after.png"></p>

<h3>Do the dirty work of query optimization.</h3>

<p>Start by optimizing long-running queries, per Heroku recommendation. This topic is worth a blog post itself (so we <a href="http://devblog.thinkthroughmath.com/blog/2013/02/27/optimizing-long-running-queries-with-new-relic/">wrote one</a>).</p>

<h3>Dramatically reduce the Unicorn backlog.</h3>

<p>The default backlog for Unicorn is 1024. With a queue depth that high there&#8217;s no penalty for a random router algorithm in sending traffic to an overloaded dyno. We&#8217;re currently set at <del>6 and might still go lower</del> 16 since Unicorn uses Linux sockets and will round up any number below 16 to 16. According to <a href="https://devcenter.heroku.com/articles/error-codes#h21-backend-connection-refused">Heroku documentation</a>, if the router sends a request to a dyno with a full backlog, it will retry the request. The retry will also be random, but with an extremely short backlog setting it&#8217;s more likely that the request will end up in a short queue. There will be some overhead in the retry (and that&#8217;s not shown anywhere, even in New Relic, at the moment), but our experience has been that request queuing ends up being 2-3x more time on the server than processing time, so a little retrying shouldn&#8217;t make things worse overall. Warning though - after 10 attempts, if the router hasn&#8217;t been able to find a free dyno it will give up and throw an H21 error. You can see if this is happening using whatever log drain add-on you have set up in Heroku. It will take some experimentation, but the goal here is to set the backlog low enough that you minimize queuing time, but not so low that you throw H21s.</p>

<p>Changing the Unicorn backlog setting for Heroku is similar to what is needed for setting <a href="https://github.com/defunkt/unicorn/blob/master/examples/unicorn.conf.rb#L28">Unicorn up with Nginx</a>. In <code>./config/unicorn.rb</code> you will want to create a listen command with the port and then specify the backlog number:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">listen</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;PORT&#39;</span><span class="o">]</span><span class="p">,</span> <span class="ss">:backlog</span> <span class="o">=&gt;</span> <span class="mi">200</span>
</span></code></pre></td></tr></table></div></figure>


<p>The above example will change the backlog to 200 thus rerouting a request if the queue is full. Instead of a socket or even a specified port though, you will need to pull from the Heroku <code>PORT</code> environment variable. You may want to adjust this setting in a staging, sandbox or production environment so we highly recommend that you make a second ENV parameter for the backlog amount and a default:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">listen</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;PORT&#39;</span><span class="o">]</span><span class="p">,</span> <span class="ss">:backlog</span> <span class="o">=&gt;</span> <span class="nb">Integer</span><span class="p">(</span><span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;UNICORN_BACKLOG&#39;</span><span class="o">]</span> <span class="o">||</span> <span class="mi">200</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>


<p>That way you can alter the backlog via a <code>heroku config</code> command rather than doing a deploy.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">heroku</span> <span class="ss">config</span><span class="p">:</span><span class="n">set</span> <span class="no">UNICORN_BACKLOG</span><span class="o">=</span><span class="mi">16</span> <span class="o">-</span><span class="n">a</span> <span class="o">&lt;</span><span class="n">app</span> <span class="nb">name</span><span class="o">&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>This has the added benefit of not relying on the Rails environment name for configuration should you be running more than the standard &#8220;development&#8221;, &#8220;test&#8221; and &#8220;production&#8221; environments.</p>

<h3>What else we would do</h3>

<p>Despite all of our optimizations we still see a fair bit of request queuing. Part of this definitely stems from the single-threaded nature of the stack we have chosen. We&#8217;ve started research on switching to a multi-threaded Ruby stack. In the short term there are some ways we could think of for Heroku to reduce this problem.</p>

<p>From following the conversations on the web, we understand the challenge in implementing and managing an &#8216;intelligent&#8217; routing mesh at the scale Heroku is working with. One option would be to segment high-traffic apps onto a separate mesh; one that could reasonably use a routing algorithm such as least-connections. That would have cost and significant engineering effort, no doubt. We imagine it would need to be part of a package specifically aimed at Heroku&#8217;s higher-end tier of customers.</p>

<p>An alternative that would seem to be a lower-effort solution would be to offer a dyno with increased memory; 1024MB, 2048, or even 4096. With a 4GB dyno we could run 16 workers per dyno. Since Unicorn&#8217;s master process manages queuing once the request is on the dyno, this would likely be dramatically more efficient overall. We would gladly pay 8x per dyno-hour for a 4GB dyno vs 8 512MB dynos, since we would need far fewer of them overall, and our performance would improve at the same overall infrastructure footprint. Everything else about the dyno model could stay the same.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Optimizing long-running queries with New Relic]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/02/27/optimizing-long-running-queries-with-new-relic/"/>
    <updated>2013-02-27T08:33:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/02/27/optimizing-long-running-queries-with-new-relic</id>
    <content type="html"><![CDATA[<p><strong>Summary</strong>: For single-threaded Rails web apps, a good strategy to improve concurrency is to ensure a low and consistent transaction time across all of your controller actions. <a href="http://newrelic.com">New Relic</a> provides excellent tools for identifying and prioritizing the worst offenders.</p>

<p>At Think Through Math, we&#8217;re always happy when we can use math to solve a real-world problem. When it comes to modeling operational efficiency in Rails, math once again provides a great framework. Many Rails apps are single-threaded; as of the time of this writing ours is no different. Let&#8217;s assume that the average controller method in our app takes 250ms. That means in a perfectly ordered environment we can process four requests per second, per web server queue. We&#8217;re hosted on <a href="http://heroku.com">Heroku</a>, using the <a href="http://unicorn.bogomips.org/">Unicorn Web server</a> with four worker processes per dyno. Since each worker is its own queue, we can process on average 16 requests per-second-per-dyno, or 960 requests per minute. To generalize this we can write an equation: <code>(1000 / avg_response_time) * queues_per_dyno * 60 = dyno_throughput</code>.</p>

<p>This is where New Relic comes in. New Relic will always show you your average app server response time, both real-time and as a graph over the time range you have selected.</p>

<p><img src="http://ttm-public.thinkthroughmath.com/static/nr_web_transactions.png"></p>

<p><img src="http://ttm-public.thinkthroughmath.com/static/filter_sort_transactions.png"></p>

<p>To start using New Relic to optimize queries, click the <em>Web transactions</em> tab under <em>Monitoring</em>. Click <em>App server</em> if it isn&#8217;t already selected, then sort by <em>Slowest average response time</em>. This will give you a list of controller methods, sorted by highest average tranaction time. <a href="https://devcenter.heroku.com/articles/background-jobs-queueing">Heroku&#8217;s recommendation</a> is that all transactions have an average response time below 500ms, so that&#8217;s a good place to start. What we do is make the time window reflect at least three hours of peak usage, then export the list as CSV (there&#8217;s an option in New Relic). We then look at the combination of average response time, max response time, std deviation, and call count to prioritize our efforts.</p>

<p>Implementing the refactor to reduce the average is going to be specific to your application, but we generally end up with one of four different strategies:</p>

<ul>
<li>Use the transaction tracing features in New Relic to identify the slowest parts of the transaction and optimize that code</li>
<li>Database optimization; add indexes, denormalize, add counter caches</li>
<li>Switch elements of the page to use an ajax callback strategy</li>
<li>If it&#8217;s not time-sensitive, move the transaction to a background job (we use and love the awesome <a href="https://github.com/mperham/sidekiq">sidekiq</a> for this)</li>
</ul>


<p>We typically dedicate a portion of development effort each iteration to this activity. Rather than assign it to a specific developer we like to do optimization parties - divvy the list up and have people pair on solutions. It gives people a chance to work on parts of the code they don&#8217;tnormally interact with, and it&#8217;s an excellent way to add technical breadth to the team.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Development and Triathlons—More in Common than You Think]]></title>
    <link href="http://devblog.thinkthroughmath.com/blog/2013/02/15/development-and-triathlons/"/>
    <updated>2013-02-15T14:08:00-05:00</updated>
    <id>http://devblog.thinkthroughmath.com/blog/2013/02/15/development-and-triathlons</id>
    <content type="html"><![CDATA[<p><em>This was originally posted as <a href="http://blog.bignerdranch.com/1331-development-and-triathlons-more-in-common-than-you-think/">a guest article on Big Nerd Ranch&#8217;s blog</a>; reposted here with permission. We &lt;3 Big Nerd Ranch!</em></p>

<p>My name is Jim Wrubel - I&#8217;m the Chief Technical Officer at Think Through Math, one of <a href="">Big Nerd Ranch</a>&#8217;s clients. In my spare time (such as it is) I&#8217;m a long-course triathlete and marathoner. Recently we partnered with Big Nerd Ranch to rebuild our core e-learning platform. During the process I realized that there are a lot of similarities between training for an endurance event like triathlon and launching a major web initiative.</p>

<h3>The work you put in during the build determines your success in the event.</h3>

<p>If you haven&#8217;t put in the time, no amount of last-minute workouts or coding will make up for it. This is something developers know instinctively - unfortunately it&#8217;s not common knowledge among managers. Also, in product launches and major races, you usually have a specific date that is set in stone. But if you haven&#8217;t done the work in the months leading up to the event, be prepared for a rough day. Coincidentally, training for an Ironman and developing a significant web app both take about the same amount of effort and calendar days. If you can do one, you can do the other.</p>

<h3>Repetition is the key to success.</h3>

<p>In training and development, having a routine is critical. Plot your development iteration schedule - one week, two weeks, a month - and stick to it. Your workout schedule should also be iterative. I tend to follow a three-week build followed by one week of recovery. Even inside of an iteration, build routines and stick to them. Run the test suite (you <em>do</em> have a test suite, don&#8217;t you?) and make sure it passes before you push code. Try to schedule the same workouts at the same time each week. It makes it easier to plan around your life.</p>

<h3>It&#8217;s easier with a partner or a group.</h3>

<p>An Ironman bike leg is 112 miles. The only way to be ready to ride that distance in a race is to ride that distance in training. I am fortunate to have a great friend who is right around my cycling ability level. Without someone like that to keep you honest it&#8217;s too easy to look at a six-hour planned bike ride and decide that it&#8217;s too windy, or too hot, or it might rain. The same is true in application development. Having another developer on the project who can help internalize the business requirements, offer suggestions and code reviews, and serve as a sounding board is invaluable. If you haven&#8217;t already discovered the benefits of pair programming, it&#8217;s worth reading up on the <a href="http://highgroove.com/articles/2012/07/03/learning-through-collaboration.html">subject</a>. It also helps to be part of a group. At several times during our project, our lead developers at Big Nerd Ranch were able to solicit advice from the group that turned up an elegant solution that we hadn&#8217;t thought of previously. I get the same kind of support in endurance athletics from my local club, the <a href="http://www.pittsburghtriathlonclub.com">Pittsburgh Triathlon Club</a>.</p>

<h3>Take the long view</h3>

<p>Not every day will be as productive as you want it to be - in workouts or in code. It takes months to build an exceptional application and it takes months to train for an Ironman. Chances are you will get sick during this time. Or have a family emergency. Or any of a thousand things that could distract you from your goal. Make sure you plan for them and don&#8217;t get discouraged when they hit - because they will.</p>

<h3>Climbs are never good for your heart rate.</h3>

<p>Whether it&#8217;s average page response time for a web app or elevation gain for a cycling course, it&#8217;s the spikes that get you. Graphs of each metric are helpful in showing where the problem spots are. Rely on data you have gathered to help you make decisions. Both developers and endurance athletes tend to be data junkies, for good reason.</p>

<p><img src="https://www.evernote.com/shard/s3/sh/3d87912e-0445-46d0-a403-e0c2f6fdc0ab/b63d6fb9a8351201220d1a7a820a0bd5/res/3a353e23-6ed3-445b-a746-8aac3e854c74/skitch.png?resizeSmall&amp;width=832" title="App server response times are better when they are flat" alt="App server response time" /></p>

<p><img src="https://www.evernote.com/shard/s3/sh/9a131e81-f952-40df-885b-e5c8bc2477f5/e94162d62ed7a6e503e68062d0f1e57d/res/c8d796cb-3789-4af0-b365-0fc3403a03b7/skitch.png?resizeSmall&amp;width=832" title="So are triathlon bike courses" alt="Savageman bike course elevation chart" /></p>

<h3>Summary</h3>

<p>Great developers - architects and big thinkers - are hard to find, but if you hire only the best you will be <a href="http://en.wikipedia.org/wiki/The_Mythical_Man-Month">far better off</a> than if you settle. If you are interviewing a candidate and find out they&#8217;re a triathlete, give &#8216;em a deeper look. A lot of the things they do for fun might make them a good fit.</p>
]]></content>
  </entry>
  
</feed>
