Going to AWS re:Invent 2026? Join us at booth 1871 for demos, giveaways, and more.
Meet with us

Outgrowing Lambda Functions, Not Lambda

This post walks through moving the bulk of query compute to AWS Lambda Managed Instances, the misread telemetry, the utilization math, and the months of performance engineering that turned the switch into a 40-56% cost reduction.

Honeycomb logo and the AWS Lambda logo on a dark background.

Honeycomb, at its core, is a big data processing tool focused on the observability domain. Its spiritual predecessor, Scuba at Facebook, required all data to live in RAM. But by the time Honeycomb was founded, NVMe storage had become a performant yet far more cost-effective alternative to keeping everything in memory, so we built our “retriever” columnar storage engine around it. In 2017, we introduced Secondary Storage, tiering older data to S3 so that we could scale beyond the limits of the NVMe that any one AWS host could hold. But customer queries across longer ranges of time could take tens of minutes to retrieve from S3 and process on a mere double-digit number of hosts.

Why does time range matter so much? Each dataset is stored as segments, each covering a slice of time, and each column of each segment is its own file. A query only reads the segments overlapping its time range (and only the columns it needs), so a query over sixty days of a busy dataset does sixty times the work of the same query over one day. On a fixed fleet, response time grows in lockstep. What we wanted instead was for compute to grow with the time range while response time stayed flat, and to get that compute in seconds, which rules out booting EC2 instances.

In 2019, Honeycomb began using AWS Lambda Functions as the mapper workers for retrieving lz4-compressed data from S3: each query fans out into many invokes, each invoke reads, filters, and aggregates a batch of segments, and our query nodes merge the partial results. The reasons we cited then for why Lambda was ideal for our use case still apply today, but the scale has changed enormously. The compute we can bring to bear on queries at any one moment, measured in concurrently available vCPU, has grown by at least three orders of magnitude: we went from hundreds to thousands to tens of thousands of concurrent workers, and didn't pay for a millisecond longer than we actually used to run queries on behalf of our customers. Over the same period, our peak ingest has grown about fifteen times, to around 6.7 million events per second, and the number of queries run each week has grown about fifty times.

Figure 1: Peak ingest and weekly queries since we moved to Lambda, indexed to their 2019 averages.

In this post, we'll walk through how that model eventually stopped fitting our workload, the alternatives we tried, and how we moved the bulk of our query compute onto AWS Lambda Managed Instances (LMI), including the mistakes we made along the way. Spoiler: the switchover itself was the easy part.

Initial scale-out and cost tuning

Initially, the cost economics and performance worked out great. Access to Lambda Functions' compute on demand powered one of our most differentiating features: speed, with 90% of queries returning within two and a half seconds. We gave presentations and wrote about how we were able to switch our AWS Lambda Functions workers over to arm64 from x86 to realize significant cost savings, running identical copies of our function for each architecture behind a feature flag until we were confident enough to send 99% of invocations to Arm.

