info@naevatec.com (+34) 911 407 507
Illustration of a live broadcaster's video and audio feed flowing through AWS Lambda orchestration icons into a tiered pool of EC2 server racks labeled cold, hibernated, warmed, and instantly activated, then fanning out to a massive grid of audience screens.

From Fargate Tasks to a Hibernated EC2 Warm Pool

Case StudyAWS

A platform running large-scale live events — webinars among them, alongside product launches, town halls, and live shows — had already moved its per-event compute onto AWS Fargate. That architecture worked, but the workload each task actually ran, a browser capturing a call plus an FFmpeg pipeline chunking it for distribution, was heavy enough that Fargate's per-task pricing stopped being the cheapest way to run it.

Context

This client's platform already ran on the Fargate- and Lambda-based elastic architecture described in an earlier case study: a pool of Fargate tasks, launched and torn down per event, orchestrated by Lambda functions reacting to demand instead of an always-on control service. That migration had already solved the problem of paying for idle capacity.

What it hadn't solved was the cost of the workload itself once the platform's per-event compute grew beyond what the earlier webinar case ever needed: each unit of work now ran a full browser to capture a live call's composed output, plus an FFmpeg-based pipeline to chunk that output for distribution. Neither piece is small or cheap to run, and Fargate's per-task pricing carries its own overhead on top of the underlying compute, overhead that matters more as the task itself gets heavier. Running the same workload on EC2 instances directly, instead of as Fargate tasks, would cost less for a workload this size.

The project

The obstacle was cold start. Booting a fresh EC2 instance from scratch, loading its AMI, and bringing the application up, is far slower than launching a new Fargate task, too slow for compute that has to be ready the moment an event starts. Hibernated EC2 instances close that gap: resuming one from hibernation takes somewhere between 4 and 10 seconds, fast enough to disappear into an event's normal startup time.

That only works with a pool of already-hibernated instances ready to resume on demand, and the team already understood pools: the Fargate task pool from the earlier migration had its own requirements around batch-launching many tasks at once for bursty demand, and that same model mapped cleanly onto a pool of hibernated EC2 instances. Managing that pool turned out to be the easy part, once reframed this way: AWS EC2 Auto Scaling Groups already support warm pools of hibernated instances natively, so the fleet scales efficiently using AWS's own autoscaling logic instead of a custom pool manager built and maintained in-house, the way the Fargate task pool had been.

Each instance follows a lifecycle of its own states to match. A fresh instance runs its startup.sh script while STARTING_UP, becomes WARMED_IP once hibernated inside the EC2 warm pool, and is claimed as READY the moment the Auto Scaling Group needs it, a handoff a Scale Lambda and a dedicated lifecycle-ready Lambda trigger instantly rather than polling for it. From there the instance moves through IN_USE, IDLE (Chrome already running, driven by a play.sh script, waiting to join the call), and PUBLISHING, where FFmpeg encodes the composed call into an HLS stream, with a further set of Lambdas handling CDN distribution and storage housekeeping around what gets published.

Architecture diagram of the EC2 instance lifecycle: a fresh instance runs startup.sh while
STARTING_UP, becomes WARMED_IP once hibernated in the EC2 warm pool, is claimed as READY by
an Auto Scaling Group triggered by a Scale Lambda and a Lifecycle-Ready Lambda, then moves
through IN_USE, IDLE (running Chrome via play.sh), and PUBLISHING (encoding an FFmpeg HLS
stream) before reaching the live audience, with additional Lambdas handling CDN and storage
housekeeping.

The genuinely hard part was something the Fargate model never had to consider: making each instance ephemeral. Every instance in the pool is used for exactly one session and never reused. Cleaning a used instance back to a trustworthy, ready state, closing the browser down cleanly, clearing out whatever the FFmpeg pipeline left behind, confirming nothing lingers, proved more complex and no faster than simply terminating it and replacing it with a fresh instance from the same AMI. Treating every instance as single-use removed an entire category of state to reason about, at the cost of relying on the warm pool to keep replenishing itself with new, clean instances as fast as used ones are discarded.

Our role

Technologies

Conclusion and lessons learnt

Fargate's convenience comes at a price, and that price stops being worth paying once a workload is heavy enough on its own. The move to EC2 instances only worked out as smoothly as it did because the pool-based thinking behind the earlier Fargate migration carried over directly; hibernation and Auto Scaling Groups turned "pool of ready compute" into something AWS itself manages well, rather than something to rebuild from scratch. What stood out most was how cleanly the ephemeral-instance trade-off resolved once framed as a comparison: cleaning up isn't actually cheaper than starting over. This project is the real origin of what we now call ERTSA, our Elastic Real-Time Serverless Architecture.