
EC2 vs Lambda vs Fargate: Designing the Same AWS Workload 3 Ways
What happens when you design the same image-processing workload using EC2, Lambda, and ECS with Fargate? This comparison explores the real trade-offs between control, scalability, reliability, security, cost, and operational effort—and how workload characteristics should drive your AWS architecture decisions.
AWS gives us multiple ways to run application workloads.
The difficult part isn't knowing what EC2, Lambda, or Fargate are.
The difficult part is deciding which one actually makes sense for a particular workload.
So I took a simple image-processing use case and designed three possible architectures using different AWS compute approaches.
Rather than asking "Which service is best?", I wanted to understand the trade-offs between control, scalability, reliability, security, operational effort, and cost.
And the biggest thing I learned was this:
Architecture should follow the workload — not the popularity of the service.
In this article, I'll take the same workload and design it using:
- Amazon EC2
- AWS Lambda
- Amazon ECS with AWS Fargate
The goal isn't to declare a winner.
The goal is to understand when each approach makes sense.
The Problem:-
Imagine we're building an e-commerce platform where sellers upload product images.
A seller uploads:
shirt.jpg But our application needs to automatically generate different versions:
- Original image
- Large image
- Thumbnail
The basic workflow is:
User ↓Upload Image ↓Store Image ↓Process Image ↓Store Processed ImagesAt first, this sounds simple.
But as soon as we think like engineers, more questions appear:
- What happens when 10 images are uploaded?
- What happens when 10,000 arrive simultaneously?
- What happens if processing fails?
- Who manages the servers?
- How do we control access to the images?
- How much infrastructure do we need when there is no traffic?
- How easily can we scale the system?
To explore these questions, I designed the same workload using EC2, Lambda, and ECS with Fargate.
🖥️ Architecture 1: Amazon EC2
The first approach is the most traditional one.
Amazon EC2 gives us virtual servers in AWS.
We can install our application, configure the environment, and run the image-processing service ourselves.
The architecture could look like:
User │ ▼ S3 │ ▼ EC2 │ Image Processing App │ ▼ S3
The important thing here is control.
We can choose the operating system, install dependencies, configure the environment, and have significant control over how our application runs.
But that control comes with responsibility.
We need to think about:
- Operating system updates
- Security patches
- Application deployment
- Server configuration
- Monitoring
- Scaling
- Availability
For example, if traffic suddenly increases, one EC2 instance may not be enough.
We might need more additional components such as load balancing, Auto Scaling, monitoring, and health checks.
The trade-off?
More control → more operational responsibility.
EC2 starts making sense when we need that control or have workloads that don't naturally fit a serverless execution model.
⚡ Architecture 2: AWS Lambda
Then I asked a different question:
Do we actually need a server running continuously?
For image processing, perhaps not.
The processing only needs to happen when an image is uploaded.
That makes this workload a good candidate for an event-driven architecture.
The architecture becomes:
User │ ▼ S3 │ Image uploaded │ ▼ Lambda │ Process image │ ▼ S3
Instead of keeping an application server running and waiting for work, an event can trigger a Lambda function.
Conceptually:
Image uploaded ↓Lambda triggered ↓Function executes ↓Image processed ↓Execution endsThis is where the idea of serverless becomes interesting.
Serverless doesn't mean that servers don't exist.
It means we don't have to manage the underlying servers ourselves.
That removes a lot of operational work.
We don't have to worry about:
- Provisioning servers
- Operating system patching
- Maintaining idle servers
- Manually scaling individual servers
But Lambda isn't automatically better.
It has a different execution model and its own constraints around things such as execution duration, memory, concurrency, runtime environment, and workload characteristics.
So the right question isn't:
"Is Lambda better than EC2?"
It's:
"Does my workload fit the Lambda execution model?"
For event-driven, short-lived processing, the answer may be yes.
📦 Architecture 3: ECS + Fargate
The third approach becomes interesting when our application is packaged as a Docker container.
First, Docker allows us to package our application and its dependencies into a container.
Conceptually:
Application ↓Docker Image ↓ContainerBut we still need somewhere to run that container.
That's where Amazon ECS and AWS Fargate enter the picture.
A simplified architecture looks like:
User │ ▼ S3 │ ▼ ECS / Fargate │ Docker Container │ Process Image │ ▼ S3
A useful way to think about the three technologies is:
Docker → packages the application
ECS → orchestrates and manages the containers
Fargate → provides serverless compute for those containers
This gives us a middle ground.
We get the flexibility of containers without having to manage the underlying servers ourselves.
This can be particularly useful when:
- We already have containerized applications
- We need more runtime flexibility than a simple Lambda function
- We have multiple containerized services
- We want more control over the application environment
But there is also more complexity than simply creating a Lambda function.
⚔️ EC2 vs Lambda vs Fargate
After looking at all three architectures, the differences become much clearer.
Consideration | EC2 | Lambda | ECS + Fargate |
|---|---|---|---|
Server management | High | Very low | Low |
Control | High | Lower | High at container level |
Scaling | Configured by us | Managed automatically within service limits | Managed/configurable |
Deployment model | Application on VM | Function | Container |
Event-driven workloads | Good | Excellent | Good |
Long-running workloads | Excellent | More constrained | Excellent |
Container support | Yes | Possible with limitations | Native |
Operational complexity | Higher | Lower | Medium |
Runtime flexibility | High | More constrained | High |
But this table doesn't tell us which one to choose.
For that, we need to think about the workload.
📈 Scalability: What happens when traffic increases?
Imagine our platform normally receives:
100 image uploads/day
but suddenly receives:
100,000 image uploads/day.
With EC2, we'd need to design a scaling strategy around instances.
We could use multiple instances and Auto Scaling.
With Lambda, AWS can handle scaling of function executions according to the service's concurrency model and limits.
With Fargate, we can scale the number of running tasks based on workload requirements.
So all three can scale.
But the way they scale is different.
That's an important distinction.
Scalability isn't simply:
"Can it handle more traffic?"
It's also:
"How much engineering effort is required to make it handle more traffic reliably?"
🛡️ Reliability: What happens when something fails?
Now imagine an image-processing operation fails.
A production system shouldn't simply lose the image and forget about it.
We might need:
- Error handling
- Logging
- Monitoring
- Retry mechanisms
- Alerts
- Dead-letter handling for appropriate event-driven designs
The architecture therefore isn't complete just because:
Image → Compute → Image
A production architecture needs to consider:
What happens when things go wrong?
For example, an event-driven design could introduce a queue between the upload and processing stages:
S3 │ ▼Event │ ▼Queue │ ▼Compute │ ▼Processed Image
This can help decouple components and provide a place to buffer work during traffic spikes.
That's one of the biggest differences between simply knowing AWS services and thinking about reliability.
🔐 Security: Who is allowed to access the images?
Our S3 bucket shouldn't simply be publicly accessible.
We need to think about:
- IAM
- IAM roles
- Least privilege
- Encryption
- Bucket permissions
- Secure access patterns
For example, Lambda shouldn't receive unlimited AWS permissions just because it needs to read an image.
Ideally, it receives only the permissions necessary for its task.
This is the principle of least privilege.
A simplified permission model could be:
Lambda ↓IAM Role ↓Read required S3 objects ↓Process image ↓Write processed object
The same principle applies to EC2 instances and ECS tasks.
Security isn't something we add at the end.
It should be considered while designing the architecture.
💰 What about cost?
This was one of the most interesting parts of the comparison.
It would be misleading to simply say:
"Lambda is cheaper."
or:
"EC2 is cheaper."
The actual answer depends on:
- Workload
- Traffic
- Runtime
- Resource requirements
- Utilization
- Scaling patterns
- Data transfer
- Storage
- Region
- Architecture
For example, if a workload runs continuously at high utilization, a different compute model may make more economic sense than if the workload runs only occasionally.
So instead of asking:
"Which service is cheapest?"
I think the better question is:
"Which service gives me the right balance between cost, control, scalability, and operational effort for this workload?"
🧠 My Decision
For the specific image-processing workload I designed, I'd start by evaluating S3 + Lambda.
Why?
Because the workload is naturally event-driven:
Image uploaded ↓Processing required ↓Lambda executes ↓Processing completed
There is no obvious reason to keep a traditional application server running and waiting for work.
However, I wouldn't blindly choose Lambda for every image-processing system.
If the workload required:
- Long-running processing
- Specialized software
- More control over the runtime
- A containerized environment
I'd evaluate ECS + Fargate.
And if I needed extensive server-level control or had a workload that fit a traditional virtual-machine architecture particularly well, I'd consider EC2.
When I think about choosing between the three, I use a workload-first approach:

The key takeaway is that all three can solve the problem.
The difference is how they solve it and what trade-offs they introduce.
💡 The Biggest Lesson
Before this comparison, I thought learning AWS meant learning what each service does.
After looking at the same workload through three different architectures, I realized that knowing a service and knowing when to use it are two different skills.
EC2 isn't "old."
Lambda isn't "automatically better."
Fargate isn't simply "EC2 without servers."
Each exists because different workloads have different requirements.
The engineering challenge is identifying those requirements and choosing the architecture that satisfies them with the right balance of:
Control + Scalability + Reliability + Security + Cost + Operational Effort
And that's probably the most important cloud concept I've taken away from this exercise.
🤔 What would you choose?
Suppose this system suddenly needs to process 100,000 image uploads during a traffic spike.
Would you choose:
EC2, Lambda, or ECS/Fargate?
And here's the part I'm most interested in:
Would your decision be driven primarily by cost, scalability, control, or operational simplicity?
I'd love to hear how you'd design it—and what trade-offs you'd be willing to make.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article