Lambda Functions does scale, but within limits, and we got to know those limits intimately. Each function can add about a thousand concurrent executions every ten seconds (refilled a little every second, so it's a smooth ramp rather than a staircase), up to the account limit, and beyond that you get HTTP 429s. That's a great fit for web traffic, which ramps; it's a terrible fit for a query that suddenly wants ten thousand invokes all at once, in well under a second. Support can raise the ceiling, but not how fast you climb towards it. So every 429 became a decision our code had to make: retry, wait, or go somewhere else. (A word to the wise: check your SDK's retry defaults. The Go SDK's default backoff is far too slow for a query that has to finish in seconds.)

But eventually, the pace of AWS silicon innovation eclipsed the rate at which the Lambda fleet was being refreshed. By recording the CPU part number on every invocation, we determined we were seeing a mix of 49% Graviton2, 49% Graviton3, and 2% Graviton4, when Graviton5 instances were already available to us on EC2. We'd experienced first-hand the power and price performance improvements from Graviton2 all the way through to Graviton5, so we became suspicious about whether the price of Lambda Functions was still competitive for our workload. What had been a 3-4x penalty per core-millisecond compared to EC2 back in the m6g days more than doubled, to five to eight times, once we adjusted for the older CPU mix we were actually getting.

And the billing model itself worked against us. Lambda Functions bills in GB-seconds, memory multiplied by wall-clock time, which includes all the time spent waiting on S3. Our cold reads were network-bound (in Europe, the CPU was only about 40% busy), and for years each sandbox got a fixed slice of network bandwidth regardless of how much memory we bought. So we'd make our CPU work dramatically cheaper and the bill wouldn't budge because we weren't paying for CPU, we were paying for waiting.

Meanwhile, the shape of our workload changed underneath us. We had more and more customers issuing queries that didn't need extreme millisecond-level speed, for instance querying via our MCP server or our query data API. Weekly MCP tool calls went from tens of thousands in February to over a million by October, most of them queries, and an agent investigating an incident doesn't ask one question, it asks dozens, wide and long-range, all in a burst. (Human-run queries, interestingly, have been roughly flat since 2024.) This load became a steady baseline rather than the spiky load that we'd originally gone to AWS Lambda Functions to solve, and the cost of the Lambda core-milliseconds and the S3 GET API calls combined had grown to become a plurality of our AWS bill.

The spikes didn't go away, either; they got bigger. Our ten-second peaks ran about nine times our average concurrency in the US, and fifteen times in Europe. And while the AWS Lambda Functions fleet was capable of withstanding short bursts of 70,000 concurrent invocations, we found that we could inadvertently create latency and reliability regressions for ourselves and others by slamming the Lambda Functions service with over a hundred thousand concurrent invocations (and millions of requests in the span of seconds).

We began investigating what an alternative to Lambda Functions might look like. Back in 2020, we'd built a set of read-only retriever query workers called “Golden Retrievers,” and removed them in 2022 once it became clear that adding ordinary retrievers worked better. We revived the name for this project as well: the goal was to create an EC2 Auto Scaling group that we could tune up and down on demand, which would pull files from S3 on behalf of the core indexing and query-handling nodes. When we sharpened our pencils, though, a fleet sized for our peaks and running around the clock came out at about 3.4 times what we were paying for Lambda.

Enter AWS Lambda Managed Instances, which launched at last year's re:Invent. LMI keeps the part of Lambda we liked while running the execution environments on EC2 instances in our own account, from instance families we choose. We set a target CPU utilization and a minimum and maximum fleet size, AWS packs execution environments onto the instances, and Compute Savings Plans apply to the instances themselves, with a management fee on top of 15% of the on-demand price.

Setting up LMI

It was surprisingly easy to set up Lambda Managed Instances thanks to the shared API with Lambda Functions. The main issue we encountered was the lack of full Terraform provider support for propagating capacity provider tags down to the underlying instances. But the logic to call the LMI function alias first, then the traditional Functions alias after several retries and a timeout, was simple boilerplate that our agents could crank out.

The one thing we did have to change in our architecture was the assumption that only one query could concurrently execute per Lambda process; instead, to make the most of Lambda Managed Instances, we needed to enable multi-concurrency with up to 16 different Invoke requests executing simultaneously. Each execution environment has 4.9 vCPU, so a busy one runs about three invokes per vCPU, whereas on Functions each invoke had two and a half vCPUs all to itself. That packing is where most of the savings comes from: while one invoke waits on S3, another gets to use the CPU.

This had knock-on effects in three places.

First, garbage collection: since 2019, we'd forced a garbage collection at the start of every invoke, because a Functions sandbox freezes the instant it returns its response, leaving all its garbage behind for the next request to deal with. With sixteen invokes sharing one heap, that would have meant sixteen redundant stop-the-world collections, so now only the invoke that wakes an idle execution environment pays for one.

Second, memory: each execution environment has about 9 GB, which works out to about 1.25 GB per invoke on average and only about 0.6 GB when all sixteen are running (compared to about 4.4 GB per invoke on Functions), so killing a query consuming significant amounts of memory now has to protect the fifteen other queries sharing the same heap, and we shed new work under memory pressure instead.

Third, telemetry: we had to rethink when to mark runtime spans as starting and ending, and we added attributes recording how many other invokes were running alongside each one. (Be very careful with averages here: the median is about two, but at P99 and above it sits right at the cap of 16, and it'll queue right up to that cap whenever things get busy.)

Incorrectly interpreting telemetry, and adjusting thresholds

Because Lambda Managed Instances uses AWS EC2 Compute Savings Plans, the numbers we saw depended upon how much Compute Savings Plan coverage happened to land on the LMI instances. In Europe, our existing commitment was being applied to other usage, so our shiny new LMI hosts were billed at close to on-demand list price; re-priced as though they'd been on an ordinary one-year Compute Savings Plan, Europe's LMI fleet would have come out about 18 index points cheaper on average from August to October, and below the April Functions baseline every week except the three I'll come to shortly.

Europe's cost index (April = 100) as billed, with LMI hosts at on-demand list price (blue), and re-priced at a public one-year Compute Savings Plan rate (green)

Additionally, a confounding factor was that we'd changed the way that we measured the number of bytes decoded off the wire (the denominator of our effective cost per processed byte). This made it appear initially as if we'd achieved a 60% price performance improvement, when all we'd done was tune capacity parameters, savings plans, and compression algorithms.

Our dogfood-style instinct to measure everything had led us astray, so we picked a better metric: query cost per hour of customer data queried, indexed to April, priced at public AWS prices with an ordinary one-year Compute Savings Plan.¹ It's a denominator that none of our own optimizations can move, and using public prices keeps our negotiated pricing out of the comparison.

US query cost per hour of customer data queried (April = 100): Lambda Functions (green), LMI (blue) and S3 GET requests (yellow)

In the US, you can see the switchover in mid-July, when compute moved from Functions (green) to LMI (blue), and cost per hour actually went up: an untuned fleet, running far below break-even. The real drop only came from late August onwards, as bigger segments and bundling shrank S3 (yellow), and as the tuning described below cut LMI.

The most important number to internalize was LMI's break-even point. Per CPU-second, LMI on Graviton5 with a Savings Plan is about seven and a half times cheaper than Lambda Functions. But that figure assumes every CPU you pay for is busy all the time. Functions only bills you while an invoke is running, whereas LMI bills you for the whole fleet, busy or idle (and the management fee is a percentage of on-demand that no Savings Plan reduces). So 7.5x is the break-even: you have to keep the fleet more than about one-seventh busy just to match what Functions would have cost you.

Our first fleets averaged somewhere between 10-16% utilization, which is why our real net saving started out near zero. Rather than try to prevent spilling to Lambda Functions, we found the best indicator of whether we were on target to achieve savings was to measure the fraction of available Invoke slots per execution environment that were in use on average. As long as that figure stayed above 12.5%, it would be cost-neutral, and anything above that figure would be savings.

Why was utilization so low? LMI's autoscaler nominally scales on CPU, but it also adds execution environments whenever invokes are throttled because environments are at their concurrency cap, even when average CPU is far below target. Our traffic arrives in microbursts, so during the working day, there's always some execution environment that's full, and every throttle we saw was a concurrency throttle, never a CPU one. In practice, that makes the controller bang-bang: all day the fleet sits at whatever maximum you allowed, and it only comes back down to the minimum once the whole fleet goes quiet at night or over the weekend. In Europe, demand swung 33 times across a day, while the fleet swung only 7 times. The CPU target barely mattered; the maximum and minimum were our real cost knobs. So we cut back the maximum number of execution environments allowed during each weekday and weekend peak, until we were comfortably above 20% utilization.

Routing got us the rest of the way. Interactive queries go to LMI first, and if they're throttled, we retry with jitter, across several layers, before spilling to Functions. Our first version spilled at the very first throttle, and our graphs showed LMI sitting idle while we paid Functions prices for the overflow; a single retry turned out to rescue about one in nine throttled invokes. Queries that can afford to wait, like large API jobs, go further still: my colleague Ian built a queue that batches up to 64 compatible queries into a single fetch, and a slow mode that waits for an LMI slot instead of racing off to Functions. Every layer trades a little latency for a fuller LMI slot.

We had to add new telemetry, and had many separate Honeycomb Agent and Canvas investigations aiming to lock in price performance. But using LMI gave us new tools that we didn't have access to before on Lambda Functions, namely access to the execution environment's network tx/rx statistics, and to hardware performance counters, including branch mispredicts, stalls, and instructions per cycle (IPC). This enabled us to find the right bottlenecks to optimize, and the point at which we'd increased the number of concurrent invokes per execution environment so much that we were thrashing.

The first bottleneck those counters exposed was CPU quota: each execution environment has a quota enforced by the Linux scheduler, and once you exceed it, you're paused until the next scheduling period. IPC can't see that kind of throttling, because the cycles never happen. On our earliest execution environment shapes, we were throttled for 40-50% of wall time, and giving each environment about 9% more vCPU cut throttling from 22.5% to 5.7%, because demand had been sitting just above quota and the backlog had been feeding on itself.

It wasn't just the switchover: performance engineering

It would be easy to read this post as “we flipped our invokes over to LMI, and the bill went down.” That isn't what happened. Switching to LMI gave us the ability to save money, by changing which costs mattered; realizing the savings took months of performance engineering on top, by me and my colleagues Ian Wilkes, Alex Kahn, and Doug Soo, among others. In the month from mid-October to mid-November alone, the four of us opened more than 150 pull requests, the large majority of them performance and reliability work on the query path.

Why did LMI make that work worthwhile when Functions hadn't? On Functions, cutting CPU didn't cut the bill, because we were paying for wall-clock time spent waiting on S3. On LMI, our hosts were now CPU-bound, so every cycle saved was money saved, directly, in fewer hosts. And with a single CPU generation (Graviton5) to target rather than a mix of Graviton2 and Graviton3, we could finally tune for the chip we were actually running on, which alone was worth about 19% less CPU per row.

Our method was the same for every change: start from continuous CPU profiles collected from production, find the hottest code, make a change, measure it against a benchmark on the real hardware, and then check the production profile again after it deploys. Those same production profiles feed Go's profile-guided optimization (PGO); our most recent refresh of the Lambda profile was built from about 33 hours of a single build in production, 18,017 LMI profiles and 6,098 from retriever pods. Along the way, we found that a Go compiler limitation (golang/go#69046) causes hot functions to stop being inlined into PGO-inlined copies of their callers, so we built a CI check that fails the build if any of our required hot inlines disappear, rather than discovering the regression in a profile weeks later.

Here's a sampling of what that turned up, roughly in order of how much it mattered (percentages are shares of our Lambda CPU, across both Functions and LMI):

First, the column readers themselves. A fix to how we track which rows have a value in a column took that “presence” bookkeeping from about 15% of US Lambda CPU (and 6.5% in Europe) down to 2.6% (and 1.4%). Reading rows only to skip past them turned out to be about 9% of US Lambda CPU, so our packed and compact readers now skip short gaps by summing deltas instead of decoding every value. Our simple8b integer decoder was zero-filling up to 510 buffer slots for every run-length-encoded word; keeping the buffer zero instead and clearing only what was written took simple8b from 2.58% to 1.93%. And splitting the 19 KB per-segment closure that drove our row loop into smaller, separately inlinable methods made ReadRows about 3% faster on Graviton5, with a few percent more from follow-ups once it was split.

Second, filter evaluation. One customer's AI agents were issuing regex filters that were really just literal strings, and in Europe, regexp.Match alone had grown to 11.7% of our Lambda CPU; matching a pure literal with bytes.Contains instead took each match from 89.9 to 22.6 ns, and small sets of literals (alternations, anchors, leading or trailing .*) went from 189.7 to 6.4 ns, all checked for equivalence against Go's own regexp test corpus plus 1.65 million fuzz executions. For substring search, I wrote NEON kernels using Go's new simd/archsimd experiment, making SEARCH 34-85% faster and case-sensitive CONTAINS 35-93% faster on longer values. Filters on dictionary-encoded string columns now evaluate once per dictionary code when a segment opens, for the first 256 codes (which cover 81% of the rows in those columns), and then answer each row with a single table lookup; that took filter checking from 3.35% to 1.90% of Lambda CPU. And filters on derived columns that just alias another column, like COALESCE($service.name, $service_name) (43% of US Lambda invoke time comes from queries with filters like that), now run directly on the source column, dropping derived column computation from 7.6% to 1% of Lambda CPU.

Third and finally, the bytes we move. We now defer opening a segment's result columns from S3 until at least one row has passed the query's filters, so segments that match nothing skip those GETs entirely. We carried an upstream Go change for a faster arm64 SIMD memmove (26-39% faster for 128 B to 64 KB copies) ahead of its release. And it was the PMU counters that pointed us at Europe's unusually high branch-miss rate: over half of zstd decode's branch mispredicts came from one branch in match copying, which I fixed upstream in Klaus Post's compress library (klauspost/compress#1295) by copying matches in 32-byte blocks.

LMI also brought some surprises of its own, which needed engineering rather than tuning. In Europe, 3.7% of LMI segment reads that opened new connections spent at least 4.5 seconds just setting up the connection to S3, compared to 65 out of 9.6 million on Functions; the culprit was DNS lookups stalling, so S3 dials now abandon a lookup that's still pending after one second, retry on a fresh resolver, and cache resolved addresses for a few seconds. In the US, connections taking two seconds or longer fell from 0.46% to 0.004%, and DNS p99 from 594 to 36 ms. Doug found that every published LMI function version keeps at least three execution environments warm, so CI runs that were canceled partway had leaked enough versions to fill our test environments' capacity providers and break our main branch builds; CI now prunes unaliased versions before it publishes. And because sixteen invokes now share one heap, and a dying environment's heap could grow by 5–9 GB per second, new invokes are now turned away to spill to Functions once an environment crosses our memory-pressure threshold, rather than taking the whole environment down with them.

The final cost savings

Even after our initial wins in the US environment, there still was work to do. We were paying a significant overhead for things that come with having hosts at all. Every host got a root EBS volume sized per vCPU that we never touched, and anything priced per host or per launch, such as configuration recording and threat detection, scaled with fleet churn rather than with useful work. Together, that overhead had been about 10% of fleet cost.

At times, we found ourselves with stranded CPU that was blocked on reading bytes from S3 via the host network. Since AWS Lambda Functions gained scalable network bandwidth (from 625 Mbps at 2 GB of memory, up to 3,000 Mbps at 10 GB), the specifications for Lambda Functions throughput per invoke were actually higher than what each invoke got on our brand new shiny Graviton5 hosts, especially once we were multiplexing 16 concurrently running queries per execution environment. Europe made for a lovely natural experiment here: its workload is network-bound, and when scalable bandwidth reached our production accounts on the first of July, Europe's cost per hour fell about 40% overnight, while the CPU-bound US barely moved. I also made a mistake when I assumed network was the sole limiting factor: I moved Europe onto a network-optimized instance family for three weeks in September, and it cost us more than it saved.

Europe's query cost per hour of customer data queried (April = 100): Lambda Functions (green), LMI (blue) and S3 GET requests (yellow)

Fortunately, the AWS team was able to co-develop with us a mechanism to trim back the amount of EBS requested (by three quarters), and to use the instance bandwidth shaping functionality to enable vpc-1 mode, which devotes more instance bandwidth to VPC networking rather than EBS throughput. That gave our bandwidth-bound hosts about 17% more network throughput, which meant we could run that many fewer hosts, and brought the host overhead down from about ten percent of fleet cost to about five.

With the more powerful Graviton5 processors and some performance improvements I made to Klaus Post's Go compression libraries for zstd, it became worth it to change over from lz4 (which we mentioned at the start of this blog) to zstd, even though it was approximately 2-3 times more expensive in CPU. After this change rolled through a majority of bytes written and read by our fleet, we finally had balance between CPU and network bounds on the Lambda Managed Instance hardware. We no longer needed expensive high-network instances, nor did we need to fall back to Lambda Functions for throughput.

Not every win was about cost, either. S3 SlowDown (throttling) errors fell from 1.31% of requests on Functions to 0.0001% on LMI, because LMI's reads go through a VPC endpoint. When a runaway backfill hit us, LMI absorbed it for about 80% less than Functions would have cost. And because our bursts are big enough to exhaust the regional arm64 Functions capacity, running our baseline on our own LMI fleet keeps our peaks from starving us (or anyone else). The tradeoff is that the slowest S3 reads got slower, because many invokes now share one network card.

After one final pass of polish on our instance purchase strategy, instance type selection, compression algorithms, and amount of data per S3 file, our cost per hour of customer data queried was down about 40% in the US and 56% in Europe compared to April, all while query volume grew about 30%.

Conclusion

Lambda Functions is still the right tool for spiky, latency-sensitive work, and it's still there catching our spill on the busiest days. But once a large share of your Lambda workload becomes a steady baseline, or is waiting on the network rather than computing, it's worth asking whether you're paying a premium for elasticity you aren't using. For us, LMI turned out to be the best of both worlds: the same Lambda API and routing we'd relied on for seven years, running on current-generation Graviton hardware that we choose and that our Savings Plans cover.

If you're considering the same move, our advice on the capacity side is to treat utilization as the only number that matters: know your break-even before you start, measure what fraction of your invoke slots are busy (and don't trust averages of anything), and set your fleet minimum and maximum deliberately, per region and per weekday versus weekend. Pick a cost denominator that your own changes can't move, look at public list prices as well as your bill so you can tell when a Savings Plan is landing in the wrong place, and tell your account team what you're about to do (and check your EC2 and EBS quotas, not just Lambda's). And keep your latency-insensitive batch work off Lambda Functions; queue it onto capacity you're already paying for.

If you'd like to see how fast and cost-effective Honeycomb's queries are for yourself, sign up for a free Honeycomb account today.

Sign up for a free account

See how fast and cost-effective Honeycomb's queries are.

¹ Indexed to April 2026 = 100, using public AWS prices with LMI hosts and Lambda on a one-year Compute Savings Plan, so that the comparison doesn't depend on any negotiated pricing.