Should I use AWS Lambda or Fargate for a spiky, event-driven web API?
I'm designing a new API that will handle image processing. The traffic is very inconsistent—sometimes 1,000 requests a minute, then nothing for hours. I’m torn between the simplicity of Lambda and the control of Fargate. Which one is more cost-effective and easier to maintain for this specific type of spiky workload?
2025-09-08 in Cloud Technology by Christopher Reed
| 12126 Views
All answers to this question.
For your specific case of "nothing for hours," Lambda is almost certainly the better choice. With Lambda, you pay exactly zero when the API isn't being called. Fargate, while "serverless" in terms of management, still requires you to have at least one task running to handle requests, meaning you pay for idle time. However, be mindful of "cold starts" in Lambda, especially if your image processing libraries are large. If your users can't afford a 2-3 second delay on that first request after a quiet period, you might need Provisioned Concurrency, which adds to the cost.
Answered 2025-09-10 by Cynthia Higgins
What is the average execution time for your image processing? Remember that Lambda has a 15-minute timeout. If some of your larger images take longer than that to process, wouldn't Fargate be the safer architectural choice for long-running tasks?
Answered 2025-09-11 by Matthew Foster
-
Matthew, most of our processing finishes in under 30 seconds. I hadn't considered the 15-minute limit, but it shouldn't be an issue for us. The bigger concern for us is the memory limit; some high-res images might need more than the 10GB that Lambda provides. We'll have to benchmark that first.
Commented 2025-09-13 by Christopher Reed
Start with Lambda. It's much faster to deploy and requires almost zero infrastructure code compared to setting up ECS clusters and task definitions. You can always migrate to Fargate later if you hit limits.
Answered 2025-09-14 by Rebecca Wood
-
Agreed with Rebecca. The "Developer Experience" on Lambda is just so much smoother for getting a MVP out the door. Plus, the integration with S3 triggers for image uploads is native and very easy to set up.
Commented 2025-09-16 by Cynthia Higgins
Write a Comment
Your email address will not be published. Required fields are marked (*)

