AWS Lambda Web 函数在最后一个请求后约 7 分钟继续计费内存
AWS Lambda Web Functions keep billing memory ~7 minutes after the last request

原始链接: https://www.easel.sh/blog/lambda-web-functions-idle-memory

Easel 测试了 AWS Lambda Web Functions,发现空闲执行环境在最后一次请求后仍持续计费内存 5–7 分钟,使得许多低流量应用成本较高。尽管 Web Functions 能很好地处理负载,但终止空闲环境会导致运行时失败。Easel 因此将应用执行迁移到自己的共享服务器,仅将 Lambda 用于溢出流量。一个 US East 主机于 11 月 2 日上线。Ashburn 对相同 Next.js 应用的基准测试显示,Easel 的主机提供 1.5–3 倍更快的热请求、更快的链式 SHA-256 哈希,以及空闲 12 分钟后约 3.5 倍更快的冷启动;在 5 分钟间隔后,它在 14ms 内恢复暂停环境,而 Web Functions 需要 908ms。结果尚早,来自单一区域和一个小型应用,样本有限。Easel 得出结论:自运营计算更符合其经济性,并且可以超越 Web Functions,但需要承担更多基础设施责任。

一项 AWS Lambda Web Functions 基准测试发现,环境在最后一次请求后仍存活约 5–7 分钟,因此空闲时也会计费内存。作者表示,这对他们的工作负载并不合适;与传统 Lambda 事件函数不同,后者在调用后会冻结,并且只按执行时间计费。他们尝试提前退出进程,但 AWS 会将其记录为错误。评论者指出,空闲时间有助于刷新遥测数据、持续流量可降低其影响,且空闲超时不可配置。他们还讨论了 GCP Cloud Run、Firecracker 和 Vercel Fluid Compute 等替代方案,以及冷启动样本量小和硬件差异方面的顾虑。作者澄清,Web Functions 可能仍适合活跃工作负载,而 Easel 使用的是传统 Lambda。
相关文章

原文

When AWS announced Lambda Web Functions in October, I was excited.

At Easel, we'd spent months building infrastructure to run web applications efficiently on traditional Lambda. Native HTTP servers, concurrent requests, and active CPU billing sounded like exactly what we'd been looking for.

If Web Functions worked the way we hoped, we could potentially replace a substantial amount of our custom infrastructure.

So we decided to put them to the test.

A few weeks later, we'd decided to run our own compute instead. And as it turns out, our own infrastructure was faster, too.

The five-minute problem

Our initial experiments were promising. Web Functions handled 300 concurrent requests without errors, and a new function was serving requests in under nine seconds.

But we quickly ran into something that didn't work for us.

Execution environments continued running and accruing memory charges for 5–7 minutes after their last request.

Web Functions bill CPU only while it's actively used, but memory is billed for the entire lifetime of an execution environment, even when no requests are running.

AWS documents this behavior. What surprised us was how long those environments remained alive.

Across six representative environments, we observed idle periods ranging from 313 to 411 seconds. The processes remained active throughout, and there was no configurable idle timeout to shorten their lifetime.

Six environments after their last completed request, us-east-1, October 26.

For a 200ms request followed by 345 seconds of inactivity, that's roughly 1,700 times the request duration in metered memory time.

We checked the economics against CloudWatch and AWS Cost Explorer. Across our experiment, memory accounted for approximately 88% of the calculated compute and request costs at published list prices, even though our application only used around 160–210 MB.

The entire experiment amounted to about two cents at list prices. Hardly alarming on its own.

But Easel needs to support thousands of applications with unpredictable traffic. Some receive sustained traffic, while others might get only a few requests per day. At that scale, the cost of keeping independently metered environments alive starts to matter.

We even tried terminating environments ourselves after 10 seconds of inactivity. That reduced metered environment time by roughly 20×, but AWS recorded every intentional exit as a runtime failure.

It wasn't something we wanted to rely on in production.

What if we ran the compute ourselves?

Rather than adopt Web Functions, we decided to move application execution onto servers we operate ourselves, keeping traditional Lambda available for overflow.

This gives us control over scheduling and resource allocation. We can share capacity across applications without paying AWS for each idle environment, and scale beyond our own infrastructure when demand requires it.

Requests enter the Easel.sh edge, which routes them to our own compute, where many apps share one machine. Lambda takes only the overflow.

Our first self-operated compute host went live in US East on November 2, serving applications including Easel's own website.

But taking ownership of the compute raised another question: How would our performance compare to AWS?

We deployed the same Next.js 16 application to both platforms and ran a series of benchmarks from a client in Ashburn, Virginia.

The results surprised us.

Median time to first byte (first chunk for streaming), excluding the TLS handshake. 100 requests per route per platform from Ashburn, Virginia.

Our host delivered 1.5–3× faster median warm-request times across all four workloads.

The difference wasn't limited to network or routing overhead. Running the same 20,000 chained SHA-256 operations took 29.2ms on our host versus 43.8ms on Web Functions, about 1.5× faster.

And cold starts told a similar story.

After leaving both applications idle for 12 minutes, we triggered fresh execution environments on each platform.

First request after 12 minutes idle, sent to both platforms at the same moment. Time to first byte, excluding the TLS handshake. Two paired trials only.

In both trials, Easel started serving requests about 3.5× faster.

We also saw an interesting difference after a shorter idle period. Following one five-minute gap, Web Functions had already terminated its environment and needed 908ms to respond. Easel resumed its paused environment and responded in just 14ms.

These are early results from a single region and a small application, not a comprehensive performance study. The cold-start comparison has only two paired samples, and we haven't benchmarked sustained throughput yet.

Still, seeing our own infrastructure outperform AWS across these initial workloads was encouraging.

Taking ownership of the infrastructure

Running our own compute comes with additional responsibilities. We have to manage capacity, handle failures, and make sure resources are distributed efficiently across applications.

But it also gives us the freedom to optimize the entire execution path, rather than working around the constraints of another platform.

Web Functions may be a good fit for applications with sustained traffic, where idle memory costs are less significant. For Easel, the economics of running large numbers of independent applications led us in a different direction.

And our initial benchmarks suggest that the decision doesn't have to come at the expense of performance.

We're taking on more infrastructure complexity so developers using Easel don't have to.

How we measured
Dates
Benchmarks ran November 11–12, 2026 (UTC). Idle-memory measurements are from October 26, 2026.
Setup
The same Next.js 16 application on Easel's self-operated US East host and on AWS Lambda Web Functions in us-east-1.
Client
One client in Ashburn, Virginia.
Timing
Time to first byte, excluding TLS connection setup but including network transit and platform routing.
Samples
About 100 requests per route per platform for warm requests. Two paired trials for cold starts.
Hardware
The platforms ran on different hardware and resource configurations, so these compare deployments, not normalized hardware.
Pricing
AWS costs use published list prices.
联系我们 contact @ memedata.com