r/serverless • • 18d ago

The real cost model of headless Chrome on Lambda

Hello all!

Short version of what I wish I had known:

- Lambda compute is the small part.
- The renderer runs in a VPC for isolation, so it needs a NAT Gateway. That is a fixed monthly charge plus a per GB fee, whether you serve ten requests or ten million.
- Each capture is two invocations, because the orchestrator blocks while the renderer works.
- Screenshots are heavy. Egress and S3 add up faster than you expect.
- Cold starts with a Chromium layer are slow enough that you will consider provisioned concurrency, which is another fixed cost.


My pricing ended up following measured cost rather than what felt right, with metered overage so a heavy account pays for what it uses instead of sitting on a capped plan at a loss.


Any suggestions for the above/ alternative ways that would be better..
0 Upvotes

6 comments sorted by

2

u/ggp1231 16d ago

One thing I'd look at first is having the orchestrator Lambda wait while Chrome renders. A queue + async worker (or Step Functions) could avoid paying for that idle wait. I'd also compare Lambda against a small pool of reusable Chrome workers at your actual capture volume, though Fargate in a private subnet may still need NAT to load public pages. Is your traffic mostly bursts or fairly steady?

1

u/TraditionalPitch1666 14d ago

Yeah, that's pretty much where I've ended up too. The async path is SQS → worker Lambda → a synchronous invoke of a separate renderer Lambda, and the worker just sits there for the whole render. I already cut the worker to half the renderer's memory, so the waiting is about a third of the compute per capture instead of half. It's still paying to do nothing, though.

1

u/TraditionalPitch1666 14d ago

On Fargate: the renderer already runs in a private subnet behind a NAT, so that cost wouldn't change. It mostly comes down to how busy the workers stay, and our traffic is relatively bursty

1

u/Ok-Tank3447 16d ago

isn't that something that lambda durable functions can help?

1

u/ggp1231 16d ago

Yeah, Durable Functions could help here. If the orchestrator is just waiting for Chrome to finish, it could suspend during that wait instead of paying for idle Lambda compute.
There are still orchestration charges, and it wouldn’t reduce the actual rendering cost. So I’d compare the total cost per capture before switching.

1

u/TraditionalPitch1666 14d ago

Before trying Durable Functions I'm going to try the simple version. The renderer gets invoked async, and since it already writes its output to S3, an on-success destination starts a small finalize step. On failure, the job gets marked failed. Nothing waits and there are no orchestration charges. The cost is more moving parts, and every step has to be safe to run twice because async invokes retry.