<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marty Weiner on Medium]]></title>
        <description><![CDATA[Stories by Marty Weiner on Medium]]></description>
        <link>https://medium.com/@martyweiner?source=rss-190017857b3c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jyxegpi3QjReq8pe3aKzyA.png</url>
            <title>Stories by Marty Weiner on Medium</title>
            <link>https://medium.com/@martyweiner?source=rss-190017857b3c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:18:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@martyweiner/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What Good Metrics Look Like]]></title>
            <link>https://medium.com/@martyweiner/what-good-metrics-look-like-3d075a96b026?source=rss-190017857b3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d075a96b026</guid>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[engineering-culture]]></category>
            <category><![CDATA[okr]]></category>
            <category><![CDATA[metrics]]></category>
            <dc:creator><![CDATA[Marty Weiner]]></dc:creator>
            <pubDate>Mon, 05 Jun 2017 01:13:51 GMT</pubDate>
            <atom:updated>2017-06-05T01:19:18.181Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s assume you’re knee deep figuring out goals for your company / team. You have a goal in mind — it’s to grow your user base, or become a sustainable business (e.g., make some cash), or reduce negative experiences due to spam, or conquer the galaxy. Great. But now you have the challenge of figuring out a good metric to know if your goal is met, and that’s just what this article is intended to help you with. Unless you’ve formulated metrics a million times, I’ll bet millions of microdollars your first stab at it will need some improvement. The goal this blog is to step up your beginner or intermediate game.</p><p><strong>First, about OKRs</strong></p><p>For the purposes of this blog, we’re going to use OKRs to describe our objectives and their success criteria. If you’re very familiar with OKRs, skip to the next section.</p><p>OKRs were created at Intel and evangelized by John Doerr in the late 90’s. They consist of two parts: <strong>O</strong>bjective and <strong>K</strong>ey <strong>R</strong>esult. An Objective is what you are trying to accomplish in subjective English. For instance, “Reduce the number of negative experiences due to spam”. The Key Result is the <em>measurable</em> success criteria that tells you if you’ve made good progress toward your objective: “Decrease spam reports by 30% by end of quarter measured over the last 14 days.”</p><p>OKRs cascade, meaning that OKRs can have supporting OKRs, which in turn have supporting OKRs, and on and on. Any one group at the company can have multiple objectives and multiple Key Results per Objective. A good rule of thumb is a team should have no more than 3 top line key results (more than becomes hard to remember).</p><p>I know this is a lot, so let’s dig into an example. Do you remember that scene from Return of the Jedi where Darth Vader arrives in his shuttle, walks off, and up to an Imperial Officer who looks like he’s going to pee in his pants.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzkfCU6g6_Jrn1gd2vRYoA.jpeg" /><figcaption>The look of man whose boss is digging into his OKR progress</figcaption></figure><p>The look of man whose boss is digging into his OKR progress</p><p>The officer tells Vader that the Death Star will be ready as planned. Vader tells him the emperor is displeased and is coming here. After peeing in his pants, the imperial officer tells Vader they will double their efforts.</p><p>What just happened? They just had a discussion about OKRs, and it wasn’t good. Normally in business the threat of missing a goal does not involve force lighting to the face, but the general structure of the conversation is the same. The officer has an objective to deliver a completed Death Star with at least one metric of rate of work completed. While not discussed in the movie, I’m guessing Vader had his own objective of destroying the rebels, perhaps with a key result of number of planets destroyed over the next quarter to increase 50% (from 2 to 3). Completion of the Death Star on schedule is in support of blowing up more planets. And so the OKRs cascade:</p><pre><strong>Objective:</strong> Destroy the Rebels<br><strong>Key Result:</strong> Blow up 50% more planets in Q2 (from 2-&gt; 3)</pre><pre><strong>Objective:</strong> Finish the Death Star<br><strong>Key Result:</strong> Increase engineering effort by 100% by EOQ<br><strong>Key Result:</strong> Decrease cost of Death Star parts by 50% by EOQ</pre><p>In a consumer web company, this might look like this (only objectives shown):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uRxPSq8AIjmm33rPshGK-A.png" /></figure><h4>The Key Result Recipe</h4><p>A KR has several ingredients. Make sure you have all of the following parts articulated clearly when communicating OKRs:</p><ol><li>What is being improved, by how much, and how it is measured</li><li>The time frame the measurement is over</li><li>The time frame for delivery of the KR</li><li>Status — where the measurement was, where it is, where it’s projected to arrive with the current course</li></ol><p>For example:</p><pre><strong>Objective:</strong> Finish the Death Star<br><strong>Key Result:</strong> Increase engineering effort by 100% by EOQ (from 75 units per week to 150 units per week).<br>  - Engineering effort is measured as number of units of Death Star <br>    created in the last 7 days<br>  - Currently we’re at 90 units per week on track to hit 152 units <br>    per week by EOQ</pre><p>Once you have all these elements, you have the basics down. Now you gotta make sure it’s a good KR…</p><h4>So What Makes A Good KR?</h4><p>A good KR will meaningfully tell you how you’re progressing toward your Objective. To be effective, you must be able to measure it and you must be able to make changes that affect it. It should also rally and excite your troops.</p><p>I wanted to come up with a good way to help remember all this, like maybe an acronym. But I hate acronyms. And with that in mind, here’s an acronym.</p><p>A good KR should be…</p><blockquote><a href="http://I%20didn%27t%20actually%20want%20this%20to%20be%20a%20link...%20I%20just%20wanted%20to%20be%20able%20to%20underline."><strong>M</strong></a><strong>eaningful: </strong>Does this KR actually+significantly help the objective?<a href="http://I%20didn%27t%20actually%20want%20this%20to%20be%20a%20link...%20I%20just%20wanted%20to%20be%20able%20to%20underline."><strong>M</strong></a><strong>otivational: </strong>Does this get people excited?<br><a href="http://I%20didn%27t%20actually%20want%20this%20to%20be%20a%20link...%20I%20just%20wanted%20to%20be%20able%20to%20underline."><strong>M</strong></a><strong>easurable: </strong>Can you measure your KR?<br><a href="http://I%20didn%27t%20actually%20want%20this%20to%20be%20a%20link...%20I%20just%20wanted%20to%20be%20able%20to%20underline."><strong>O</strong></a><strong>perational: </strong>Can you effect timely and meaningful change in your KR?</blockquote><p>For any sufficiently interesting problem, you’ll be thinking and re-thinking which is the best key result for the rest of time. Think of this acryonym as a strategy you can use to make more effective tradeoffs between metrics you’re considering.</p><p>Let’s walk through these with an example from when I led the spam fight at Pinterest. If your company has an anti-spam team, a good objective is “Provide a spam free experience for users”. Two possible key result templates are “Reduce number of spam reports” and “Reduce number of times a user sees spam”. We’ll apply the MMMO acronym and then I’ll tell you which I chose at Pinterest:</p><h4>Reduce number of spam reports</h4><p><strong>Is this meaningful?</strong> Yes and no. Spam reports are created by users who see spam and are aware enough to understand it is spam and take the time to report it. This can be a great indicator of a big attack, but it requires your untrained users to feed you info and good spammers won’t be reported as they’ll hide effectively. In terms of meaningful, I’d give this a B that dips to a D- as you get good at fighting spam.</p><p><strong>Is this metric motivational?</strong> In early stages of companies that are not good at spam fighting yet, this is very motivational. A big spam attack comes in, let’s fight it! If you are effective, you see the reports nose dive. At later stages, if the report quality dips, which it will, the motivational quality will wane.</p><p><strong>Is this metric measurable?</strong> Hell yes. Graph the number of reports. Done.</p><p><strong>Is this metric operational?</strong> Also hell yes. Reports are coming in every second. If you ship a change, you can see the effect immediately.</p><h4>Reduce number of times a user sees spam</h4><p><strong>Is this meaningful?</strong> Yes. Your objective — what you really care about — is that your users have a good experience free from spam. Even if there’s a lot of spam everywhere, if your users don’t interact with it, you’ve won.</p><p><strong>Is this metric motivational?</strong> Yes. Knowing that your users are truly not seeing spam is awesome. Knowing that spammers are losing money and you are winning — even more awesome.</p><p><strong>Is this metric measurable? </strong>It can be, but it turns out it’s rather difficult. If I knew a user is seeing spam, I would just delete the spam. So instead, I have to determine after the fact what was spammy and re-measure. As we got better at fighting spam, we could say that we are able to label 99% of spammers within 24 hours. Using that information, we can now say with 99% confidence how many users saw spam 24 hours ago. Getting to this stage required a lot of work on the operations side, but made Pinterest both able to understand the true impact of spam and effectively fight spam.</p><p><strong>Is this metric operational?</strong> Less operational than reports, but not bad. You don’t know for sure how you’re doing for another 24 hours since it took 24 hours for us to reach 99% confidence. That’s not bad, though. But, for up to the second situational awareness of attacks, we continued to monitor spam reports for new attacks and the efficacy of our defenses.</p><p>To the question of which of these we chose at Pinterest, we had each at different stages. The reports metric was useful in the beginning until we were sufficiently good at fighting spam that we no longer had report spikes and the remaining data was too noisy. Eventually, as we got good at identifying most spam within 24 hours, we were able to shift to users who viewed spam and also users who clicked on spam, which was also a useful metric to our objective providing a spam free experience.</p><h3>What is the goal line?</h3><p>If this is your first time implementing OKRs in your company or group, this is a good time to get clear on what the goal lines is. For instance, two common options are:</p><ol><li>You set goals that you meet, and you should meet them</li><li>You set goals that are a stretch, and you should strive to meet them</li></ol><p>Why do this? If you don’t, different people naturally assume <strong>1</strong> or <strong>2</strong>, depending on what they’re used to. At Amazon, <strong>1</strong> is how they operate. At Pinterest, it’s <strong>2</strong>. By clarifying up front, you will fix a communication issue that’s waiting to cause confusion.</p><p>This is also a good time to set expectations with your managers and engineers on what happens if they meet or don’t meet their goals. This will have a profound impact on the kind of culture that evolves, so choose wisely.</p><h4>A Note on How Metrics Evolve</h4><p>A young company typically has “shippable key results” meaning that the key result is to ship a product or service. This is because the management reporting isn’t in place, the data collection and analysis systems often aren’t built, nor are the product strategies clearly articulated. There’s really no good way to measure your key result or set a goal line. You’re an even farther cry from being able to model what effects new products will have once you ship them. So we run on intuition that if we ship a product, things will be better.</p><p>But, as the group matures, the key results can and should stop being projects shipped (those are now supporting the key result) and now become a clearly defined numerical business value add. For example:</p><p><strong>Early</strong></p><pre>Objective: The site is always up and running<br>Key Result: Migrate to bigger database servers</pre><p><strong>Mature</strong></p><pre>Objective: The site is always up and running<br>Key Result: API availability is 99.9% over the last 30 days</pre><p>Having bigger database servers is not the value added to the business. But, increased availability is. And the latter is what you should strive toward. This is what good looks like.</p><p>Eventually you will reach “great” metrics. You will be able to set your goal line with very strong confidence because you have a rigorous understanding of what affects your key results and by how much. For instance, you may know that if you ship a certain product on a certain date, based on comps from other companies and what you know from past experiences, combined with layers of modeling, you should be able to increase your revenue by 13.2% with a narrow confidence interval. This is very hard to get to, but what you want to strive for.</p><p>Metric based KRs become more critical with organization size. In any organization, the leaf nodes in organization are the engineers who are always working to ship something. They most often do not need to understand higher levels of the chart (though visibility never hurts). They should understand the OKRs affecting them more directly, but most importantly they need to ship products. The higher levels of the org are shipping less or nothing at all. They are planning and strategizing and making sure things run smoothly. At those levels, managers and architects should be thinking about what business value needs to be added and how to measure it, hence why it’s critical they build proper objectives and key results to measure if their portion of the org is delivering the required business value.</p><h4><strong>Pitfalls</strong></h4><p><strong>Analysis Paralysis</strong> — OKRs are a tool for helping point your efforts and push hard. But remember that in most cases, executing and learning is more important than having the perfect OKR. In fact, you probably never have the perfect OKR. If you’re finding it hard to land on one, either look higher at your mission or what’s really important to the org, or just choose one. You can always evolve it. And that leads to my next point.</p><p><strong>The Metrics are Not The Manager </strong>— <em>You</em> are the manager. Don’t be so rigid against OKRs that you refuse to change them in the face of new data.</p><p><strong>Sandbagging and Over-Stretching </strong>— One of the hardest challenges you’ll face is coming up with good targets that stretch while not overstretching your team. Goals that are too lofty can burn out a team or demoralize if it becomes clear the goal is basically unattainable. A sandbagged goal will be a missed opportunity. As you get better at modeling, you’ll be able to thread this needle more scientifically. In the beginning, you’re better off making a good educated guess. And to that point…</p><p><strong>Don’t not have a metric</strong> — The first time you create a metric will be difficult and uncomfortable. The metric you choose might not quite feel right, but it may be the best you have at the time while you’re learning. It’s almost always better to have a metric to start with even if it’s not perfect as it will get the metrics cogs turning (measuring, checking in regularly, communication, etc). You’ll find that very quickly the act of implementing and communicating the metric will reveal a better metric that you can swap to (See “<strong>The Metrics are Not The Manager</strong>” from 10 seconds ago).</p><h4>Final Word</h4><p>Remember that good metrics should motivate the team to stretch themselves — to reach a little further than they imagined was possible. And when they do, and they feel so very proud of all their hard work, remember to celebrate their great accomplishment.</p><p>And if they don’t hit their goal, force lightning their ass.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d075a96b026" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technology Maturity]]></title>
            <link>https://medium.com/@martyweiner/technology-maturity-d5b57d4d1140?source=rss-190017857b3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5b57d4d1140</guid>
            <dc:creator><![CDATA[Marty Weiner]]></dc:creator>
            <pubDate>Tue, 19 May 2015 06:27:55 GMT</pubDate>
            <atom:updated>2015-05-19T06:29:23.729Z</atom:updated>
            <content:encoded><![CDATA[<h3>Technology Maturity<br>= (Blood + Sweat) / Complexity</h3><p><em>or Learn to stop using shiny new things and love MySQL</em></p><p><em>(Originally published at </em><a href="http://engineering.pinterest.com/post/116038532184/learn-to-stop-using-shiny-new-things-and-love"><em>http://engineering.pinterest.com/post/116038532184/learn-to-stop-using-shiny-new-things-and-love</em></a><em>)</em></p><p>A good portion of the startups I meet and advise want to use the newest, hottest technology to build something that’s cool, but not technologically groundbreaking. I have yet to meet a startup building a time machine, teleporter or quantum social network that would actually require some amazing new tech. They have awesome new ideas with down-to-earth technical requirements, so I kept wondering why they choose this shiny (and risky) new stuff when all they need is a good ol’ trustworthy database. I think it’s because many assume that building the latest and greatest needs the latest and greatest!</p><p>It turns out that’s only one of three bad reasons (traps) why people go for the shiny and new. Reason two is people mistakenly assume older stuff is slow, not feature rich or won’t scale. “MySQL is sluggish,” they say. “Java is slow,” I’ve heard. “Python won’t scale,” they claim. None of it’s true.</p><p>The third reason people go for shiny is because older tech isn’t advertised as aggressively as newer tech. The younger companies needs to differentiate from the old guard and be bolder, more passionate and promise to fulfill your wildest dreams. But most new tech sales pitches aren’t generally forthright about their <em>many</em> failure modes.</p><p>In our early days, we fell into this third trap. We had a lot of growing pains as we scaled the architecture. The most vocal and excited database companies kept coming to us saying they’d solve all of our scalability problems. But nobody told us of the virtues of MySQL, probably because MySQL just works, and people know about it.</p><p>Through the gauntlet, two of the most important lessons I learned building Pinterest were:</p><ul><li>If you’re the biggest user of a technology, your challenges will be greatly amplified. Avoid being the biggest.</li><li>No matter what technology you’re using, it will fail. Keep it simple.</li></ul><p>After about a year of fast, sleep-defying scaling at Pinterest, we had MySQL, Memcache, MongoDB, Redis, Cassandra, Membase and Elastic Search. Everything was on fire and breaking in their own special ways. We wanted to simplify and get rid of all the fancy stuff, but we also wanted something that would scale to the moon with us. It was time to start our grand re-architecture. To help guide us and our choices, we built a set of questions to apply to every different technology:</p><ul><li><em>Does the technology meet your needs?</em><br>Solidify your requirements. Do you need simple lookups, ordered lookups and/or lookup by geography? Graph walking? One technology may not be able to support all of your requirements, but it’s nice when it does.</li><li><em>How well does it scale?</em><br>Some technology is designed for massive scale and some is not. You may have to layer a little scale magic on top. With scale comes more complexity and less agility. Keep that in mind, and avoid scaling prematurely.</li><li><em>Is the cost justified?</em><br>Consider the support contract or licensing and whether or not you can get by without a support contract. If you’re an angel funded startup, ideally you’d like to spend your money on the lights and Ramen, and not on a mainframe.</li><li><em>How mature is the technology?</em><br>Maturity of a product is the most important question you can ask next to basic requirements. This is where I’ll spend the lion share of this post.</li></ul><h4>Maturity is natural</h4><p>The harder and more passionately people push on a technology, the faster they will run across bugs or performance problems, fix them and hopefully contribute fixes back for the whole community to use.</p><p>Maturity can come a hell of lot faster if the technology is simple. Getting a five line Python program to print “Hello, World” to be bug free should take 30 person-seconds, whereas a program to handle world-wide distributed banking transactions will take many person-years to mature due to the complexity that must be hammered out.</p><p>So, let’s equation-ify this. Maturity increases with blood and sweat, but comes slower with more complexity.</p><p><strong>Maturity = (Blood + Sweat) / Complexity</strong></p><p>(I really wanted to throw in some e, i, and π into the equation, but just couldn’t justify it. Yet…)</p><p>As a technology hardens, collaboration occurs, understanding gets deeper and a wealth of knowledge is built out. As the technology itself gets more stable and beautiful, documentation and simplification occur and the frontiers and boundaries are tested and widened.</p><p>You don’t want to be on the wrong end of the maturity equation. There be dragons there:</p><ul><li><em>Hiring will be more difficult</em><br>Try searching on Google for MySQL admin and Cassandra admin. Try walking out into a busy San Francisco walkway and yell out that you need a MySQL admin. You’ll find one. Hbase, unlikely.</li><li><em>You’ll find minimal community</em><br>It’s 2 a.m. and you’re getting a weird error message “48fe1a is opaque” (an actual error message I got from Membase). What the f!*k does that mean? Crap, there are there no answers anywhere on Google. Conversely, I can’t remember the last time a MySQL question I had wasn’t already answered along with somebody calling the questioner a nOObXor.</li><li><em>You’re more likely to fail, possibly catastrophically</em><br>We had an unexpected loss of data on nearly every technology we used at one time or another, except MySQL. Even on the worst days, when the hard drive crashed, we still managed to find a script somebody wrote to do magic voodoo to get our MySQL data out again and live another day. Other technologies left us dead in our tracks because nobody had encountered the same problems, or they hadn’t taken the effort to dive deep to recover their data or they hadn’t contributed the fix back to the community. Incidentally, I’m super thankful we never trusted the golden copy of our data to any other system except MySQL in those early days.</li></ul><p>Sometimes you have to be on the bad end of this maturity ratio. For instance, if you HAVE to have a Flux Capacitor for your time machine, recognize that you won’t be able to hire for it easily. There will be minimal community online to help you debug why you only went back in time 100 years and not 1,000 years. Support may not be able to help you understand why Marty McFly is now stuck in a supernova.</p><p>If you’re on the frontier, you’ll hit new bugs and issues that the rest of the world has never seen. They’ll be 10x harder to debug and will likely require a depth of knowledge that goes outside the comfort zone of your current engineers. You’ll have to dig in, push hard and learn fast. I send you my virtual hugs and admiration. I’ve been there. It will be tough. Blog what you find, collaborate and communicate.</p><p>If you’re starting or growing a company, and your scale is smaller than huge, consider maturity to be your most important factor aside from basic requirements. Ask yourself — does MySQL sufficiently meet my needs? If so, use it. If you’re wondering if MySQL will be fast enough, the answer is <em>YES</em>. Even better than fast, MySQL’s performance will be consistent.</p><h4>Last Remarks</h4><p>So I’ve wailed away on a bunch of technologies, but I seem to have a near-romantic thing for MySQL. I’d like to take a moment to mention that MySQL, while mature, does not solve all your problems. Sometimes you’ll have to venture away from the comforting warming glow of maturity.</p><ul><li><em>Cartesian Distance</em><br>If you need to search for nearby points in two dimensions, storing coordinates as<a href="http://en.wikipedia.org/wiki/Geohash"> Geohashes</a> in MySQL would work well (<a href="http://xkcd.com/426/">here’s an XKCD comic</a> to help). Three dimensions would probably also work well. But if you need large N-dimensional search spaces, I don’t know of a good way to store and retrieve them in MySQL efficiently. You might find yourself needing to store N-dimensional points if, for instance, you have created a model that produces feature vectors for some input and you want to see if two inputs are similar. Classic examples include determining if two images are similar but not exactly the same. For these sorts of situations, consider building a distributed RP/KD tree (would love to collaborate! Email me!).</li><li><em>Speed of writes</em><br>MySQL delivers full write consistency. If you’re willing to trade off “full” for “eventual” consistency, your writes can be much faster. HBase, Cassandra and other similar technologies write to an update log incredibly fast, at the expense of making reads slower (reads must now read the stored info and walk the update log). This is a nice inversion, because it’s easier to cache reads and make them fast.</li><li><em>FIFOs, such as feeds</em><br>My biggest complaint about MySQL is that it’s still living in 1994 (with baggy pants and the.. erk..<a href="https://www.youtube.com/watch?v=XiBYM6g8Tck"> Macarena</a>). Many uses of databases back then needed relational queries. There were no social networks. MySpace wouldn’t come around for another nine years! And so MySQL is built out of trees and has no good notion of queues. To insert into a B-tree is an O(lg(N)) operation (assuming happy balance). But today, social networks are a major force on the internet, and they depend heavily on queues. We want uber fast O(1) enqueuing! My suggestion is to not use MySQL for feeds. It’s too much overhead. Instead, consider<a href="http://redis.io/"> Redis</a>, especially if you’re still a small team. Redis is super fast and has lists with fast insertion and retrieval. If you’re a larger company and can hire the folks to maintain it, consider HBase. It’s working well for our feeds.</li><li><em>Logs</em><br>For the love of everything holy, <em>don’t store logs in MySQL</em>. As mentioned in the previous paragraph, MySQL stores things in trees. Logs should not live in trees (that’s a weird thing to say…). Send your logs to<a href="http://kafka.apache.org/"> Kafka</a>, then use<a href="https://github.com/pinterest/secor"> Secor</a> to read from Kafka and ship up to S3. Then go nuts with<a href="http://aws.amazon.com/elasticmapreduce/"> EMR</a>,<a href="http://qubole.com/"> Qubole</a> or your map-reduce platform du jour.</li><li><em>Scale beyond one box</em><br>If you’re in this position and you’ve optimized all queries (no joins, foreign keys, distinct, etc.), and you’re now considering using read slaves, you need to scale to beyond one MySQL server. MySQL won’t do this for you out of the box, but it’s not hard. And we have a solution, which you’ll be able to read about and learn how we did this once I finish writing the blog post. In the meantime, bug me at marty@pinterest.com, and I’ll get you up and running now.</li></ul><p>Follow my adventures on <a href="http://twitter.com/MartyWeiner">Twitter</a> and <a href="http://pinterest.com/martaaay">Pinterest</a>.<br>Email: <a href="http://marty@pinterest.com/">marty@pinterest.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5b57d4d1140" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Steps to Better Goals and Metrics]]></title>
            <link>https://medium.com/@martyweiner/4-steps-to-better-goals-and-metrics-99d58c426ef1?source=rss-190017857b3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/99d58c426ef1</guid>
            <dc:creator><![CDATA[Marty Weiner]]></dc:creator>
            <pubDate>Tue, 19 May 2015 06:16:06 GMT</pubDate>
            <atom:updated>2015-05-19T06:18:26.352Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.”</em> — Sun Tzu</p><p><em>(Originally published at </em><a href="http://engineering.pinterest.com/post/112720487359/4-steps-to-better-goals-and-metrics"><em>http://engineering.pinterest.com/post/112720487359/4-steps-to-better-goals-and-metrics</em></a><em>)</em></p><p>I’ve found over and over again that many organizations suffer from the same problem, goal setting . It’s not always clear how goals are set or how to set them. This is especially true of startups. I had to learn this process the hard way by making lots of mistakes and banging my head against walls. So you can spare your own head and a few innocent walls, I’m sharing my brain dump on formulating goals and metrics.</p><h2>Goals</h2><p>Goals are a combination of what you’re trying to accomplish in a defined amount of time and how you’re measuring progress against those accomplishments. They can be aspirational (goals your team hopes to achieve) and/or commitments (promises to others outside your team).</p><p>Goals are useful for several reasons. Here are two of my favorites:</p><ol><li>They’re great for picking your head up out of the trenches of engineering/product warfare to think hard about the direction you’re going and what you can reasonably achieve in a certain amount of time.</li><li>Goals are an effective means of gaining alignment on where you’re headed while instilling a sense of urgency.</li></ol><p>Everybody responsible for setting goals <strong><em>must</em></strong> know how goal lines are chosen (step 1) and the importance of hitting goals (step 2). In steps 3 and 4, I’ll discuss how to actually set a good goal. <em>WARNING: Skipping past the first two steps will cause you headaches, loss of appetite, thinning of the hair and occasional nausea.</em></p><h3>Step 1. Communicate how the goal line is chosen</h3><p><strong><em>Everybody</em></strong> has to know how the goal line is set in the company. The purpose is to ensure alignment about where on the football field we’re trying to run. Here are a few options to seed the discussion:</p><ol><li>Set goals that are incredible big stretches</li><li>Set goals you’re 70 percent likely to hit</li><li>Set goals you’re likely to hit</li><li>Set goals you’re easily going to hit</li></ol><p>Each option has interesting ramifications, and you should choose the one that works best for your culture. At Pinterest, we have a culture of setting goals that we can likely hit 70 percent of the time, and we push really hard to hit them. If we miss our goal, we discuss how we could improve on our strategy and/or tactics or our ability to set goals.</p><p>If it’s not clear which style the whole org uses, communication will break down, likely in subtle ways (you should read “subtle” as a curse word in this context). For example, if Alice assumes goal (2) is how the company operates and Bob is setting a goal for (3), Alice could think Bob is a <a href="http://www.investopedia.com/terms/s/sandbag.asp">sandbagging</a> *expletive*. If Alice and Bob aren’t aware they’re working on different basic assumptions, their communications will likely break down and they won’t even know it.</p><h3>Step 2. Communicate the importance of hitting a goal</h3><p>Your company needs a well communicated philosophy of how goal setting and meeting/not meeting goals is treated. A few options:</p><ol><li>You MUST hit your goal!</li><li>Strive hard to meet your goal. Big kudos if you do. Discuss what could have been better if you don’t.</li><li>Goals are just guidelines. No big deal.</li></ol><p>Again, it’s important to choose which one best matches your company culture. Even more importantly, ensure the choice is well communicated. The impact of poor communication could be that Alice assumed (1) and Bob assumed (2), and the goal wasn’t met. The result could be Alice is upset the goal wasn’t met, and Bob is confused because he feels that he did nothing wrong. Likely, Bob will be defensive , a sure sign effective communication has ceased.</p><p>So which do you choose?</p><p>Different companies and departments approach setting their goal lines differently. If you’re not sure which to choose, get the appropriate folks together, gather sentiment and<strong><em> choose one combination to start with</em></strong>.</p><p>After you’ve selected one “goal line” choice and one “importance of goals” choice, communicate it. Communicate it over and over again until it’s adopted in the DNA of the company. Communicate it at each goal meeting. Communicate it over beer. Then drink lots of beer so more communication happens.</p><p>Once you’ve had enough beer, it’s time to choose a goal.</p><h3>Step 3. Choose a goal</h3><p>Strive for a metric-driven goal, but not to the point of losing the human element. A great way to define goals is with OKRs. If you’re already familiar with OKRs, skip the next paragraph. If not, read on.</p><p>An <a href="http://en.wikipedia.org/wiki/OKR">OKR</a> is an <strong><em>O</em></strong>bjective and a<strong><em> K</em></strong>ey <strong><em>R</em></strong>esult. The objective is what you’re trying to achieve with this goal. It should be qualitative and inspirational (e.g. grow our user base to the moon). The key result is the metric you’ll be using to monitor your progress (e.g. grow to 10 million active users or version 1.3 shipped). A key result should be qualitative and specify a measurement window. Let’s improve the first example to “grow to 10 million monthly active users,” meaning we’re measuring ourselves against all active users in the last month. Here’s <a href="http://www.firstround.com/article/the-management-framework-that-propelled-LinkedIn-to-a-20-billion-company">more</a> <a href="http://www.gv.com/lib/how-google-sets-goals-objectives-and-key-results-okrs">about</a> <a href="http://www.eleganthack.com/the-art-of-the-okr/">OKRs</a>. Eat this stuff up. It’s good for you and low in sodium.</p><p>Furthermore, goals should cascade. At the highest level, you might have a goal around growth. Supporting that goal could be sub-goals other teams maintain for improving performance and reliability of site load time. Underlying that goal could be improving new server deployment speed. And so on.</p><p>With this in mind, let’s discuss choosing a solid metric. I hate acronyms, but I’m gonna use one anyhow. A <strong><em>metric </em></strong>should be <strong><em>Meaningful, Measurable, Operational</em></strong>, and <strong><em>Motivational</em></strong>, otherwise known as MMOM. (Why does “Operational” have to start with “O”? Ruined a potentially great acronym!)</p><h4><strong>Meaningful</strong></h4><p>Your metric needs to measure or contribute to your business objective in some fairly obvious way (or at least in a way everybody can agree on). Growing the number of active users to 10 million is a pretty good way to gauge your progress toward increasing the user base. On the other hand, using the number of episodes of Star Trek you can quote as a way to measure revenue is not so good.</p><p>The times you’ll struggle with meaningfulness will usually be when you have a metric that defines your objective pretty well, but not perfectly. For instance, does “number of times content is flagged” meaningfully measure bad experiences? Perhaps, but you’d prefer to know “number of times somebody has a bad experience”(which can be impossible to measure). You’ll have to make some tough trade-offs between metrics and constantly striving to improve.</p><h4>Measurable</h4><p>You should be able to measure progress on a regular basis. For instance, if you want to improve growth, you could measure how many people visited your site in the last seven days, which is pretty easy to do with a simple map-reduce job.</p><p>But sometimes measurability can be damn near impossible. For instance, how do you measure how much money a spammer is making from your site? No matter how many times I thought a metric would be impossible to measure, we’ve found a way. It may have not been perfect, but starting with something, anything, will help push progress forward. For the spam metric above, we started with measuring how much traffic we sent to spammers’ sites in the last month. This at least gives us some approximation of their revenue on which we can start operating on.</p><h4>Operational</h4><p>A highly operational metric is one that your team can affect and see the effect quickly. You need to be able to move the needle on your metric? And, the faster your metric responds to a change in the system, the faster you can iterate.</p><p>Measuring “how many people are currently on your site in the last 10 seconds” is very operational. You could change the color of the home screen and immediately see if it has an impact. You could change the color 20+ times in the next hour, if you want.</p><p>On the other end of the stick, you might measure how many people return to your site after 14 days. Iterating now becomes much slower because you may have to wait 14 days, but sometimes that’s a necessary tradeoff so that you measure what you actually want to measure (more <em>meaningful </em>to the company goals).</p><p>You could also consider having a few goals, one highly operational one for your team, and, separately, one less operational one that’s more meaningful to the rest of the company. They should be closely related.</p><h4>Motivational</h4><p>Don’t forget motivation! We’re dealing with people here. If people aren’t motivated, getting up in the morning to conquer this metric kinda sucks. Sometimes metrics themselves are motivational, such as increasing growth or increasing the snack to person ratio. The amount you push a metric can also have a heavy influence on motivation (discussed next in Step 4).</p><p>An important but naturally unmotivational metric can usually be remedied by discussing the impact or linking it to something more interesting. For instance, increasing light bulb brightness by 0.00003 percent sounds boring. Instead, how about stating the impact will increase our revenue by $3 million? Wow!</p><p>Others are motivated by mastery of the field. Relating this metric to how they’ll be the engineers of the best light bulb in the world can be quite compelling to some.</p><p>Some are motivated by the challenge. But, if it’s a damn near impossible goal, some will feel the it’s worthless or out of touch. If the goal is too easy, you lose others.</p><p>And still others are motivated in other ways: parties, money, recognition, beer, donuts, bacon. In reality, people are motivated by several of these at once. You must deeply understand what drives your team, not just for setting goals, but also for being an effective inspirational leader. Consider learning more about human motivation, starting with watching this great <a href="http://www.ted.com/talks/dan_pink_on_motivation?language=en">talk</a> by Dan Pink.</p><h3>Step 4. Push the liiiine!</h3><p>Once we know what we’re measuring and how we’re measuring it, the next step is to figure out how far you can push the metric on what timeline, and why.</p><p>One very common timeline to operate on is quarters. Set up monthly check-ins with higher ups to build trust with them and provide relevant updates.</p><p>First, <strong><em>what is the time range to which your metric holds you accountable?</em></strong></p><p>Some metrics should cover the whole quarter, such as maintenance metrics (e.g., don’t lose ground on availability). Some metrics, especially covering areas of fast improvement, could be unmotivational if the window is too long. For instance, measuring the teams performance before critical infrastructure has had a chance to be built doesn’t make a whole lot of sense. If you’re at 99 percent availability and want to push to 99.9 percent by the end of the quarter, you’re going to need to ship several key optimizations that may not be ready until half way. In this instance, perhaps it’s better to only measure against the last two weeks.</p><p>As a rule of thumb, I feel a metric should never cover a window shorter than two weeks. There’s generally way too much noise. Second, <strong><em>how far can you move the metric?</em></strong></p><p>This is where things get tougher. Sometimes a gut feel is a sufficient answer, but propping your answer up with data can give you a far better guess of where you’ll be by the end of the quarter and build trust with everybody else involved. Use whatever data you have available and gather new data to understand what leverage you have.</p><h4>Progress Over Perfection</h4><p>When choosing a goal for the first time, it can be very hard to discover one that meets all three M’s and one O. Sometimes there are too many metrics to choose from, sometimes there seem to be none. Just remember, you’re better off choosing a less than perfect goal to begin with rather than nothing at all. In some cases, you may find there isn’t a perfect metric or even that a metric isn’t appropriate, but give it a good <strong><em>hard </em></strong>try.</p><h2>Examples</h2><p>Here are two examples of this model applied to different situations: site performance and amount of spam.</p><h4>Example 1 — Site performance</h4><p>Let’s set a goal around site performance. Say you have a young site that’s never measured site performance. You first need a baseline, an awareness of what levers to use to push the metric in the right direction, as well as a goal.</p><p>First, choose your strategy for setting goal lines and tell everybody in the goal setting meeting. For example, set a goal line that you can hit with a 70 percent chance, and, if you don’t hit it, study why and get better at setting the goal. Also, let’s assume you’re setting a goal that you’d like to achieve by the end of the quarter that’s about to begin.</p><p>After doing some profiling to determine why the site is slow and sometimes not responding, you find that the databases are causing major availability and latency issues and that performing some key optimizations can improve latency and availability:</p><p><strong><em>Objective:</em></strong> Improve customer facing site performance</p><p><strong><em>Key Result 1:</em></strong> Increase availability measured over the last two weeks of the quarter from 98.5 percent to 99 percent</p><p><strong><em>Key Result 2:</em></strong> Decrease 99.9 percentile latency from 200ms to 100ms measured over the last two weeks of the quarter</p><p>When discussing performance, it’s always a good idea to include an availability metric (a measure of how often you return an answer to your client without timing out or erroring) and a performance metric (a measure of how fast the site loads for a reasonable portion of your users). (By the way, if you think you understand latency, <a href="https://www.youtube.com/watch?v=6Rs0p3mPNr0">think again</a>.)</p><p>KR1 and KR2 combine to give a pretty great MMOM story. First, these <strong><em>meaningfully </em></strong>measure your customer’s experience. If you improve the metric, the (hopefully small) leap of faith you’re making is that user satisfaction will go up (you can measure that as another higher OKR).</p><p>These are easily<strong><em> measured</em></strong>. You could set up <a href="https://github.com/etsy/statsd/">StatsD</a> and get this data now. You could set up alerting to know when you might be risking violating your goal.</p><p>These metrics are measured over a week, so <strong><em>operationally</em></strong> they’re a little too long. But, you can measure the most recent five minutes and one hour of availability and latency and report that to your engineers. That represents the wider goal pretty well. That way the engineers know if an optimization has an impact in just a few minutes.</p><p>Finally, these metrics, in my opinion, are very <strong><em>motivational</em></strong>. Nothing gets my engineering gears fired up like making the site faster and more reliable! Plus, we’re talking about a fairly large jump Also, you have until the last two weeks to push really hard on some of those projects so the majority of the team can focus.</p><p>You should probably designate a (implicit or explicit) goal around maintenance, as well as some resourcing to that end. It’d be bad to go from 98 percent last quarter to 93 percent for most of this quarter and then back up to 99 percent during the measurement window.</p><h4>Example 2 — Amount of spam</h4><p>Measuring the success of reducing spam is surprisingly difficult. This is because there’s a paradox afoot. If I knew something was spam, I’d get rid of it. I’d like to know how much spam is left, but how do I measure the stuff I don’t know about?</p><p>At Pinterest we went through several rounds of refining our spam metric, and we continue refining to this day. As mentioned earlier, we assume we’re shooting for a 70 percent likelihood of hitting a goal. One metric we used to use was the following:</p><p><strong><em>Objective: </em></strong>Reduce negative experiences of Pinners due to spam</p><p><strong><em>Key Result: </em></strong>Decrease pin reports by 30 percent this quarter over last</p><p>Pin reports are a count of the number of times somebody flagged a Pin on Pinterest as spam. This metric is super easy to<strong><em> measure</em></strong> — just count the number of reports that have come in with any standard stats package. <strong><em>Operationally</em></strong>, looking at a range of three months could be hard to react to quickly, but this metric is simply a count of all reports. We can keep a minute-by-minute graph that allows us to observe and react to attacks quickly and see if our rules and models are effective within minutes. Therefore, this metric is still <strong><em>very</em></strong> operational.</p><p>This metric was very <strong><em>motivational</em></strong>. We saw occasional daily spikes which could push us in the wrong direction, and low level spam attacks that made the daily average higher. e tore into the data and while we felt that a 30 percent reduction would be tough, we had a strong plan of attack. We could also try lots of different approaches and react quickly.</p><p><strong><em>Meaningful</em></strong> is where this metric is interesting. We want to measure negative experiences as a result of spam. Sometimes Pin reports are false positives (e.g., the Pinner flagged something they didn’t like, but it wasn’t necessarily spam). Additionally, Pin reports don’t really tell us how bad of an experience somebody had. Sometimes people don’t report Pins because they don’t know that they can. And, ideally, it’d be nice to know how successful spammers are (though this isn’t explicitly called out in the objective). However, Pin reports did show us when big attacks were hitting us, and they correlated with helpdesk tickets Pinners were sending in during big attacks.</p><p>As we’ve gotten better at fighting spam, Pin reports are so low that they’re largely noise. In response, we’ve now swapped to measuring how many MAUs (monthly active users) click on spam each day. This metric is more meaningful and maps directly to our spam fighting strategy (but was a bit harder to measure and operationalize at first).</p><h4>Example 3 — Student Performance</h4><p>Student performance? What the hell is this doing here? Well, I’ll tell you. I wanted an example that highlights where <em>meaningful</em> can go south. Since I’ve interviewed many engineers, debates about evaluating new grads have come up many many times, and the debates often steer toward how GPA’s suck.</p><p>Student performance is almost universally measured with a Grade Point Average (GPA), which is a weighted average of tests, homework, and other assignments, combined with a curve in order to normalize against test difficulty.</p><p><strong>Objective: </strong>Improve my knowledge of a field of study<br><strong>Key Result: </strong>Maintain a GPA of 3.8 or higher over the year</p><p>Different schools treat goal lines differently. For instance, the grad department I was in at UT Austin made it very clear to the incoming students that not achieving a 4.0 GPA was BAD(tm). They passed the first important test of goal setting — proper communication of the goal line and the importance of hitting the goal. At Harvey Mudd, my undergrad, a 3.4 was considered very good.</p><p>GPA’s are very <strong>operational</strong> and <strong>measurable</strong>. They’re influenced in calculable ways with every homework, test, etc. You can know how you’re trending, and accordingly quickly course correct by drinking less beer, studying more, partnering better, or in the worst case, dropping the course. Each of these steps can be visible with the very next homework, quiz, or test.</p><p>GPA’s can be very <strong>motivational</strong>. Many companies use them during interviews, other grad programs will look at them, etc. And, students know this. Often times, parents who still control a young student’s credit card will also see the GPA. Veeeery motivational. Interestingly, GPA’s can also be very <strong>unmotivational</strong>, especially to students who work hard, know the material, and still can’t seem to achieve the same grades as others.</p><p>Are GPA’s <strong>meaningful</strong>? I.e., do they represent analytically how well versed I am in my field of study. The ideal way to measure knowledge would be with a brain implant that can download the whole brain and test the source code. I don’t have one of those yet…</p><p>GPA’s try to measure knowledge of a field with grades on homework, tests, and projects. My gut is that GPA’s give only a <em>very high</em> level view of somebody’s knowledge + motivation + learning speed. There is probably a difference between a 2.0 and a 4.0. At the same time, GPA’s don’t tell you if the student is cheating, if other students are cheating, the difficulty of the courses taken, what kind of curve is applied, nor the student’s ability / inability to take tests. Two students from two different schools have an almost incomparable GPA. Alice could have taken the gimme courses learning very little at a school that gives 99% 4.0&#39;s and Bob could have taken all the toughest courses, learned a lot, but ended up with a 3.0.</p><p>GPA’s are a great example of why metrics should always be paired with human intuition and with a healthy dose of salt.</p><p>Follow my adventures on <a href="http://twitter.com/MartyWeiner">Twitter</a> and <a href="http://pinterest.com/martaaay">Pinterest</a>.</p><p><em>Thanks to </em><a href="http://twitter.com/jimmysopko"><em>Jimmy Sopko</em></a><em> and Chris Walters for sharing this goal setting, head banging adventure with me!</em></p><p><em>Thanks to Philip Ogden-Fisher and Sriram Sankar for their substantial feedback and insights!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99d58c426ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redis Quick Tip #1872348297]]></title>
            <link>https://medium.com/@martyweiner/redis-quick-tip-1872348297-1495ac2b8050?source=rss-190017857b3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1495ac2b8050</guid>
            <dc:creator><![CDATA[Marty Weiner]]></dc:creator>
            <pubDate>Tue, 23 Dec 2014 06:32:52 GMT</pubDate>
            <atom:updated>2014-12-23T06:54:09.196Z</atom:updated>
            <content:encoded><![CDATA[<p>Run lots of Rediseseses per server!</p><p>If you use Redis in your stack, you’re probably aware of BGSAVEs and how they can be scary. When Redis starts a background save, it forks itself and feverishly writes your data to disk. To save RAM and maintain simplicity, Redis uses a <a href="http://redis.io/topics/persistence">copy-on-write</a> approach.</p><p>If you have a high-write load, the forked Redis process may end up using a lot of RAM. Potentially double. This forces some people to ensure Redis isn’t using more than 50% RAM on any one box, lest they walk into swap hell. What a waste of nutritious RAM.</p><p>There’s a way around this! Instead of maintaining one big Redis process per server, run 32 of them on one server. Each one gets its own port. Use a sharding strategy to distribute your data (see <a href="https://github.com/twitter/twemproxy">Nutcracker</a>!).</p><p>This approach has several advantages:</p><ol><li>You can stagger all 32 BGSAVEs so that only one is happening at any point in time. This means the max memory increase is only 1/32 of your total RAM usage. (To stagger BGSAVEs, consider forcing a Redis instance to BGSAVE from a cronjob every 5 minutes over the course of a few hours.)</li><li>On EC2, you can have one EBS volume per Redis giving you a nice 32-way RAID.</li><li>If you need more capacity, you can easily move 16 of these processes to a new machine. Just replicate them over and change your shard configuration.</li></ol><p>There’s no down side to doing this except that you need to shard your data. If you anticipate explosive growth, you’ll need to do that anyway!</p><h4>Bonus Tip — Use Redis Databases</h4><p>Don’t forget Redis supports <a href="http://redis.io/commands/select">multiple internal databases</a>. If you grow a lot and end up splitting your 32 Redis processes onto 32 machines, you’ll now be back to one big Redis process per server. Crap.</p><p>Instead, run lots of databases per Redis instance (how about 1024) and shard your data across all Redis databases (1024 databases / instance * 32 instances = 32k shards). To add more capacity, you can replicate your 32 Redis processes onto a new server, and the old server can keep some of the databases from each process, and the new server gets the other databases from each process. This way, you maintain 32 Redis processes per server until you have grown 1024 times!</p><p>Follow my adventures on <a href="http://twitter.com/MartyWeiner">Twitter</a> and <a href="http://pinterest.com/martaaay">Pinterest</a>.<br>Email: <a href="http://marty@pinterest.com/">marty@pinterest.com</a></p><p>Thanks to <a href="https://twitter.com/eric_conner">Eric Conner</a> for feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1495ac2b8050" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beat Hackers at Their Own Game]]></title>
            <link>https://medium.com/@martyweiner/store-your-users-passwords-correctly-c155ac90f0c2?source=rss-190017857b3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c155ac90f0c2</guid>
            <dc:creator><![CDATA[Marty Weiner]]></dc:creator>
            <pubDate>Mon, 03 Nov 2014 06:44:32 GMT</pubDate>
            <atom:updated>2014-11-26T19:49:17.931Z</atom:updated>
            <content:encoded><![CDATA[<h4>Just store your users’ passwords correctly!</h4><p><strong>(</strong>Skip down to <strong>How NOT to store passwords</strong> if you want to jump to the punchline)</p><h4>You’re Welcome, Hackers</h4><p>Passwords are the greatest gift we ever gave to the hacker community. An elegant combination of human nature and poor dev choices brings Christmas in July for hackers. And January. And February. And well, every month, yes even December.</p><p>We’re witnessing <a href="http://www.npr.org/blogs/thetwo-way/2014/08/05/338116845/1-2-billion-web-credentials-said-to-be-in-russian-gang-s-hands">a sharp rise</a> in the number of credentials being stolen and accounts being hijacked across the web. Each new set of hijacked credentials gets a spammer into the inner sanctum of your friends on every social platform where they can spam as you. Spammers create content with links to their websites where they entice people with ads, knockoff products, and scams. Many times, surprisingly, the knockoff products do actually work as promised. In one <a href="http://cseweb.ucsd.edu/~savage/papers/Oakland11.pdf">study</a>, Berkeley researchers purchased many products from these sites and actually received them. In the case of even the knockoff Viagra, the product contained the proper active ingredients!</p><p><strong>Spammers are awesome marketers.</strong> While their marketing is illegitimate, spammers are highly motivated. They’re great at posting targeted content, getting a lot of views. They typically make a LOT of money by posting content to a site which links back to spammy sites where they monetize users.</p><p>To post content, spammers first need a registered account on your site. There are two ways to get accounts. (1) They can make or buy fake accounts to post content. To be successful in this game requires building legitimate looking accounts and a fair amount of effort to get users to click on spammy content. A spammer may need to make “friends” with many good users so their posts are visible. (2) Alternatively, spammers can hijack your good account. Now spammers can get their content right in front of your friends’ faces, which typically increases visibility and propensity to click. In this game they must acquire passwords, and they must use them before their competitors use them and before anti-spam security teams discover them.</p><p>In <a href="https://www.usenix.org/legacy/event/sec11/tech/full_papers/Kanich.pdf">one well constructed estimate</a>, spammers can make up to $2.4M in a month. To spam with hijacked accounts, spammers purchase accounts from hackers or employ hackers who try to breach company databases. In the last three years, Adobe leaked 150M emails and passwords, LinkedIn leaked 6.5M, eHarmony 1.5M, Snapchat 4.6M, Gawker 1.3M, Yahoo Voices .5M, Last.FM 2.5M, and Forbes 1M (cite). And there are more. These companies do protect user passwords, however this protection is often disastrously weak in the face of how passwords are used by people and how they’re stored by devs.</p><h4>Problem the first — Humans</h4><p>The human brain is a complicated meat sack with many competing inputs and many things to remember. Passwords are a tolerated nuisance. This sack of fats and lipids is also amazingly good at underestimating risk. The result is we users often (A) have simple passwords, or (B) use the same password in many different places, or (C) both.</p><p>To illustrate these points, the great <a href="http://www.theguardian.com/technology/2013/nov/07/adobe-password-leak-can-check">Adobe leak of 201</a>3 showed 1.9M people used the password “123456&quot;, which was also one of the top 30 passwords in the great <a href="http://en.wikipedia.org/wiki/2012_LinkedIn_hack">LinkedIn leak of 201</a>2.</p><p>It’s also common for people to have a set of 3 passwords:<br>1. Their simple password for <em>Farmville</em> and <em>Candy Crush</em> and <em>Cranberry Silo Security Simulator 2014</em><br>2. Their moderate password for <em>Twitter</em> and <em>Facebook</em> and <em>Pinterest</em> and <em>Gmail</em> and <em>Secret</em><br>3. Their strong password for their bank (though “strong” is typically an over-exaggeration)</p><p>If a hijacker has a user’s password for one site, they generally have it for the rest where it has been “shared”. If I’m a spammer wanting to maximize profits, damn straight I’m going to try these credentials on all sites I can get my hands on. Your website included.</p><h4>Problem the second — Devs</h4><p>I listed several sites that leaked their passwords. They <strong>all </strong>used less than ideal methods for storing passwords. Why? My theory is this sort of thing is just not taught in school or discussed often. Commonly, whoever first wrote user authentication used something that sounded okay. Since that day, nobody has wanted to touch the authentication layer. Is it worth the engineering effort to perform a big scary change in preparation for an event that may never happen?</p><p>I think yes — if you are a product manager who makes the decision to indefinitely delay fixing your passwords, you should be liable for when you hand your user’s keys, which happen to match their bank keys, to a Russian spammer.</p><h4>Solutions</h4><p>If we can fix either the human element or how devs store passwords, we could make hijackers’ jobs much harder. Let’s talk solutions.</p><p><strong>One solution is to fix humans or get rid of them. </strong>The problem with this approach is it’s generally impossible or bad for business. Even pushing your users to have stronger or unique passwords can decrease sign up rates in significant ways. You’ll have to weigh that balance with your growth czar. I’d at least recommend disallowing some set of 10000 <a href="https://xato.net/passwords/more-top-worst-passwords/#.UqWhW2RdXrV">most common passwords</a>, using the username or variants as the password, and some passwords unique to your site (like ‘linkedin’ for LinkedIn). By disallowing these passwords, you make brute force against your database much harder.</p><p>I’m not going to dive further into fixing the human element until I perfect my global mind-control ray (patent pending).</p><p><strong>Solution two, don’t use passwords. </strong>Companies like <a href="https://www.toopher.com/">Toopher</a> and <a href="https://getclef.com/">Clef</a> are now offering ways to use your Phone-As-Your-Identity (PAYI). Facebook and Google offer single sign-on (SSO) options where they manage user authentication data so you don’t have to. At Pinterest we offer SSO via Facebook and Google and are now exploring PAYI mechanisms. A spammer sitting 6,500 miles away in Bulgaria who needs a million or more accounts to be successful would need to hack into as many phones. That’s far harder since the spammer must hunt for cracks in venerable Telco/Google/Apple security rather than for the databases of a website that has not yet spent many person-years on security. It gets better.</p><p>With passwordless login, the insecure human aspect is removed almost entirely. Users can’t give away their <a href="http://news.bbc.co.uk/2/hi/technology/3639679.stm">credentials for chocolate</a> (caveat caveat caveat) because users don’t have access to the credentials buried in their phones. Better, users can’t use simple passwords or share them on multiple sites even if they wanted to. Needless to say, I’m closely following and pushing for this trend, but until passwordless login is the norm we must continue to clean up the password mess our forefathers left us.</p><p><strong>Solution three, store your users’ passwords properly. </strong>We, the devs, can solve this whole problem by simply storing passwords in a way that does not allow a hijacker to use them. Encryption, hashing, something…</p><p>Databases love to get leaked especially if they contain awesome data. Naturally you should work toward adopting a strong security stance to protect your database in the first place. But, should a hacker get a quick view of your database, <strong>make that view unappealing. </strong>Remember rule #1 of spamdom: “spammers want money or power”. A database with <strong>strong </strong>password protection and a bunch of recipe descriptions isn’t worth much. If hackers find you store your passwords correctly, they are less likely to extract your data — why bother? If your passwords still do leak, let’s minimize the risk to your users, your neighbors’ users, as well as the risk to your PR reputation.</p><h4>How NOT to store passwords</h4><p>Most people are surprisingly uneducated on how to store passwords.</p><p>Let’s do some engineering. What are the requirements for a good password storage system? I propose these simple two:</p><p>1. Users should be able to authenticate or create a new account by providing a unique identifier (e.g., email) and a plaintext password<br>2. Password recovery difficulty should be maximized</p><p>A non-requirement — you should never need to recover the exact password a user used. The most common reason cited for password recovery is being able to email that password to the user if they lose their password. Many sites do this, and it’s bad bad bad. Any time I see a site that can send me my password, I KNOW they’re storing their passwords weak (and so do the bad guys). Refactor your account recovery system to create a new random password and send that to the user.</p><p>Looking at the last several major leaks, here are a few common ways passwords are stored:</p><p>1) Plaintext</p><p>Holy shit. Plaintext. This means that the passwords are stored with absolutely no encryption / hashing / anything. Yahoo Voices did this.</p><p>I believe storing plaintext passwords may violate requirement 2. Let’s stop here and cry in our beers for a few minutes that this is ever done.</p><p>2) 1-way cryptographical hash</p><p>A 1-way cryptographical password hash is intended to convert your password to a long string of characters that is very hard, if not impossible, to reverse. So, hopefully if a hijacker gets the hash of your password, they’ll never be able to recover your password. Examples include MD5 and SHA1 and look like this:</p><pre>MD5 (“123456&quot;) = e10adc3949ba59abbe56e057f20f883e<br>MD5 (“seinfeld”) = 9fab36cc63eac0a9951edd4e6a6ac6f8<br>SHA1 (“123456”) = 7c4a8d09ca3762af61e59520943dc26494f8941b</pre><p>This is the most common way passwords are stored incorrectly. LinkedIn was guilty of this sin. Hell, Microsoft got it wrong with their ubiquitous <a href="https://media.blackhat.com/bh-us-12/Briefings/Duckwall/BH_US_12_Duckwall_Campbell_Still_Passing_WP.pdf">NT hash and LM hash</a>.</p><p>So why is this a bad way to store passwords?</p><p>Here’s where the fun begins. Have you heard of rainbow tables? If so, you’re golden, skip this paragraph. If not, read on. A rainbow table is a very large hash table of password hashes back to the unhashed password (smarty description <a href="http://lasec.epfl.ch/~oechslin/publications/crypto03.pdf">here</a>, one I can read <a href="http://en.wikipedia.org/wiki/Rainbow_table">here</a>). With a rainbow table, I can recover any one SHA1 password in picoseconds. It turns out you can construct a rainbow table for all alphanumeric passwords of 9 characters or less and store it in just 864GB in a few days (with <a href="https://securityledger.com/2012/12/new-25-gpu-monster-devours-passwords-in-seconds/">this</a>!). Or, you can go download one from <a href="http://www.freerainbowtables.com/">www.freerainbowtables.com</a> (no really!). With such a table and modern EC2 offerings (see r3.8xlarge on <a href="http://ec2instances.info/">this table</a>), you should be able to hit 50 to 100 million passwords converted <strong>per second</strong>. How many users does your site have?</p><p>3) 1-way cryptographical hash with salt</p><p>Do you avoid salt in real life? <a href="http://articles.mercola.com/sites/articles/archive/2012/02/17/dangers-of-salt-restriction.aspx">Here</a>’s some light reading that might be important to your health.</p><p>If your password storage is also low in salt, read on.</p><p>Password salting is the practice of adding an extra bit of data to the password before you protect it. For instance:</p><pre>MD5 (“seinfeld|81837210385&quot;) = 864069725cb607a13f097ef623f7eb75<br>MD5 (“seinfeld|93982716363&quot;) = 2d12282c267774a57368f6470b16650f</pre><p>Then you store the hash and the salt in the password field. Given a decently large salt that’s different for every account, you cannot reasonably make a rainbow table to store all salted hashed passwords. Great!</p><p>But, by definition cryptographical hashes are FAST to compute. There’s a reason for this. They were never meant for security. They were meant for error detection in transitions and storage. If you transmit a 4GB file and even 1 bit changes, the MD5 of the file changes vastly:</p><pre>MD5 (“seinfeld”) = 9fab36cc63eac0a9951edd4e6a6ac6f8<br>MD5 (“Seinfeld”) = 5b01e11129355ca058d358dfcae3ce2c</pre><p>Great for error detection, but the speed of these hashes is so fast, you can create a rainbow table in hours to days. A rainbow table of all 7 or fewer character passwords takes minutes to compute. If your cryptographical hashed and salted set of passwords gets out, your overall user base is still very at risk, especially your high risk targets like celebrities or employees.</p><p>4) 1-way slow hash with salt</p><p>Let’s make computing the hash slow! I swear, this is the end of the ride.</p><p>With salt, making a globally useful rainbow table is damn near impossible. Using a slow hash makes creating a rainbow table for any one user exceptionally difficult or brute force crunching nearly impossible. Like years or decades or millenium impossible. Even better, as computers get stronger, these methods include a difficulty amount called the cost parameter. If computational strength increases by 10x, pump up the cost! Well, in theory that will work (quantum computers? la la la la la la la).</p><p>At this point, hijackers are down to brute forcing. Your high target users with the most common passwords are still at risk, so consider disallowing the most common passwords.</p><p>What should you use for delicious slow salted password storage? There are several great options to choose from. These days, the most common are <a href="http://en.wikipedia.org/wiki/Bcrypt">Bcrypt</a>, <a href="http://en.wikipedia.org/wiki/Scrypt">Scrypt</a>, and <a href="http://en.wikipedia.org/wiki/PBKDF2">PBKDF2</a>. So, which?</p><p>Bcrypt has been around since 1999 and has matured quite a bit. It’s available in most languages and has a lot of eyeballs on it. But, it is starting to show a little age. In particular, the computational strength stored with each Bcrypt password cannot be dialed up. So, in 5 years when computer power increases substantially, you will have a harder time pushing up the power for all of your passwords. Not too big of a deal — worst case if something better comes along you can always wrap your Bcrypt passwords with the next big thing.</p><p>If you’re feeling feisty, have a look at Scrypt and friends. Scrypt, in particular, is gaining in popularity especially among crypto-currencies. But, like any relatively new technologies, there are risks. The many implementations have not had as much time to mature, and <a href="http://blog.ircmaxell.com/2014/03/why-i-dont-recommend-scrypt.html">there are fears</a> for the underlying maths. Currently I’m not aware of any websites that use Scrypt to store passwords.</p><p><strong>If I started a new site now, I’d go with Bcrypt.</strong></p><h4>How do I use Bcrypt?</h4><p>It’s <em>super</em> easy. In Python, you can create a new bcrypt password for user registration or password changes with the following:</p><pre>import bcrypt<br>bcrypt_pw = bcrypt.hashpw(plain_password, bcrypt.gensalt())</pre><p>And you would store the bcrypted_password in your database. To verify a password the user just entered, do the following:</p><pre>allow_login = bcrypt.hashpw(plain_password, bcrypt_pw) == bcrypt_pw</pre><p>Bcrypt passwords look like this:</p><pre>bcrypt.hashpw(“123456”, bcrypt.gensalt()) = &#39;$2a$12$HqXXZ1TTb4Z0OV9jYUS7X.A1tYCPWRn6FhSVcsGDxjXm92BWw35yS&#39;</pre><p>For the curious, the 2a defines the format. 12 is the cost factor. The goop before the period is the salt, and the goop after is the hash.</p><p>Here are some Bcrypt libraries you can use:<br>Java: <a href="http://www.mindrot.org/projects/jBCrypt/">http://www.mindrot.org/projects/jBCrypt/</a><br>Python: pip install bcrypt<br>Ruby: gem install bcrypt-ruby<br>Go: import “code.google.com/p/go.crypto/bcrypt”<br>C/C++: <a href="http://openwall.com/crypt/">http://openwall.com/crypt/</a><br>Node: <a href="https://github.com/ncb000gt/node.bcrypt.js/">https://github.com/ncb000gt/node.bcrypt.js/</a><br>Perl: <a href="http://search.cpan.org/~jaitken/Digest-Bcrypt-1.0.1/lib/Digest/Bcrypt.pm">Here</a>, but seriously.. Perl?</p><h4>How do I convert my current site to Bcrypt fast?</h4><p>My prime audience is those of you out there who are reading this and realizing that your 10+ million users’ passwords are SHA-1’d or one of the other weak methods. The good news is converting your entire system to Bcrypt can be done overnight quite easily.</p><p>If your passwords are not salted, creating new passwords and verifying new passwords will now be a bcrypt of your previous method. If using SHA-1, you will now do the following:</p><pre>bcrypt_pw = bcrypt.hashpw(sha1(plain_password), bcrypt.gensalt())</pre><p>and</p><pre>allow_login = bcrypt.hashpw(sha1(plain_password), bcrypt_pw)==bcrypt_pw</pre><p>You don’t gain or lose any security by keeping the sha1 password around, but you can convert all your passwords now. You don’t have to brute force discover all your users’ passwords, force reset, or wait for them to login so you can convert the password.</p><p>If you have a system with a per account salt such as SHA-1(pw+salt), it’s slightly tougher. You now need to store the bcrypted password and the previous salt:</p><pre>bcrypt_pw = bcrypt.hashpw(sha1(plain_password+sha1salt), bcrypt.gensalt())</pre><p>And store bcrypt_pw and sha1salt in your database so you can do the following:</p><pre>allow_login = bcrypt.hashpw(sha1(plain_password+sha1salt), bcrypt_pw)==bcrypt_pw</pre><h4>Last Thoughts</h4><p>Be sure that you don’t log plaintext passwords. Most commonly, plaintext passwords are found when sites log errors during login, or log user edits, etc.</p><p>If you have backups of old database dumps (hopefully you do!) or dump your database for use in map-reduce, consider wiping whatever you don’t need or cleansing what you do need soon.</p><p>That’s all you need to know! Go to it! Write me at marty@pinterest.com when you’re done. I’d love to hear your experience and challenges!</p><h4><em>Last</em> Last Thoughts</h4><p>For the sake of fun story telling, I left off one other way passwords are commonly stored incorrectly:</p><p>5) 2-way encryption</p><p>Encryption is not necessary except if you want to recover a specific user’s account. This violates requirement 2 of good password storage from above.</p><p>Adobe was guilty of storing their passwords this way. They used 3DES, which is an encryption method. 3DES is also unsalted and therefore susceptible to decrypting via rainbow table attacks. Worse, if your hacker has recovered your encryption key, your database is now as good as plaintext.</p><p>It gets worse. Adobe also stored hints. I think this XKCD comic says it best:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*tdprVOE-jxAyBsZfYOI9UA.png" /><figcaption>Source: XKCD (<a href="http://xkcd.com/1286/">http://xkcd.com/1286/</a>)</figcaption></figure><h4>Sticker!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gu5aAM5uK6opQyqpgS8WBQ.png" /><figcaption>Want to make your own stickers?</figcaption></figure><p>Follow my adventures on <a href="http://twitter.com/MartyWeiner">Twitter</a> and <a href="http://pinterest.com/martaaay">Pinterest</a>.<br>Email: <a href="http://marty@pinterest.com/">marty@pinterest.com</a></p><p>HUGE thanks to <a href="http://twitter.com/jamiefavazza/">Jamie Favazza</a> and <a href="http://twitter.com/malliegator">Malorie Lucich</a> for critical feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c155ac90f0c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>