Share
Observability & the Development Process
This talk was presented at Codemania 2018.
Historically, monitoring has been thought of as an afterthought of the software development cycle: something owned by the ops side of the room. But instead of trying to predict the various ways something might go sideways right before release and crafting dashboards to prepare, what might it look like to use answers about our system to figure out what to build, and how to build it, and whom for?
Observability is the practice of understanding the internal state of a system via knowledge of its external outputs -- and is something that should be built into the process of crafting software from the very beginning.
In this talk, we'll discuss what this might look like in practice by using Honeycomb as a case study: how we rely on visibility into our system to inform planning during the development process, to observe the impact of new changes during and after release, and, of course, debug. We'll start by describing the problems faced by a SaaS platform like ours, then run through some specific instrumentation practices that we love and have used successfully to gain the visibility we need into our system’s day-to-day operations.
Christine Yen
Transcript
55 slides
-
hi. the title of this talk is "observability and the
development process," and today I’d like to talk about how observability — a word associated with monitoring, with "over there in production-land" — is a mindset and a set of tools that can benefit us not just after, but before and during our software development process. i’m also a cofounder at honeycomb, which is focused on empowering engineering teams to understand their software in production. as a disclaimer - while i’ll be sharing some examples about how we dogfood to build honeycomb, the philosophies and techniques are generally applicable and should be transferrable to your existing tools. -
who am i? i’m christine :) an engineer who’s done
software dev for many years -
these days, software development is usually super customer-focused. there’s a
whole suite of stuff we’re super diligent about: and we celebrate shipping!! … and we forget about it. -
until an ops person comes knocking on our door, grumpy
and complaining about something breaking. which can make devs respond like this :) we all know folks, on either side, who talk like this. what happened to that diligence? that curiosity? that "oh, i should check these edge cases"? when we focus on the "us" vs "them" of this conflict, we get folks pointing fingers and hunkering down on their POV. but what brings us together, in the end, is this contract to the users of our service — this is what unifies us. so no matter what, we’re in this together, and need to start thinking from the perspective of users in production, instead. -
from the developers’ perspective, we can use data about users
in production to really explore what our services are doing. and as a result, we can inform not only what features we build / bugs we fix, but also: -
During the development process, we've got lots of questions about
our system that don't smell like "production monitoring" questions, but should totally rely on production data to answer them. Instead, they're about hypotheticals. Or specific customer segments. Or "what does 'normal' even mean for this system?" (I’d actually posit that any sort of performance work, you just can't do reliably without actually measuring behavior in the wild) -
Here are some questions that look an awful lot like
standard, production systems-y, ops-y questions… But since we're a SaaS platform, and because we sell to businesses who rely on us to understand their systems, we have a lot of different workloads coming in, each of which we have to be able to understand in isolation from the rest. Our nouns, our things-to-drill-down-by, are always customers. -
… and once you start talking about customers, and their
workloads, and how that might impact or affect what the code does… then devs start to care about the answers to these, too. Your nouns might be different. You might care about expensive Mongo queries, or high-value shopping carts, or the countries responsible for processing transactions. But the premise is the same — that the most painful problems to debug, the most annoying things to realize, the most important edge cases to understand, often originate from that one outlier doing something unexpected, while the code expected something else. and these are problems that ops people often find, but devs have to help fix. -
Here are some examples of how folks currently answer these
questions. Some folks would label this side monitoring, or this side APM; some would label this side "for ops people" and this side "for developers"; I say it doesn't matter. The goal here is observability. The goal is not a form factor but to be able to answer questions with data. And these labels invite folks to erect walls, to create "us" vs "them" these tools want to create a divide, but—remember?—we’re all in this together. we're all software owners, trying to provide a service to our customers. -
We’re here today because this wall that folks think of—between
"works on my machine" and "it’s over the wall now and in production"—has to come down. We’re entering a world with containers and microservices and serverless systems, and there’s too much code in production for developers to not take ownership of what gets deployed. the first wave of devops was about teaching ops people to code. teaching them to automate their workflows, to do more development. the second wave is going to have to be about teaching devs to get comfortable owning their code in production. and observability—teaching and encouraging devs to look at prod, to poke at prod, to understand prod through data—is how we get there. -
which one is easier to map to the code i'm
writing? tools matter. the data we feed into those tools matter. and our tools for understanding prod can’t just talk in terms of CPU and memory and disk space, not if we want devs—who think in terms of build IDs and codepaths and customers—to use them too. -
Observability should be a core part of the development process.
As the software is being built — not as it’s being evaluated for reliability, or right before it’s deployed — we need to be feeding useful information into each step of that process. As much as testing or documentation, understanding what our code does in production teaches us how to build better software. All the time. Observability isn’t just for finding out when things are broken or going wrong — it’s for understanding your software. "what does normal look like" e.g. "oh, these errors are normal"—the logs always look like this; that raised line is a red herring. -
let's go back to that slide of all the things
that developers do and break them down into some more manageable steps what informs each of these? is it just our fantastic developer intuition? do we have a PM feeding us instructions? ... I mean, the answer to both of those might be yes. but I sure hope we have some real data coming in as well! let’s take a look at some real-world examples of what using data in each of these stages of the development process might look like. -
This is the most boring case for me, because there’s
really no shortage of people and software telling developers what needs to be fixed: alerts, exceptions, people on Twitter; they all help identify work that needs to be done. Data comes in to play, though, in refining that directive — when you’re going from a high-level "elevated latency" alert to "X part of your system is misbehaving under Y circumstances." -
This might be a classic example, but I’ll run through
it anyway. Honeycomb ingests your events, then lets you query over them. we optimize for really fast analytics on our column store, but we also support folks asking to view the full events that make up a given query. One of our very large customers was able to run a simple COUNT query just fine, but was experiencing timeouts when flipping to raw data mode—even when the two queries were theoretically drawing from the same set of rows. We were able to jump into our data, figure out what was "normal" in aggregate, then zoom in on just the two queries that were under examination. Without going into detail, since my time is limited :), we were able to figure out where we were doing a whole bunch of extra work in this very specific case, and add to our benchmarks for the future. there are certain things that can only be debugged or diagnosed in production, at scale. and by having all of the information we needed, from a developer’s perspective, in prod—we could start high level, zoom in on it, then essentially replay the past. -
This is another example of the sort of high-level analysis
we were able to do on this one customer’s data. We were noticing that a small number of the timestamps they sent us were splayed all over the place, and also causing degraded query performance—and, somehow, the bottom graph seems to show one particular availability zone resulting in… really weird latencies getting sent in. We were able to go back to the customer with something super specific for them to look into -
There's a difference between knowing that something should be changed
or built and knowing how it should be. Understanding the potential impact of a change we're making—especially something that'll have a direct, obvious impact on users—lets us bring data into the decisionmaking process. By learning about what "normal" is (or at least—what "reality" is), we can figure out whether our fix is actually a fix or not. -
When we were first starting out, we knew we needed
to build in real rate limiting into our API—our previous band-aidy solution involved in-process cache, where each server kiiind of just approximated the rate limit individually. while this worked well enough, it meant that as our traffic grew, there was an unwanted correlation between which server a single request hit, and which customers were actually being rate limited. we needed to spin up a shared cache and clean up this tech debt but instead of just blindly making the change, we wanted to be confident it’d actually behave correctly. while we perfected the logic and heuristics, we could start capturing data in prod to simulate the logic, to see what the steady-state behavior would be, without impacting customers. So alongside the logic in the API server that calculated a particular requests's rate limit, we added a bit that tracked whether or not a given request would have been rate limited by the new algorithm. -
And then we could visualize the glorious new hypothetical future
We could see that - as expected - the new rate limiting algorithm was more strict in a number of places, especially around large spikes. but we now had enough information here to examine each case individually and assess whether the change was what we intended! and the ability to actually identify which customers would have been rate limited… allowed us to work with each customer to help them understand the change in behavior. -
Here’s another example. We wanted to introduce some basic compression
into our string columns, and hypothesized that datasets with lots of unique strings (high cardinality) would benefit less from compression. Before we started building, we gathered data on cardinality characteristics of string files in production, today. The conclusion we reached: most but not all string columns are low-cardinality, so most but not all columns will benefit from compression—was able to set expectations before we jumped in and did the time-consuming implementation of our new compression scheme. -
I love these stories because they’re like — debug statements
in your prod traffic. By having a flow where it’s lightweight and natural for software engineers to add these diagnostic bits and suddenly be able to describe of the execution of your logic in the wild, we can make more informed decisions and deliver better experiences to our customers. -
Testing is great and all, but how do we select
our test cases? A lot of this tends to be "intuition," or guessing at edge cases that matter. Why not use prod data to determine which test cases are worthwhile? -
It’s pretty nice to be able to go take a
look at your prod data to ask, hey… across all of the payloads hitting our API, what’s the distribution of the number of columns within each payload? what are the edge cases we should make sure to handle? Note: this, right here... is why pre-production testing is never going to be enough. The test cases are determined by humans, and even though we're using "data in the wild" to inform those, who knows what crazy things will happen next week, next month, next year? -
We love the concept of "testing in production." Testing on
your machine is all well and good, but what do we do when we aren't quiiite sure about our change, or want to check its impact in some lightweight or temporary way? -
We love feature flags for letting us essentially test in
production while we're still making sure the change is one we're happy with shipping. Pairing feature flags with our observability tooling lets us get incredibly fine-grained visibility into our code's impact. Being able to get these arbitrary feature flags into our dogfood cluster, means we can look at our normal top-level metrics, segmented by flags. This becomes incredibly powerful when we do things like turn a feature flag on for a very small amount of traffic, while still retaining the ability to slice by hostname, customer, whatever. -
The best part about this approach is the ability for
your developers to define these ephemeral, specific segments of your data freely to answer these sorts of... ephemeral questions that pop up during development. At this point, we actually send all live feature flags and their values along with all payloads to our storage engine dataset, so that as we observe future experiments, we don't have to stop first and remember to add the feature flag to a metric name or dashboard -- they're all just right there, mapped to the flags that we as software engineers are already thinking about. -
STORY TIME: we feature flag heavily. lots for UX reasons,
but also anytime we make changes to our storage layer -- these are hard to test locally (both because of scale and diversity of types of data). About a year ago, we were making changes to our string storage format. It was intended to make things more flexible but we wanted to make sure that it didn’t impact performance significantly. It was a twitchy change, and something that we wanted to roll out very carefully, one dataset at a time—this would give us greater isolation and ability to compare performance impact that if we’d done it one storage host at a time. What feature flags and this observability mindset let us do—we could go from these top-level metrics around volume and cumulative speed of these writes -
… to being able to inspect "COUNT and AVG(cumulative write
latency) for each write for datasets in the experiment, vs metrics for datasets not in the experiment." This graph’s purple line actually shows writes that are flagged in to the new code, and seems to somehow show latency going up for both groups when datasets are flagged in. -
… Turns out there was just a correlation between write
speed and another factor (size of the write) that wasn’t shown on the previous graph. By poking around and adding that one in, we could pull those lines out, recognize that they’re just steady-state slower than the rest, and convince ourselves that the storage format change was stable after all. (This example actually made it onto our blog, and you can find out more about it here: https://www.honeycomb.io/blog/20 17/08/how-honeycomb-uses-honeycomb-part-5-the-correlations-are-not-what-they-seem/) -
I almost left this stage out of the deck, thinking
you all know how to do this - but I want to press on this, because it’s a great example of the ops/dev split I touched on earlier. What’s the biggest source of chaos in systems? Humans. Software Engineers. Us, pushing code. :) Our tools have to be able to reflect this chaos - accurately. The state of the art for this these days seems to be drawing a line to mark a deploy, or matching up timestamps against some other record — but anyone who’s spent enough time deploying their code knows that deploys aren't instantaneous -
- For example, we do rolling deploys of our storage
nodes - and here you can see the progression of the deploy, the switchover, happen. -
Here’s a more dramatic example. I was watching a deploy
go out containing some changes that should have had no impact on performance—but saw the average latency for query reads go up a whole bunch. I was able to pinpoint the build where that started, go figure out what else made it in (turns out another storage layer change landed :)), and give the engineer a heads up. And, you can see where they reverted their change and latencies largely returned to normal. If you think about the sorts of observability tools that developers tend to rely on the most, because they speak their language, you think of… what? Exception trackers and crash reporting tools. Workflows to associate degenerate behavior with an outdated build are half the value of nice exception trackers — and if we just remember to fold some of those nouns, some of that vocabulary, into our current tools, then maybe it can start to be more natural to reach for a different set of tools. -
That's how we help bridge this "ops" vs "dev" gap,
and that's how we devs start thinking about what happens after we ship: -
Instrumentation and observability shouldn’t just be checkboxes for the "end"
of the dev cycle; they should be embedded into each stage of the development process and continually checked to keep us grounded with "what’s normal" / "what’s really happening." By capturing more, lightweight, transient information in prod — even before we flip a switch and ship real code — we’ll be better-informed, make better choices, and deliver better experiences for our users. -
Yep, the things that we deal with day-to-day may be
different, depending upon which end of the spectrum we fall on… but in the end, we build bridges that bring us together. Things like e2e checks => the ideal way to say, "hey: all i care about is this core functionality of our product. does it work?" Transcends devs or ops—potentially use dev skills and ops techniques to make sure things keep working. Observability => asking new questions about our systems. Not just for ops. -
OK, grumpy folks and skeptics, I see you So I
hear what you're saying. And you're right to be skeptical. -
… except, in the bigger engineering orgs we’ve talked to,
no one actually wants to have people slinging code over a wall or having another entire team be responsible for tracking metrics or, heaven forbid, having an entire team be responsible for adding metrics -
We're seeing people end up in this position and slowly
try to move away, asking questions like: How do we empower our dev teams to think in terms of real-world impact? how do we get them to pay attention to our monitoring? ... How do we make our devs not scared of prod? Think back to how you stopped being scared of prod. -
There are so many ways where we naturally democratize familiarity
/ comfort with something new. pairing (doing something together, where you're talking through your thought process) design patterns (taking something that works, understanding why it works, and riffing off of it) tutorials (intentional, optionally hands-on teaching) code reviews (transferring knowledge, bouncing things back and forth, critiquing) architecture reviews (asking for benchmarks, "baselines") All of these techniques for learning anything engineering-y can help build up comfort with "observability. how else do you know that you're building something worthwhile? and starts building up the expectation that it's data that isn't just "over there" that isn't only relevant for keeping an idle eye on after the fact but is in fact something that we use to feed into our day to day. -
And, arguably, the feedback loop is even more important when
it comes to these folks New engineers—or just engineers new to your team—are so much more susceptible to learning that (using data to determine what's "normal," etc) is just the way that things work. Ops folks call this understanding the potential "blast radius" of a change because they expect things to blow up. There's already tons of discipline here on the design and product side: "how will we measure success? what will the impact be on our engagement numbers, etc?" Man, bringing that mindset into the engineering world means that we're not looking at things like MONTHLY ACTIVES or anything -- we can measure performance, errors, throughput, etc, NOW. Immediately. Things that matter in our time frame. -
Yeah, okay, maybe some of the pre-rollout verification is overkill
for your system. But how many times has being super careful about rolling out super risky changes bitten you… compared to the alternative? This sort of flexibility saves you time—being able to diagnose issues quickly in production gives you another way to ensure correctness besides… ginormous test suites that take hours. -
Okay. So. How do we get there, from nothing, without
getting lost in a giant rabbit hole? Start at the edge and build it up: in our webapp, for a long time the least sensitive part of our system, we just stuck in a middleware that turned each HTTP request into an event for logging. But that... was actually pretty great! We were able to toss it into dogfood there and immediately answer super-high-level questions like: "if I make this change, will anybody care? Is anybody hitting this route regularly?" -
- On top of those standard HTTP attributes like URL,
status code, latency, and build ID, we made sure to include our business-relevant characteristics (like customer id and dataset id) and any infrastructure-specific characteristics (like the kafka partition an API write was going to, for example, or storage nodes queried). -
- And this sets you up for the sort of
ad-hoc, ephemeral queries that drive development forward. - Remember, many of those examples we ran through earlier -- the rate limiting example, or the feature flagged storage example -- relied on data that we had to add, often in parallel to the actual code being written. The simpler and smoother it is for engineers to add this sort of metadata on the fly, the more we’ll be able to use it to make sure we're building the right things. -
- Some fields (e.g. timers) we'll just leave in place
in case they're useful in the future. Other fields do eventually get pruned when they're no longer useful or are noisy, the same way feature flags do. -
- Some things that have helped us keep our data
clean and easy to work with - Contextual, structured data - In our API code, we attach a map to our request contexts, pick up attributes or tags along the way as code is executed, then send the payload off upon http response - This ensures collection of a ton of useful context alongside the metrics we care about visualizing, as well as providing a consistent mental model of request -> single unit of work, or an event -
- Establishing a common set of nouns that we care
about, and being consistent with our naming patterns (e.g. always `app_id`, not sometimes `appId` or `application-id`) will help make Future Us not hate Past Us. - Those common "business-relevant characteristics" I mentioned? Those map to a consistent set of metadata on all events we send (hostname, customer ID, dataset ID, build ID, etc), no matter which part of the system we’re looking at. -
- Ultimately, instrument services according to your need. Think about
how you're likely to read the data and how important certain attributes will be relative to others. -
- For example, say you have a service where you
care a lot about read performance characteristics, so we capture lots of timers and information about the shape of the read, for every single read request. - On the other hand, we're generally interested in the health of our datastore's write path, but it's a high-throughput codepath that has been really highly optimized -- so it's a rare example of being a) very sensitive to the performance overhead of capturing events, and b) less interested in granular observability (especially because we already learned whatever we needed to at the API layer). As a result, we actually batch up writes per dataset (still a pretty high-cardinality field!) and do some pre-aggregation to make life saner for everyone. -
And, just because I always like to show folks what
our experience is really like, here’s how the schema has evolved for us observing our own API: -
# In Conclusion - I don't care what tools you
use, we should all be doing these things. - big or small, compliance or no compliance — the folks involved in shipping software should understand the behavior of our systems in production. - Software developers, we should own observability — because we have the most to gain! - Observability should be a core part of how we understand what to build, how to build it, and who we’re building it for. - We have the power to use data, be better engineers, and ship better software