Compute
Where the code runs: EC2 with Auto Scaling groups and launch templates, the ECS/EKS/Fargate container options, and Lambda with its invocation models, cold starts, and concurrency limits. You learn to justify the choice from traffic shape and job duration, since that is the opening question of most AWS rounds.
part ofAWSoverview, primer and where to startread it →on this pageshowhide
explore
- Choosing a Compute Model6 questions
- ECS and Fargate6 questions
- EKS in the AWS Compute Menu3 questions
- Elastic Beanstalk, App Runner and Lightsail5 questions
- EC229 questions
- Instance Families and Sizing6 questions
- Instance Lifecycle and Metadata6 questions
- AMIs and User Data Bootstrapping5 questions
- Auto Scaling Groups and Launch Templates6 questions
- Purchase Options and Spot Economics6 questions
- AWS Lambda29 questions
- Invocation Models and Retries6 questions
- Concurrency and Cold Starts6 questions
- Packaging, Layers and Limits6 questions
- Event Source Mappings6 questions
- Execution Roles, VPC Access and Config5 questions
questions
78 · 6 sectionsYour team is deploying a new HTTP API on AWS and must choose between AWS Lambda, ECS on Fargate, and EC2 instances. Which decision axes drive that choice, and which way does each one point?
basics
~20 sDrive the choice from five axes: request duration, traffic shape and duty cycle, statefulness, latency and cold-start tolerance, and how much operations the team can carry. Lambda wins on spiky, short, stateless work; containers win on steady, long-running or stateful work.
A nightly ETL job runs for about 40 minutes and needs roughly 8 GB of memory. A colleague proposes running it on AWS Lambda. What is your objection, and which AWS compute option would you choose instead?
basics
~20 sA Lambda function cannot run for 40 minutes: the maximum timeout is 15 minutes, so the job would be killed mid-run. Memory is fine, duration is not. Run it as a scheduled container task, on AWS Batch, or split it into shorter chunks.
Across EC2, ECS on Fargate, and AWS Lambda, who is responsible for patching the operating system, and which capacity decisions remain yours in each case?
basics
~20 sOn EC2 you patch the guest OS and decide instance count and type. On ECS with Fargate, AWS runs the host and you only size and scale tasks. On Lambda, AWS handles the host and scaling; you set memory and code.
A steady internal API serves a roughly constant 200 requests per second around the clock and currently runs on AWS Lambda. How would you reason about whether moving it to ECS on Fargate is cheaper, and what must the comparison include?
basics
~20 sCompare cost curves, not sticker prices. Lambda's bill grows with requests times duration and never amortizes; a container's bill is set by provisioned capacity and time, so it wins at high, steady duty cycle. Include front-door, networking and engineering costs.
A service keeps a large warm in-memory cache and holds long-lived connections to a database and a message broker. The team wants to move it to AWS Lambda. What architectural objections do you raise?
basics
~20 sLambda gives each concurrent invocation its own isolated environment and freezes it once the handler returns, so a shared warm cache cannot exist, connection count scales with concurrency instead of instance count, and background work after the response stops running.
In Amazon ECS, explain what a task definition, a task, and a service each are, and when you would use the RunTask API directly instead of putting the workload behind a service.
basics
~20 sAn ECS task definition is the immutable blueprint: image, CPU and memory, IAM roles, logging. A task is one running copy of it. A service keeps a desired count of tasks alive and replaces failures; RunTask launches one-off jobs.
In an ECS task definition, what is the difference between the task role (taskRoleArn) and the task execution role (executionRoleArn), and which of the two does application code inside the container use?
basics
~20 sThe execution role is assumed by the ECS agent or Fargate infrastructure to pull the image, fetch secrets and write logs before your code runs. The task role is what application code inside the container uses to call AWS.
ECS supports several network modes, and Fargate requires awsvpc. What does the awsvpc network mode give each task, and how does it change things compared with the bridge network mode on the EC2 launch type?
basics
~20 sawsvpc gives every ECS task its own elastic network interface with a private VPC IP and its own security groups, so tasks get first-class VPC identity, no host port mapping, and register in load balancer target groups by IP address.
A new Fargate service deployed into private VPC subnets never reaches RUNNING: every task stops with a CannotPullContainerError naming the ECR registry. What are the likely causes, and how would you work through them?
basics
~20 sThe task cannot reach the registry. A Fargate task in a private subnet needs a NAT route or ECR, S3 and CloudWatch Logs VPC endpoints, outbound 443 allowed in its security group, and an execution role with ECR permissions.
Every rolling deployment of an ECS service behind a load balancer produces a burst of 5xx errors, and some freshly started tasks are killed and replaced before they serve anything. Which ECS service settings explain that, and how do you make deployments clean?
basics
~20 sNew tasks are being health-checked or killed before they are ready, and old tasks are stopped before their connections drain. Set healthCheckGracePeriodSeconds, align the container stopTimeout with the target group deregistration delay, and handle SIGTERM gracefully.
A team on AWS is choosing between Amazon ECS and Amazon EKS to run a new containerized service. What would make EKS the right choice, and what do you take on by picking it?
basics
~20 sChoose EKS when you need conformant Kubernetes — its ecosystem of Helm charts, operators and CRDs, portability off AWS, or existing Kubernetes skills. The price is a per-cluster fee plus a permanent upgrade and add-on treadmill that ECS does not impose.
Amazon EKS is described as "managed Kubernetes". Which parts of an EKS cluster does AWS actually run and bill you for, and which parts stay your responsibility?
basics
~20 sAWS runs the EKS control plane — API server, etcd, scheduler, controller manager — across multiple Availability Zones for a flat hourly charge per cluster. The data plane stays yours: nodes, node patching, add-on versions, upgrades and the workloads.
Amazon EKS offers two AWS-side mechanisms for giving a pod its own IAM role: IAM Roles for Service Accounts (IRSA) and EKS Pod Identity. How do they differ operationally, and how would you choose between them?
basics
~20 sIRSA federates the cluster's OIDC issuer into IAM, so each role's trust policy names that cluster's issuer and service account. EKS Pod Identity instead trusts the service principal pods.eks.amazonaws.com once and maps roles to service accounts through an EKS API association, which scales better across clusters.
Elastic Beanstalk, App Runner and Lightsail
all 5 Elastic Beanstalk, App Runner and Lightsail questions →When you create a load-balanced Elastic Beanstalk environment, what does Beanstalk actually provision in your AWS account, and why is changing those resources by hand a problem?
basics
~20 sBeanstalk is a control plane, not a runtime. It drives a CloudFormation stack that creates an Auto Scaling group of EC2 instances, a load balancer, security groups and CloudWatch alarms in your account. Hand-edits are not recorded in the environment configuration and get overwritten.
In AWS Elastic Beanstalk, how do an application, an application version, and an environment relate to one another, and what does Beanstalk itself add to your AWS bill?
basics
~20 sAn Elastic Beanstalk application is a namespace holding application versions — uploaded code bundles kept in S3. An environment is a running set of AWS resources with exactly one version deployed. Beanstalk is free; you pay for the resources it provisions.
AWS App Runner takes a container image or a source repository and hands back an HTTPS URL. What does it create on your behalf, what does it scale on, and how are you billed when no requests are arriving?
basics
~20 sApp Runner runs your container on AWS-managed capacity behind a managed HTTPS endpoint, with no cluster, load balancer or certificate of yours. It scales on concurrent requests per instance, and bills memory continuously for warm instances but CPU only while requests are being served.
A service has run on AWS Elastic Beanstalk for two years, and each release now changes more .ebextensions configuration than application code. How do you judge whether the team has hit the platform's ceiling, and what would you try before migrating off it?
basics
~20 sYou have hit the ceiling when the environment configuration, not the application, is what the team maintains. First exhaust the supported hatches — option settings, platform hooks, and raw CloudFormation in .ebextensions Resources. Migration is cheap because the environment is already an Auto Scaling group behind a load balancer.
Amazon Lightsail sells servers as fixed-price monthly bundles. What is actually included in that price, and what does an engineer give up compared with running the same workload on EC2?
basics
~20 sA Lightsail bundle rolls vCPU, memory, SSD storage and a monthly data-transfer allowance into one predictable price, with a simplified console and prebuilt blueprints. What you give up is the surrounding AWS ecosystem: your own VPC, Auto Scaling, and fine-grained integration.
What is EC2 user data, at what point in an instance's life does the script run, and as which OS user?
basics
~20 sUser data is a text blob you attach to an EC2 instance that cloud-init fetches from the instance metadata service at first boot. A script starting with a shebang runs as root, once per instance — not on every reboot.
In an EC2 Auto Scaling group, what do the minimum, maximum and desired capacity settings each control, and what happens if you manually terminate one of the group's instances?
basics
~20 sDesired capacity is the instance count the group tries to run right now; minimum and maximum are the floor and ceiling that scaling can never cross. Manually terminating an instance leaves the group below desired, so it launches a replacement.
Decode the EC2 instance type name m7g.2xlarge: what does each part of the name tell you, and how many vCPUs and how much memory does that instance have?
basics
~20 sm7g.2xlarge splits into four parts: family m (general purpose, roughly 4 GiB of memory per vCPU), generation 7, processor letter g (AWS Graviton, arm64), and size 2xlarge — 8 vCPUs and 32 GiB of memory.
In EC2, what do you get and what do you give up by running an instance as Spot instead of On-Demand, and how is the Spot price actually determined?
basics
~20 sSpot Instances run on EC2 capacity AWS currently has idle, at a steep discount off On-Demand, but AWS can reclaim them at any moment with a two-minute warning. Spot prices move gradually with supply and demand; there is no bidding auction.
A deployment script that launches EC2 instances hardcodes an AMI ID. It works in us-east-1 and fails in eu-west-1 with InvalidAMIID.NotFound. Why, and what is an AMI actually made of?
basics
~20 sAMI IDs are scoped to a single AWS region, so an ID registered in us-east-1 does not exist in eu-west-1. Copy the image with CopyImage, which mints a new ID, or look the ID up per region instead of hardcoding it.
What is a cold start in AWS Lambda, and why does the same function usually respond faster on the next invocation a moment later?
basics
~20 sA cold start is the extra latency Lambda spends creating a new execution environment for an invocation: downloading the code, starting the runtime, and running your initialization code before the handler runs. A later invocation reuses that environment and skips all of it.
You attach an SQS queue to a Lambda function, yet SQS never pushes anything anywhere. What is the event source mapping, and how do queue messages actually end up in your handler?
basics
~20 sAn event source mapping is a separate Lambda resource that runs an AWS-managed poller. It reads the queue for you, groups messages into a batch, and invokes your function synchronously with that batch in the event's Records array.
An AWS Lambda function needs to write objects to S3, and API Gateway needs to be able to invoke it. Which of Lambda's two permission mechanisms — the execution role or the function's resource-based policy — covers each, and how do they differ?
basics
~10 sThe execution role says what the function may do, so it grants the S3 write. The function's resource-based policy says who may invoke the function, so it grants API Gateway the lambda:InvokeFunction action.
In AWS Lambda, what is the difference between invoking a function with InvocationType RequestResponse and InvocationType Event, and who is responsible for retrying a failure in each case?
basics
~20 sRequestResponse is synchronous: the caller waits, receives the function's result or error, and must retry itself. Event is asynchronous: Lambda returns 202 immediately, queues the event internally, and retries a failed invocation on your behalf.
How do you work out how many concurrent executions an AWS Lambda function needs, and what does Lambda do to a synchronous invocation once the account's concurrency limit is reached?
basics
~20 sConcurrency equals invocation rate multiplied by average duration in seconds: 500 requests per second at 200 ms needs about 100 concurrent executions. Beyond the account's per-Region limit Lambda throttles, and a synchronous caller gets HTTP 429 with TooManyRequestsException.